Adds logical deletes to shared channel remotes and remote clusters (#28159)
* Adds logical deletes to shared channel remotes and remote clusters Instead of physically deleting the shared channel remote and remote clusters records when a channel is unshared, a remote uninvited or a remote cluster is deleted, now those have a logical `DeleteAt` field that is set. This allows us to safely restore shared channels between two remote clusters (as of now resetting the cursor without backfilling their contents) and to know which connections were established in the past and now are severed. * Delete the index in remoteclusters before adding the new column * Fix bad error check
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
19733eef1e
Коммит
f8202309ce
@@ -8781,6 +8781,9 @@ func (c *Client4) GetRemoteClusters(ctx context.Context, page, perPage int, filt
|
||||
if filter.ExcludePlugins {
|
||||
v.Set("exclude_plugins", "true")
|
||||
}
|
||||
if filter.IncludeDeleted {
|
||||
v.Set("include_deleted", "true")
|
||||
}
|
||||
url := c.remoteClusterRoute()
|
||||
if len(v) > 0 {
|
||||
url += "?" + v.Encode()
|
||||
@@ -8894,7 +8897,7 @@ func (c *Client4) DeleteRemoteCluster(ctx context.Context, remoteClusterId strin
|
||||
return BuildResponse(r), nil
|
||||
}
|
||||
|
||||
func (c *Client4) GetSharedChannelRemotesByRemoteCluster(ctx context.Context, remoteId string, excludeHome, excludeRemote bool, page, perPage int) ([]*SharedChannelRemote, *Response, error) {
|
||||
func (c *Client4) GetSharedChannelRemotesByRemoteCluster(ctx context.Context, remoteId string, excludeHome, excludeRemote, includeDeleted bool, page, perPage int) ([]*SharedChannelRemote, *Response, error) {
|
||||
v := url.Values{}
|
||||
if excludeHome {
|
||||
v.Set("exclude_home", "true")
|
||||
@@ -8902,6 +8905,9 @@ func (c *Client4) GetSharedChannelRemotesByRemoteCluster(ctx context.Context, re
|
||||
if excludeRemote {
|
||||
v.Set("exclude_remote", "true")
|
||||
}
|
||||
if includeDeleted {
|
||||
v.Set("include_deleted", "true")
|
||||
}
|
||||
if page != 0 {
|
||||
v.Set("page", fmt.Sprintf("%d", page))
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ type RemoteCluster struct {
|
||||
SiteURL string `json:"site_url"`
|
||||
DefaultTeamId string `json:"default_team_id"`
|
||||
CreateAt int64 `json:"create_at"`
|
||||
DeleteAt int64 `json:"delete_at"`
|
||||
LastPingAt int64 `json:"last_ping_at"`
|
||||
Token string `json:"token"`
|
||||
RemoteToken string `json:"remote_token"`
|
||||
@@ -75,6 +76,7 @@ func (rc *RemoteCluster) Auditable() map[string]interface{} {
|
||||
"site_url": rc.SiteURL,
|
||||
"default_team_id": rc.DefaultTeamId,
|
||||
"create_at": rc.CreateAt,
|
||||
"delete_at": rc.DeleteAt,
|
||||
"last_ping_at": rc.LastPingAt,
|
||||
"creator_id": rc.CreatorId,
|
||||
"plugin_id": rc.PluginID,
|
||||
@@ -271,6 +273,7 @@ func (rc *RemoteCluster) ToRemoteClusterInfo() RemoteClusterInfo {
|
||||
Name: rc.Name,
|
||||
DisplayName: rc.DisplayName,
|
||||
CreateAt: rc.CreateAt,
|
||||
DeleteAt: rc.DeleteAt,
|
||||
LastPingAt: rc.LastPingAt,
|
||||
}
|
||||
}
|
||||
@@ -284,6 +287,7 @@ type RemoteClusterInfo struct {
|
||||
Name string `json:"name"`
|
||||
DisplayName string `json:"display_name"`
|
||||
CreateAt int64 `json:"create_at"`
|
||||
DeleteAt int64 `json:"delete_at"`
|
||||
LastPingAt int64 `json:"last_ping_at"`
|
||||
}
|
||||
|
||||
@@ -457,4 +461,5 @@ type RemoteClusterQueryFilter struct {
|
||||
OnlyPlugins bool
|
||||
ExcludePlugins bool
|
||||
RequireOptions Bitmask
|
||||
IncludeDeleted bool
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ type SharedChannelRemote struct {
|
||||
CreatorId string `json:"creator_id"`
|
||||
CreateAt int64 `json:"create_at"`
|
||||
UpdateAt int64 `json:"update_at"`
|
||||
DeleteAt int64 `json:"delete_at"`
|
||||
IsInviteAccepted bool `json:"is_invite_accepted"`
|
||||
IsInviteConfirmed bool `json:"is_invite_confirmed"`
|
||||
RemoteId string `json:"remote_id"`
|
||||
@@ -265,6 +266,7 @@ type SharedChannelRemoteFilterOpts struct {
|
||||
InclUnconfirmed bool
|
||||
ExcludeHome bool
|
||||
ExcludeRemote bool
|
||||
IncludeDeleted bool
|
||||
}
|
||||
|
||||
// SyncMsg represents a change in content (post add/edit/delete, reaction add/remove, users).
|
||||
|
||||
Ссылка в новой задаче
Block a user