forked from mattermost/mattermost-plugin-mscalendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
connect.go
33 lines (25 loc) · 1.15 KB
/
connect.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved.
// See License for license information.
package command
import (
"fmt"
"github.com/firstfoundry/ff-mattermost-plugin-mscalendar/calendar/config"
)
const (
ConnectBotAlreadyConnectedTemplate = "The bot account is already connected to %s account `%s`. To connect to a different account, first run `/%s disconnect_bot`."
ConnectBotSuccessTemplate = "[Click here to link the bot's %s account.](%s/oauth2/connect_bot)"
ConnectAlreadyConnectedTemplate = "Your Mattermost account is already connected to %s account `%s`. To connect to a different account, first run `/%s disconnect`."
ConnectErrorMessage = "There has been a problem while trying to connect. err="
)
func (c *Command) connect(_ ...string) (string, bool, error) {
ru, err := c.Engine.GetRemoteUser(c.Args.UserId)
if err == nil {
return fmt.Sprintf(ConnectAlreadyConnectedTemplate, config.Provider.DisplayName, ru.Mail, config.Provider.CommandTrigger), false, nil
}
out := ""
err = c.Engine.Welcome(c.Args.UserId)
if err != nil {
out = ConnectErrorMessage + err.Error()
}
return out, true, nil
}