From 4dd8bae5c91fa4aef09d865d8fef1acd84f90925 Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 17 Oct 2021 00:47:22 +0200 Subject: Update dependencies (#1610) * Update dependencies * Update module to go 1.17 --- .../mattermost-server/v5/model/group_syncable.go | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'vendor/github.com/mattermost/mattermost-server/v5/model/group_syncable.go') diff --git a/vendor/github.com/mattermost/mattermost-server/v5/model/group_syncable.go b/vendor/github.com/mattermost/mattermost-server/v5/model/group_syncable.go index 6a4d4023..eb3bdf09 100644 --- a/vendor/github.com/mattermost/mattermost-server/v5/model/group_syncable.go +++ b/vendor/github.com/mattermost/mattermost-server/v5/model/group_syncable.go @@ -60,14 +60,14 @@ func (syncable *GroupSyncable) UnmarshalJSON(b []byte) error { if err != nil { return err } + var channelId string + var teamId string for key, value := range kvp { switch key { case "team_id": - syncable.SyncableId = value.(string) - syncable.Type = GroupSyncableTypeTeam + teamId = value.(string) case "channel_id": - syncable.SyncableId = value.(string) - syncable.Type = GroupSyncableTypeChannel + channelId = value.(string) case "group_id": syncable.GroupId = value.(string) case "auto_add": @@ -75,30 +75,40 @@ func (syncable *GroupSyncable) UnmarshalJSON(b []byte) error { default: } } + if channelId != "" { + syncable.TeamID = teamId + syncable.SyncableId = channelId + syncable.Type = GroupSyncableTypeChannel + } else { + syncable.SyncableId = teamId + syncable.Type = GroupSyncableTypeTeam + } return nil } func (syncable *GroupSyncable) MarshalJSON() ([]byte, error) { type Alias GroupSyncable - switch syncable.Type { case GroupSyncableTypeTeam: return json.Marshal(&struct { - TeamID string `json:"team_id"` - TeamDisplayName string `json:"team_display_name,omitempty"` - TeamType string `json:"team_type,omitempty"` + TeamID string `json:"team_id"` + TeamDisplayName string `json:"team_display_name,omitempty"` + TeamType string `json:"team_type,omitempty"` + Type GroupSyncableType `json:"type,omitempty"` *Alias }{ TeamDisplayName: syncable.TeamDisplayName, TeamType: syncable.TeamType, TeamID: syncable.SyncableId, + Type: syncable.Type, Alias: (*Alias)(syncable), }) case GroupSyncableTypeChannel: return json.Marshal(&struct { - ChannelID string `json:"channel_id"` - ChannelDisplayName string `json:"channel_display_name,omitempty"` - ChannelType string `json:"channel_type,omitempty"` + ChannelID string `json:"channel_id"` + ChannelDisplayName string `json:"channel_display_name,omitempty"` + ChannelType string `json:"channel_type,omitempty"` + Type GroupSyncableType `json:"type,omitempty"` TeamID string `json:"team_id,omitempty"` TeamDisplayName string `json:"team_display_name,omitempty"` @@ -109,6 +119,7 @@ func (syncable *GroupSyncable) MarshalJSON() ([]byte, error) { ChannelID: syncable.SyncableId, ChannelDisplayName: syncable.ChannelDisplayName, ChannelType: syncable.ChannelType, + Type: syncable.Type, TeamID: syncable.TeamID, TeamDisplayName: syncable.TeamDisplayName, -- cgit v1.2.3