* - columns added to ShareChannelRemotes: lastpostcreateat, lastpostupdateat
- SyncMsg and SyncResponse moved to `model` package
- field added to RemoteCluster struct: PluginID

* sync new posts before updated posts to ensure post order in MS Teams

* add plugid to remoteclusters table and store

* don't sync history by default
Этот коммит содержится в:
Doug Lauder
2023-12-04 13:10:20 -05:00
коммит произвёл GitHub
родитель b2ec1ff8ae
Коммит 8bf9e4c481
22 изменённых файлов: 471 добавлений и 132 удалений

Просмотреть файл

@@ -4,6 +4,7 @@
package model
import (
"encoding/json"
"net/http"
"unicode/utf8"
)
@@ -100,7 +101,9 @@ type SharedChannelRemote struct {
IsInviteConfirmed bool `json:"is_invite_confirmed"`
RemoteId string `json:"remote_id"`
LastPostUpdateAt int64 `json:"last_post_update_at"`
LastPostId string `json:"last_post_id"`
LastPostUpdateID string `json:"last_post_id"`
LastPostCreateAt int64 `json:"last_post_create_at"`
LastPostCreateID string `json:"last_post_create_id"`
}
func (sc *SharedChannelRemote) IsValid() *AppError {
@@ -248,3 +251,49 @@ type SharedChannelRemoteFilterOpts struct {
RemoteId string
InclUnconfirmed bool
}
// SyncMsg represents a change in content (post add/edit/delete, reaction add/remove, users).
// It is sent to remote clusters as the payload of a `RemoteClusterMsg`.
type SyncMsg struct {
Id string `json:"id"`
ChannelId string `json:"channel_id"`
Users map[string]*User `json:"users,omitempty"`
Posts []*Post `json:"posts,omitempty"`
Reactions []*Reaction `json:"reactions,omitempty"`
}
func NewSyncMsg(channelID string) *SyncMsg {
return &SyncMsg{
Id: NewId(),
ChannelId: channelID,
}
}
func (sm *SyncMsg) ToJSON() ([]byte, error) {
b, err := json.Marshal(sm)
if err != nil {
return nil, err
}
return b, nil
}
func (sm *SyncMsg) String() string {
json, err := sm.ToJSON()
if err != nil {
return ""
}
return string(json)
}
// SyncResponse represents the response to a synchronization event
type SyncResponse struct {
UsersLastUpdateAt int64 `json:"users_last_update_at"`
UserErrors []string `json:"user_errors"`
UsersSyncd []string `json:"users_syncd"`
PostsLastUpdateAt int64 `json:"posts_last_update_at"`
PostErrors []string `json:"post_errors"`
ReactionsLastUpdateAt int64 `json:"reactions_last_update_at"`
ReactionErrors []string `json:"reaction_errors"`
}