feat: add ViewersCanPostReactions to Chat object

Needed https://github.com/status-im/status-desktop/issues/13523
This commit is contained in:
Jonathan Rainville 2024-03-06 16:46:41 -05:00
parent b02e3b19e2
commit e3810148d8
3 changed files with 43 additions and 34 deletions

View File

@ -87,6 +87,9 @@ type Chat struct {
// Active indicates whether the chat has been soft deleted // Active indicates whether the chat has been soft deleted
Active bool `json:"active"` Active bool `json:"active"`
// ViewersCanPostReactions indicates whether users can post reactions in view only mode
ViewersCanPostReactions bool `json:"viewersCanPostReactions"`
ChatType ChatType `json:"chatType"` ChatType ChatType `json:"chatType"`
// Timestamp indicates the last time this chat has received/sent a message // Timestamp indicates the last time this chat has received/sent a message
@ -500,6 +503,7 @@ func CreateCommunityChat(orgID, chatID string, orgChat *protobuf.CommunityChat,
ReadMessagesAtClockValue: 0, ReadMessagesAtClockValue: 0,
ChatType: ChatTypeCommunityChat, ChatType: ChatTypeCommunityChat,
FirstMessageTimestamp: orgChat.Identity.FirstMessageTimestamp, FirstMessageTimestamp: orgChat.Identity.FirstMessageTimestamp,
ViewersCanPostReactions: orgChat.ViewersCanPostReactions,
} }
} }

View File

@ -96,16 +96,17 @@ type CommunityAdminSettings struct {
} }
type CommunityChat struct { type CommunityChat struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Color string `json:"color"` Color string `json:"color"`
Emoji string `json:"emoji"` Emoji string `json:"emoji"`
Description string `json:"description"` Description string `json:"description"`
Members map[string]*protobuf.CommunityMember `json:"members"` Members map[string]*protobuf.CommunityMember `json:"members"`
Permissions *protobuf.CommunityPermissions `json:"permissions"` Permissions *protobuf.CommunityPermissions `json:"permissions"`
CanPost bool `json:"canPost"` CanPost bool `json:"canPost"`
Position int `json:"position"` ViewersCanPostReactions bool `json:"viewersCanPostReactions"`
CategoryID string `json:"categoryID"` Position int `json:"position"`
CategoryID string `json:"categoryID"`
} }
type CommunityCategory struct { type CommunityCategory struct {
@ -184,16 +185,17 @@ func (o *Community) MarshalPublicAPIJSON() ([]byte, error) {
return nil, err return nil, err
} }
chat := CommunityChat{ chat := CommunityChat{
ID: id, ID: id,
Name: c.Identity.DisplayName, Name: c.Identity.DisplayName,
Color: c.Identity.Color, Color: c.Identity.Color,
Emoji: c.Identity.Emoji, Emoji: c.Identity.Emoji,
Description: c.Identity.Description, Description: c.Identity.Description,
Permissions: c.Permissions, Permissions: c.Permissions,
Members: c.Members, Members: c.Members,
CanPost: canPost, CanPost: canPost,
CategoryID: c.CategoryId, ViewersCanPostReactions: c.ViewersCanPostReactions,
Position: int(c.Position), CategoryID: c.CategoryId,
Position: int(c.Position),
} }
communityItem.Chats[id] = chat communityItem.Chats[id] = chat
} }
@ -320,16 +322,17 @@ func (o *Community) MarshalJSON() ([]byte, error) {
return nil, err return nil, err
} }
chat := CommunityChat{ chat := CommunityChat{
ID: id, ID: id,
Name: c.Identity.DisplayName, Name: c.Identity.DisplayName,
Emoji: c.Identity.Emoji, Emoji: c.Identity.Emoji,
Color: c.Identity.Color, Color: c.Identity.Color,
Description: c.Identity.Description, Description: c.Identity.Description,
Permissions: c.Permissions, Permissions: c.Permissions,
Members: c.Members, Members: c.Members,
CanPost: canPost, CanPost: canPost,
CategoryID: c.CategoryId, ViewersCanPostReactions: c.ViewersCanPostReactions,
Position: int(c.Position), CategoryID: c.CategoryId,
Position: int(c.Position),
} }
communityItem.Chats[id] = chat communityItem.Chats[id] = chat
} }

View File

@ -79,10 +79,11 @@ type Chat struct {
PinnedMessages *PinnedMessages `json:"pinnedMessages,omitempty"` PinnedMessages *PinnedMessages `json:"pinnedMessages,omitempty"`
// Deprecated: CanPost is deprecated in favor of CanPostMessages/CanPostReactions/etc. // Deprecated: CanPost is deprecated in favor of CanPostMessages/CanPostReactions/etc.
// For now CanPost will equal to CanPostMessages. // For now CanPost will equal to CanPostMessages.
CanPost bool `json:"canPost"` CanPost bool `json:"canPost"`
CanPostMessages bool `json:"canPostMessages"` CanPostMessages bool `json:"canPostMessages"`
CanPostReactions bool `json:"canPostReactions"` CanPostReactions bool `json:"canPostReactions"`
Base64Image string `json:"image,omitempty"` ViewersCanPostReactions bool `json:"viewersCanPostReactions"`
Base64Image string `json:"image,omitempty"`
} }
type ChannelGroup struct { type ChannelGroup struct {
@ -505,6 +506,7 @@ func (chat *Chat) populateCommunityFields(community *communities.Community) erro
chat.CanPost = canPostMessages chat.CanPost = canPostMessages
chat.CanPostMessages = canPostMessages chat.CanPostMessages = canPostMessages
chat.CanPostReactions = canPostReactions chat.CanPostReactions = canPostReactions
chat.ViewersCanPostReactions = commChat.ViewersCanPostReactions
return nil return nil
} }