Make the user-info more robust
This commit is contained in:
parent
30182f9222
commit
6826b6ea8c
1 changed files with 4 additions and 10 deletions
|
@ -165,9 +165,9 @@ func (p *Plugin) ExecuteCommand(_ *plugin.Context, args *model.CommandArgs) (*mo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pref, appErr := p.API.GetPreferenceForUser(user.Id, "pp_com.mattermost.msteams-sync", "platform")
|
prefValue := ""
|
||||||
if appErr != nil {
|
if pref, appErr := p.API.GetPreferenceForUser(user.Id, "pp_com.mattermost.msteams-sync", "platform"); appErr == nil {
|
||||||
return p.sendEphemeralAndExit(fmt.Sprintf("ERROR getting user preferences: %s", appErr.Error()), args)
|
prefValue = pref.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, _ := p.Q().
|
rows, _ := p.Q().
|
||||||
|
@ -175,18 +175,12 @@ func (p *Plugin) ExecuteCommand(_ *plugin.Context, args *model.CommandArgs) (*mo
|
||||||
From("msteamssync_users").
|
From("msteamssync_users").
|
||||||
Where(sq.Eq{"mmuserid": user.Id}).
|
Where(sq.Eq{"mmuserid": user.Id}).
|
||||||
Query()
|
Query()
|
||||||
// if err != nil {
|
|
||||||
// return p.sendEphemeralAndExit(fmt.Sprintf("ERROR querying for msteamssync user: %s", err), args)
|
|
||||||
// }
|
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
var mmTeamsUserID string
|
var mmTeamsUserID string
|
||||||
var token string
|
var token string
|
||||||
var lastConnectAt int
|
var lastConnectAt int
|
||||||
var lastDisconnectAt int
|
var lastDisconnectAt int
|
||||||
// if !rows.Next() {
|
|
||||||
// return p.sendEphemeralAndExit(fmt.Sprintf("User %q not found in the msteamssync_users table", email), args)
|
|
||||||
// }
|
|
||||||
if rows.Next() {
|
if rows.Next() {
|
||||||
if err := rows.Scan(&mmTeamsUserID, &token, &lastConnectAt, &lastDisconnectAt); err != nil {
|
if err := rows.Scan(&mmTeamsUserID, &token, &lastConnectAt, &lastDisconnectAt); err != nil {
|
||||||
return p.sendEphemeralAndExit(fmt.Sprintf("ERROR scanning rows: %s", err), args)
|
return p.sendEphemeralAndExit(fmt.Sprintf("ERROR scanning rows: %s", err), args)
|
||||||
|
@ -202,7 +196,7 @@ func (p *Plugin) ExecuteCommand(_ *plugin.Context, args *model.CommandArgs) (*mo
|
||||||
if token != "" {
|
if token != "" {
|
||||||
hasToken = true
|
hasToken = true
|
||||||
}
|
}
|
||||||
return p.sendEphemeralAndExit(fmt.Sprintf("User %q has\n - `mmTeamsUserID`: %s\n - `hasToken`: %v\n - `lastConnectAt`: %d\n - `lastDisconnectAt`: %d\n - `remoteID`: %s\n - `primaryPlatform preference`: %s", email, mmTeamsUserID, hasToken, lastConnectAt, lastDisconnectAt, remoteID, pref.Value), args)
|
return p.sendEphemeralAndExit(fmt.Sprintf("User %q has\n - `mmTeamsUserID`: %s\n - `hasToken`: %v\n - `lastConnectAt`: %d\n - `lastDisconnectAt`: %d\n - `remoteID`: %s\n - `primaryPlatform preference`: %s", email, mmTeamsUserID, hasToken, lastConnectAt, lastDisconnectAt, remoteID, prefValue), args)
|
||||||
case "channel-info":
|
case "channel-info":
|
||||||
if len(parameters) != 1 {
|
if len(parameters) != 1 {
|
||||||
return p.sendEphemeralAndExit("channel-info must receive the channel ID", args)
|
return p.sendEphemeralAndExit("channel-info must receive the channel ID", args)
|
||||||
|
|
Loading…
Reference in a new issue