@@ 5,7 5,9 @@
and `root-url=<app-url>/mattermost`
## Install mattermost app
-* As system admin run the following command in your mattermost instance `/apps install http <app-url>/mattermost/manifest.json`
+* As system admin run the following command in your mattermost instance `/apps install http <app-url>/mattermost/<org-slug>/manifest.json`
* In the modal, grant the proper permissions to the app and click on install
* Once the app is installed, run the following command `/link-connect`. You will receive a private message with
a link to connect your current channel with one organization. Follow the instructions and click on save.
+* Then, you will be allowed to use `link-add`, `link-add-short` and `link-search`
+* In case you haven't connect your user with the current MM integration, you will receive a private message with a link.
@@ 243,8 243,9 @@ func (s *Service) SearchCommand(c echo.Context) error {
if err != nil {
return err
}
+ lt := localizer.GetSessionLocalizer(c)
if len(mmConns) == 0 {
- return c.JSON(http.StatusOK, apps.NewTextResponse("No slack connection found"))
+ return c.JSON(http.StatusOK, apps.NewTextResponse(lt.Translate("No slack connection found")))
}
mmConn := mmConns[0]
@@ 273,7 274,7 @@ func (s *Service) SearchCommand(c echo.Context) error {
if err != nil {
return err
}
- return c.JSON(http.StatusOK, apps.NewTextResponse("We sent you a private msg"))
+ return c.JSON(http.StatusOK, apps.NewTextResponse(lt.Translate("We sent you a private msg")))
}
opts = &database.FilterOptions{
Filter: sq.And{
@@ 291,7 292,6 @@ func (s *Service) SearchCommand(c echo.Context) error {
}
org := orgs[0]
if links.BillingEnabled(gctx.Server.Config) && org.IsRestricted([]int{models.BillingStatusFree}) {
- lt := localizer.GetSessionLocalizer(c)
msg := lt.Translate("Sorry, free accounts do not support Mattermost Integration. Please upgrade to continue")
return c.JSON(http.StatusOK, apps.NewTextResponse(msg))
}
@@ 300,8 300,6 @@ func (s *Service) SearchCommand(c echo.Context) error {
if len(orgs) == 0 {
return fmt.Errorf("No user found")
}
- lang := user.Settings.Account.DefaultLang
- lt := localizer.GetLocalizer(lang)
text, ok := creq.Values["text"].(string)
if !ok {
return c.JSON(http.StatusOK, apps.NewTextResponse(lt.Translate("The text to be searched is required")))
@@ 380,12 378,13 @@ func (s *Service) ShortCommand(c echo.Context) error {
Filter: sq.Eq{"mc.team_id": teamID},
Limit: 1,
}
+ lt := localizer.GetSessionLocalizer(c)
mmConns, err := models.GetMattermostConnections(c.Request().Context(), opts)
if err != nil {
return err
}
if len(mmConns) == 0 {
- return c.JSON(http.StatusOK, apps.NewTextResponse("No slack connection found"))
+ return c.JSON(http.StatusOK, apps.NewTextResponse(lt.Translate("No slack connection found")))
}
mmConn := mmConns[0]
@@ 398,13 397,12 @@ func (s *Service) ShortCommand(c echo.Context) error {
return err
}
if len(orgs) == 0 {
- return c.JSON(http.StatusOK, apps.NewTextResponse("No organization found"))
+ return c.JSON(http.StatusOK, apps.NewTextResponse(lt.Translate("No organization found")))
}
gctx := c.(*server.Context)
org := orgs[0]
if links.BillingEnabled(gctx.Server.Config) && org.IsRestricted([]int{models.BillingStatusFree}) {
- lt := localizer.GetSessionLocalizer(c)
msg := lt.Translate("Sorry, free accounts do not support Mattermost Integration. Please upgrade to continue")
return c.JSON(http.StatusOK, apps.NewTextResponse(msg))
}
@@ 433,14 431,12 @@ func (s *Service) ShortCommand(c echo.Context) error {
if err != nil {
return err
}
- return c.JSON(http.StatusOK, apps.NewTextResponse("We sent you a private msg"))
+ return c.JSON(http.StatusOK, apps.NewTextResponse(lt.Translate("We sent you a private msg")))
}
user, err := models.GetUser(c.Request().Context(), mmUsers[0].UserID, true)
if err != nil {
return err
}
- lang := user.Settings.Account.DefaultLang
- lt := localizer.GetLocalizer(lang)
ctx := c.Request().Context()
ctx = auth.Context(ctx, user)
title, ok := creq.Values["title"].(string)
@@ 527,8 523,9 @@ func (s *Service) AddCommand(c echo.Context) error {
if err != nil {
return err
}
+ lt := localizer.GetSessionLocalizer(c)
if len(mmConns) == 0 {
- return c.JSON(http.StatusOK, apps.NewTextResponse("No slack connection found"))
+ return c.JSON(http.StatusOK, apps.NewTextResponse(lt.Translate("No slack connection found")))
}
mmConn := mmConns[0]
@@ 582,8 579,6 @@ func (s *Service) AddCommand(c echo.Context) error {
if err != nil {
return err
}
- lang := user.Settings.Account.DefaultLang
- lt := localizer.GetLocalizer(lang)
linkURL, ok := creq.Values["url"].(string)
if !ok {
return c.JSON(http.StatusOK, apps.NewTextResponse(lt.Translate("Url is required")))
@@ 642,17 637,19 @@ func (s *Service) ConnectCommand(c echo.Context) error {
slug,
creq.Context.Team.Id,
)
- msg := fmt.Sprintf("Please click in the following link to tie a org %s", baseURL.String())
+ lt := localizer.GetSessionLocalizer(c)
+ msg := lt.Translate("Please click in the following link to tie a org %s", baseURL.String())
post := &model.Post{ChannelId: channel.Id, Message: msg}
_, err = botClient.CreatePost(post)
if err != nil {
return err
}
- return c.JSON(http.StatusOK, apps.NewTextResponse("We sent you a private msg"))
+ return c.JSON(http.StatusOK, apps.NewTextResponse(lt.Translate("We sent you a private msg")))
}
func (s *Service) Ping(c echo.Context) error {
- return c.JSON(http.StatusOK, apps.NewDataResponse("Installed successfully"))
+ lt := localizer.GetSessionLocalizer(c)
+ return c.JSON(http.StatusOK, apps.NewDataResponse(lt.Translate("Installed successfully")))
}
func (s *Service) ServeBinding(c echo.Context) error {