Ping new shared channels remotes immediately (#25850)
* option for auto inviting plugin to all shared channels. * auto-invite remotes to shared channels when flag set * fix unit test * immediately ping new remotes; fix unique siteurl bug * make i18n-extract * fix translations * fix merge conflicts * make modules-tidy * revert accidental go.mod change * revert accidental go.sum changes --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
@@ -122,7 +122,8 @@ func remoteClusterAcceptMessage(c *Context, w http.ResponseWriter, r *http.Reque
|
||||
|
||||
func remoteClusterConfirmInvite(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
// make sure remote cluster service is running.
|
||||
if _, appErr := c.App.GetRemoteClusterService(); appErr != nil {
|
||||
rcs, appErr := c.App.GetRemoteClusterService()
|
||||
if appErr != nil {
|
||||
c.Err = appErr
|
||||
return
|
||||
}
|
||||
@@ -155,6 +156,7 @@ func remoteClusterConfirmInvite(c *Context, w http.ResponseWriter, r *http.Reque
|
||||
}
|
||||
audit.AddEventParameterAuditable(auditRec, "remote_cluster", rc)
|
||||
|
||||
// check if the invitation has expired
|
||||
if time.Since(model.GetTimeForMillis(rc.CreateAt)) > remotecluster.InviteExpiresAfter {
|
||||
c.Err = model.NewAppError("remoteClusterAcceptMessage", "api.context.invitation_expired.error", nil, "", http.StatusBadRequest)
|
||||
return
|
||||
@@ -166,12 +168,9 @@ func remoteClusterConfirmInvite(c *Context, w http.ResponseWriter, r *http.Reque
|
||||
return
|
||||
}
|
||||
|
||||
rc.RemoteTeamId = confirm.RemoteTeamId
|
||||
rc.SiteURL = confirm.SiteURL
|
||||
rc.RemoteToken = confirm.Token
|
||||
|
||||
if _, err := c.App.UpdateRemoteCluster(rc); err != nil {
|
||||
c.Err = err
|
||||
if _, rcsErr := rcs.ReceiveInviteConfirmation(confirm); rcsErr != nil {
|
||||
c.Err = model.NewAppError("remoteClusterConfirmInvite", "api.command_remote.confirm_invitation.error",
|
||||
map[string]any{"Error": rcsErr.Error()}, "", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ func (a *App) RegisterPluginForSharedChannels(opts model.RegisterPluginOpts) (re
|
||||
rc = &model.RemoteCluster{
|
||||
Name: opts.Displayname,
|
||||
DisplayName: opts.Displayname,
|
||||
SiteURL: model.SiteURLPlugin + opts.PluginID, // require a unique siteurl
|
||||
Token: model.NewId(),
|
||||
CreatorId: opts.CreatorID,
|
||||
PluginID: opts.PluginID,
|
||||
|
||||
@@ -133,6 +133,7 @@ func (rp *RemoteProvider) doCreate(a *app.App, args *model.CommandArgs, margs ma
|
||||
rc := &model.RemoteCluster{
|
||||
Name: name,
|
||||
DisplayName: displayname,
|
||||
SiteURL: model.SiteURLPending + model.NewId(), // require a unique siteurl
|
||||
Token: model.NewId(),
|
||||
CreatorId: args.UserId,
|
||||
}
|
||||
@@ -207,7 +208,7 @@ func (rp *RemoteProvider) doAccept(a *app.App, args *model.CommandArgs, margs ma
|
||||
return responsef(args.T("api.command_remote.accept_invitation.error", map[string]any{"Error": err.Error()}))
|
||||
}
|
||||
|
||||
return responsef("##### " + args.T("api.command_remote.accept_invitation", map[string]any{"SiteURL": rc.SiteURL}))
|
||||
return responsef("##### " + args.T("api.command_remote.accept_invitation", map[string]any{"SiteURL": rc.GetSiteURL()}))
|
||||
}
|
||||
|
||||
// doRemove removes a remote cluster from the database, effectively revoking the trust relationship.
|
||||
@@ -246,11 +247,11 @@ func (rp *RemoteProvider) doStatus(a *app.App, args *model.CommandArgs, _ map[st
|
||||
fmt.Fprintf(&sb, "| :---- | :---- | :---- | :---- | :---- | :---- | :---- | \n")
|
||||
|
||||
for _, rc := range list {
|
||||
accepted := formatBool(args.T, rc.SiteURL != "")
|
||||
accepted := formatBool(args.T, rc.IsConfirmed())
|
||||
online := formatBool(args.T, isOnline(rc.LastPingAt))
|
||||
lastPing := formatTimestamp(rc.LastPingAt)
|
||||
|
||||
fmt.Fprintf(&sb, "| %s | %s | %s | %s | %s | %s | %s |\n", rc.Name, rc.DisplayName, rc.RemoteId, rc.SiteURL, accepted, online, lastPing)
|
||||
fmt.Fprintf(&sb, "| %s | %s | %s | %s | %s | %s | %s |\n", rc.Name, rc.DisplayName, rc.RemoteId, rc.GetSiteURL(), accepted, online, lastPing)
|
||||
}
|
||||
return responsef(sb.String())
|
||||
}
|
||||
@@ -273,7 +274,7 @@ func getRemoteClusterAutocompleteListItems(a *app.App, includeOffline bool) ([]m
|
||||
for _, rc := range clusters {
|
||||
item := model.AutocompleteListItem{
|
||||
Item: rc.RemoteId,
|
||||
HelpText: fmt.Sprintf("%s (%s)", rc.DisplayName, rc.SiteURL)}
|
||||
HelpText: fmt.Sprintf("%s (%s)", rc.DisplayName, rc.GetSiteURL())}
|
||||
list = append(list, item)
|
||||
}
|
||||
return list, nil
|
||||
@@ -294,7 +295,7 @@ func getRemoteClusterAutocompleteListItemsNotInChannel(a *app.App, channelID str
|
||||
for _, rc := range all {
|
||||
item := model.AutocompleteListItem{
|
||||
Item: rc.RemoteId,
|
||||
HelpText: fmt.Sprintf("%s (%s)", rc.DisplayName, rc.SiteURL)}
|
||||
HelpText: fmt.Sprintf("%s (%s)", rc.DisplayName, rc.GetSiteURL())}
|
||||
list = append(list, item)
|
||||
}
|
||||
return list, nil
|
||||
|
||||
Ссылка в новой задаче
Block a user