parent
58b57b12a3
commit
8bf03609fc
|
@ -160,6 +160,9 @@ type Chat struct {
|
|||
|
||||
// Image of the chat in Base64 format
|
||||
Base64Image string `json:"image,omitempty"`
|
||||
|
||||
// If true, the chat is invisible if permissions are not met
|
||||
HideIfPermissionsNotMet bool `json:"hideIfPermissionsNotMet,omitempty"`
|
||||
}
|
||||
|
||||
type ChatPreview struct {
|
||||
|
@ -492,6 +495,7 @@ func CreateCommunityChat(orgID, chatID string, orgChat *protobuf.CommunityChat,
|
|||
return &Chat{
|
||||
CommunityID: orgID,
|
||||
CategoryID: orgChat.CategoryId,
|
||||
HideIfPermissionsNotMet: orgChat.HideIfPermissionsNotMet,
|
||||
Name: orgChat.Identity.DisplayName,
|
||||
Description: orgChat.Identity.Description,
|
||||
Active: true,
|
||||
|
|
|
@ -108,6 +108,7 @@ type CommunityChat struct {
|
|||
Position int `json:"position"`
|
||||
CategoryID string `json:"categoryID"`
|
||||
TokenGated bool `json:"tokenGated"`
|
||||
HideIfPermissionsNotMet bool `json:"hideIfPermissionsNotMet"`
|
||||
}
|
||||
|
||||
type CommunityCategory struct {
|
||||
|
@ -197,6 +198,7 @@ func (o *Community) MarshalPublicAPIJSON() ([]byte, error) {
|
|||
ViewersCanPostReactions: c.ViewersCanPostReactions,
|
||||
TokenGated: o.channelEncrypted(id),
|
||||
CategoryID: c.CategoryId,
|
||||
HideIfPermissionsNotMet: c.HideIfPermissionsNotMet,
|
||||
Position: int(c.Position),
|
||||
}
|
||||
communityItem.Chats[id] = chat
|
||||
|
@ -337,6 +339,7 @@ func (o *Community) MarshalJSON() ([]byte, error) {
|
|||
ViewersCanPostReactions: c.ViewersCanPostReactions,
|
||||
TokenGated: o.channelEncrypted(id),
|
||||
CategoryID: c.CategoryId,
|
||||
HideIfPermissionsNotMet: c.HideIfPermissionsNotMet,
|
||||
Position: int(c.Position),
|
||||
}
|
||||
communityItem.Chats[id] = chat
|
||||
|
|
|
@ -176,8 +176,9 @@ func (s *CommunitySuite) TestEditChat() {
|
|||
}
|
||||
|
||||
_, err := org.CreateChat(newChatID, &protobuf.CommunityChat{
|
||||
Identity: identity,
|
||||
Permissions: permissions,
|
||||
Identity: identity,
|
||||
Permissions: permissions,
|
||||
HideIfPermissionsNotMet: false,
|
||||
})
|
||||
s.Require().NoError(err)
|
||||
|
||||
|
@ -203,8 +204,9 @@ func (s *CommunitySuite) TestEditChat() {
|
|||
org.config.PrivateKey = s.identity
|
||||
org.config.ID = &s.identity.PublicKey
|
||||
editChanges, err := org.EditChat(newChatID, &protobuf.CommunityChat{
|
||||
Identity: editedIdentity,
|
||||
Permissions: editedPermissions,
|
||||
Identity: editedIdentity,
|
||||
Permissions: editedPermissions,
|
||||
HideIfPermissionsNotMet: true,
|
||||
})
|
||||
|
||||
s.Require().NoError(err)
|
||||
|
@ -218,6 +220,7 @@ func (s *CommunitySuite) TestEditChat() {
|
|||
s.Require().NotNil(editChanges.ChatsModified[newChatID])
|
||||
s.Require().Equal(editChanges.ChatsModified[newChatID].ChatModified.Identity, editedIdentity)
|
||||
s.Require().Equal(editChanges.ChatsModified[newChatID].ChatModified.Permissions, editedPermissions)
|
||||
s.Require().Equal(editChanges.ChatsModified[newChatID].ChatModified.HideIfPermissionsNotMet, true)
|
||||
}
|
||||
|
||||
func (s *CommunitySuite) TestDeleteChat() {
|
||||
|
|
|
@ -322,6 +322,7 @@ func (s *MessengerCommunitiesSuite) TestJoinCommunity() {
|
|||
Emoji: "😎",
|
||||
Description: "status-core community chat",
|
||||
},
|
||||
HideIfPermissionsNotMet: true,
|
||||
}
|
||||
response, err = s.bob.CreateCommunityChat(community.ID(), orgChat)
|
||||
s.Require().NoError(err)
|
||||
|
@ -338,6 +339,7 @@ func (s *MessengerCommunitiesSuite) TestJoinCommunity() {
|
|||
s.Require().True(createdChat.Active)
|
||||
s.Require().NotEmpty(createdChat.Timestamp)
|
||||
s.Require().True(strings.HasPrefix(createdChat.ID, community.IDString()))
|
||||
s.Require().True(createdChat.HideIfPermissionsNotMet)
|
||||
|
||||
// Make sure the changes are reflect in the community
|
||||
community = response.Communities()[0]
|
||||
|
|
|
@ -2950,11 +2950,13 @@ func (m *Messenger) handleCommunityResponse(state *ReceivedMessageState, communi
|
|||
oldChat.Description != chat.Description ||
|
||||
oldChat.Emoji != chat.Emoji ||
|
||||
oldChat.Color != chat.Color ||
|
||||
oldChat.HideIfPermissionsNotMet != chat.HideIfPermissionsNotMet ||
|
||||
oldChat.UpdateFirstMessageTimestamp(chat.FirstMessageTimestamp) {
|
||||
oldChat.Name = chat.Name
|
||||
oldChat.Description = chat.Description
|
||||
oldChat.Emoji = chat.Emoji
|
||||
oldChat.Color = chat.Color
|
||||
oldChat.HideIfPermissionsNotMet = chat.HideIfPermissionsNotMet
|
||||
// TODO(samyoul) remove storing of an updated reference pointer?
|
||||
state.AllChats.Store(chat.ID, oldChat)
|
||||
state.Response.AddChat(chat)
|
||||
|
|
|
@ -500,7 +500,8 @@ func createCommunityChannelForImport(request *requests.ImportDiscordChannel) *pr
|
|||
Description: request.Description,
|
||||
Color: request.Color,
|
||||
},
|
||||
CategoryId: "",
|
||||
CategoryId: "",
|
||||
HideIfPermissionsNotMet: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1210,7 +1211,8 @@ func (m *Messenger) RequestImportDiscordCommunity(request *requests.ImportDiscor
|
|||
Description: channel.Channel.Description,
|
||||
Color: discordCommunity.Color(),
|
||||
},
|
||||
CategoryId: processedCategoriesIds[channel.Channel.CategoryID],
|
||||
CategoryId: processedCategoriesIds[channel.Channel.CategoryID],
|
||||
HideIfPermissionsNotMet: false,
|
||||
}
|
||||
|
||||
// We call `CreateChat` on `communitiesManager` directly to get more control
|
||||
|
|
|
@ -129,6 +129,7 @@ message CommunityChat {
|
|||
string category_id = 4;
|
||||
int32 position = 5;
|
||||
bool viewers_can_post_reactions = 6;
|
||||
bool hide_if_permissions_not_met = 7;
|
||||
}
|
||||
|
||||
message CommunityCategory {
|
||||
|
|
|
@ -84,6 +84,7 @@ type Chat struct {
|
|||
CanPostReactions bool `json:"canPostReactions"`
|
||||
ViewersCanPostReactions bool `json:"viewersCanPostReactions"`
|
||||
Base64Image string `json:"image,omitempty"`
|
||||
HideIfPermissionsNotMet bool `json:"hideIfPermissionsNotMet,omitempty"`
|
||||
}
|
||||
|
||||
type ChannelGroup struct {
|
||||
|
@ -501,6 +502,7 @@ func (chat *Chat) populateCommunityFields(community *communities.Community) erro
|
|||
}
|
||||
|
||||
chat.CategoryID = commChat.CategoryId
|
||||
chat.HideIfPermissionsNotMet = commChat.HideIfPermissionsNotMet
|
||||
chat.Position = commChat.Position
|
||||
chat.Permissions = commChat.Permissions
|
||||
chat.Emoji = commChat.Identity.Emoji
|
||||
|
|
Loading…
Reference in New Issue