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