mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
* Add XML struct tags and multi-remote registration for shared channels plugin API Phase 1: Add xml struct tags to model types used in SyncMsg (Post, User, Reaction, Status, PostAcknowledgement, FileInfo, SyncResponse, MembershipChangeMsg). Add custom MarshalXML/UnmarshalXML for SyncMsg (Users map, MentionTransforms map), StringMap, and StringInterface. Exclude Post.Metadata, PrevStatus, and server-internal FileInfo fields from XML. JSON serialization is unaffected. Phase 2: Lift the one-remote-per-plugin constraint so plugins can register multiple remotes with different SiteURLs. Add SiteURL field to RegisterPluginOpts (defaults to "plugin_<PluginID>" for backward compatibility). Add GetAllByPluginID and GetBySiteURL store methods. Rewrite registration to dedup by SiteURL instead of PluginID. Add UnregisterPluginRemoteForSharedChannels for single-remote removal with plugin ownership validation. Validate SiteURL is non-empty in RemoteCluster.IsValid. Simplify IsPlugin() to check PluginID only.
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package model
|
|
|
|
import "net/http"
|
|
|
|
type PostAcknowledgement struct {
|
|
UserId string `json:"user_id" xml:"UserId"`
|
|
PostId string `json:"post_id" xml:"PostId"`
|
|
AcknowledgedAt int64 `json:"acknowledged_at" xml:"AcknowledgedAt"`
|
|
ChannelId string `json:"channel_id" xml:"ChannelId"`
|
|
RemoteId *string `json:"remote_id,omitempty" xml:"RemoteId,omitempty"`
|
|
}
|
|
|
|
func (o *PostAcknowledgement) IsValid() *AppError {
|
|
if !IsValidId(o.UserId) {
|
|
return NewAppError("PostAcknowledgement.IsValid", "model.acknowledgement.is_valid.user_id.app_error", nil, "user_id="+o.UserId, http.StatusBadRequest)
|
|
}
|
|
|
|
if !IsValidId(o.PostId) {
|
|
return NewAppError("PostAcknowledgement.IsValid", "model.acknowledgement.is_valid.post_id.app_error", nil, "post_id="+o.PostId, http.StatusBadRequest)
|
|
}
|
|
|
|
if !IsValidId(o.ChannelId) {
|
|
return NewAppError("PostAcknowledgement.IsValid", "model.acknowledgement.is_valid.channel_id.app_error", nil, "channel_id="+o.ChannelId, http.StatusBadRequest)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (o *PostAcknowledgement) GetRemoteID() string {
|
|
if o.RemoteId != nil {
|
|
return *o.RemoteId
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func (o *PostAcknowledgement) PreSave() {
|
|
if o.AcknowledgedAt == 0 {
|
|
o.AcknowledgedAt = GetMillis()
|
|
}
|
|
}
|