feat(@desktop/communities): Automaticaly encrypt closed communitites

This commit is contained in:
mprakhov 2023-05-04 15:28:34 +02:00 committed by Mykhailo Prakhov
parent a674ec57a8
commit 60bd0d2a6c
12 changed files with 24 additions and 68 deletions

View File

@ -138,8 +138,7 @@ proc createCommunity*(
aX: int, aY: int, bX: int, bY: int, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool, pinMessageAllMembersEnabled: bool,
bannerJsonStr: string, bannerJsonStr: string) =
encrypted: bool) =
self.communityService.createCommunity( self.communityService.createCommunity(
name, name,
description, description,
@ -152,8 +151,7 @@ proc createCommunity*(
aX, aY, bX, bY, aX, aY, bX, bY,
historyArchiveSupportEnabled, historyArchiveSupportEnabled,
pinMessageAllMembersEnabled, pinMessageAllMembersEnabled,
bannerJsonStr, bannerJsonStr)
encrypted)
proc requestImportDiscordCommunity*( proc requestImportDiscordCommunity*(
self: Controller, self: Controller,
@ -169,8 +167,7 @@ proc requestImportDiscordCommunity*(
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool, pinMessageAllMembersEnabled: bool,
filesToImport: seq[string], filesToImport: seq[string],
fromTimestamp: int, fromTimestamp: int) =
encrypted: bool) =
self.communityService.requestImportDiscordCommunity( self.communityService.requestImportDiscordCommunity(
name, name,
description, description,
@ -184,8 +181,7 @@ proc requestImportDiscordCommunity*(
historyArchiveSupportEnabled, historyArchiveSupportEnabled,
pinMessageAllMembersEnabled, pinMessageAllMembersEnabled,
filesToImport, filesToImport,
fromTimestamp, fromTimestamp)
encrypted)
proc reorderCommunityChat*( proc reorderCommunityChat*(
self: Controller, self: Controller,

View File

@ -40,14 +40,13 @@ method spectateCommunity*(self: AccessInterface, communityId: string): string {.
method createCommunity*(self: AccessInterface, name: string, description, introMessage, outroMessage: string, access: int, method createCommunity*(self: AccessInterface, name: string, description, introMessage, outroMessage: string, access: int,
color: string, tags: string, imagePath: string, aX: int, aY: int, bX: int, bY: int, color: string, tags: string, imagePath: string, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool, bannerJsonStr: string, historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool, bannerJsonStr: string) {.base.} =
encrypted: bool) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method requestImportDiscordCommunity*(self: AccessInterface, name: string, description, introMessage, outroMessage: string, access: int, method requestImportDiscordCommunity*(self: AccessInterface, name: string, description, introMessage, outroMessage: string, access: int,
color: string, tags: string, imagePath: string, aX: int, aY: int, bX: int, bY: int, color: string, tags: string, imagePath: string, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool, filesToImport: seq[string], historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool, filesToImport: seq[string],
fromTimestamp: int, encrypted: bool) {.base.} = fromTimestamp: int) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method deleteCommunityCategory*(self: AccessInterface, communityId: string, categoryId: string) {.base.} = method deleteCommunityCategory*(self: AccessInterface, communityId: string, categoryId: string) {.base.} =

View File

@ -252,11 +252,10 @@ method createCommunity*(self: Module, name: string,
aX: int, aY: int, bX: int, bY: int, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool, pinMessageAllMembersEnabled: bool,
bannerJsonStr: string, bannerJsonStr: string) =
encrypted: bool) =
self.controller.createCommunity(name, description, introMessage, outroMessage, access, color, tags, self.controller.createCommunity(name, description, introMessage, outroMessage, access, color, tags,
imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled,
bannerJsonStr, encrypted) bannerJsonStr)
method deleteCommunityCategory*(self: Module, communityId: string, categoryId: string) = method deleteCommunityCategory*(self: Module, communityId: string, categoryId: string) =
self.controller.deleteCommunityCategory(communityId, categoryId) self.controller.deleteCommunityCategory(communityId, categoryId)
@ -339,9 +338,9 @@ method requestExtractDiscordChannelsAndCategories*(self: Module, filesToImport:
method requestImportDiscordCommunity*(self: Module, name: string, description, introMessage, outroMessage: string, access: int, method requestImportDiscordCommunity*(self: Module, name: string, description, introMessage, outroMessage: string, access: int,
color: string, tags: string, imagePath: string, aX: int, aY: int, bX: int, bY: int, color: string, tags: string, imagePath: string, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool, filesToImport: seq[string], historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool, filesToImport: seq[string],
fromTimestamp: int, encrypted: bool) = fromTimestamp: int) =
self.view.setDiscordImportHasCommunityImage(imagePath != "") self.view.setDiscordImportHasCommunityImage(imagePath != "")
self.controller.requestImportDiscordCommunity(name, description, introMessage, outroMessage, access, color, tags, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled, filesToImport, fromTimestamp, encrypted) self.controller.requestImportDiscordCommunity(name, description, introMessage, outroMessage, access, color, tags, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled, filesToImport, fromTimestamp)
proc getDiscordImportTaskItem(self: Module, t: DiscordImportTaskProgress): DiscordImportTaskItem = proc getDiscordImportTaskItem(self: Module, t: DiscordImportTaskProgress): DiscordImportTaskItem =
return initDiscordImportTaskItem( return initDiscordImportTaskItem(

View File

@ -421,11 +421,10 @@ QtObject:
imagePath: string, imagePath: string,
aX: int, aY: int, bX: int, bY: int, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool, bannerJsonStr: string, pinMessageAllMembersEnabled: bool, bannerJsonStr: string) {.slot.} =
encrypted: bool) {.slot.} =
self.delegate.createCommunity(name, description, introMessage, outroMessage, access, color, tags, self.delegate.createCommunity(name, description, introMessage, outroMessage, access, color, tags,
imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled,
bannerJsonStr, encrypted) bannerJsonStr)
proc clearFileList*(self: View) {.slot.} = proc clearFileList*(self: View) {.slot.} =
self.discordFileListModel.clearItems() self.discordFileListModel.clearItems()
@ -459,7 +458,7 @@ QtObject:
aX: int, aY: int, bX: int, bY: int, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool, pinMessageAllMembersEnabled: bool,
fromTimestamp: int, encrypted: bool) {.slot.} = fromTimestamp: int) {.slot.} =
let selectedItems = self.discordChannelsModel.getSelectedItems() let selectedItems = self.discordChannelsModel.getSelectedItems()
var filesToImport: seq[string] = @[] var filesToImport: seq[string] = @[]
@ -470,7 +469,7 @@ QtObject:
self.setDiscordImportInProgress(true) self.setDiscordImportInProgress(true)
self.delegate.requestImportDiscordCommunity(name, description, introMessage, outroMessage, access, color, tags, self.delegate.requestImportDiscordCommunity(name, description, introMessage, outroMessage, access, color, tags,
imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled,
filesToImport, fromTimestamp, encrypted) filesToImport, fromTimestamp)
proc deleteCommunityCategory*(self: View, communityId: string, categoryId: string): string {.slot.} = proc deleteCommunityCategory*(self: View, communityId: string, categoryId: string): string {.slot.} =
self.delegate.deleteCommunityCategory(communityId, categoryId) self.delegate.deleteCommunityCategory(communityId, categoryId)

View File

@ -911,8 +911,7 @@ QtObject:
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool, pinMessageAllMembersEnabled: bool,
filesToImport: seq[string], filesToImport: seq[string],
fromTimestamp: int, fromTimestamp: int) =
encrypted: bool) =
try: try:
var image = singletonInstance.utils.formatImagePath(imageUrl) var image = singletonInstance.utils.formatImagePath(imageUrl)
var tagsString = tags var tagsString = tags
@ -932,8 +931,7 @@ QtObject:
historyArchiveSupportEnabled, historyArchiveSupportEnabled,
pinMessageAllMembersEnabled, pinMessageAllMembersEnabled,
filesToImport, filesToImport,
fromTimestamp, fromTimestamp)
encrypted)
if response.error != nil: if response.error != nil:
let error = Json.decode($response.error, RpcError) let error = Json.decode($response.error, RpcError)
@ -955,8 +953,7 @@ QtObject:
aX: int, aY: int, bX: int, bY: int, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool, pinMessageAllMembersEnabled: bool,
bannerJsonStr: string, bannerJsonStr: string) =
encrypted: bool) =
try: try:
var bannerJson = bannerJsonStr.parseJson var bannerJson = bannerJsonStr.parseJson
bannerJson{"imagePath"} = newJString(singletonInstance.utils.formatImagePath(bannerJson["imagePath"].getStr)) bannerJson{"imagePath"} = newJString(singletonInstance.utils.formatImagePath(bannerJson["imagePath"].getStr))
@ -976,8 +973,7 @@ QtObject:
aX, aY, bX, bY, aX, aY, bX, bY,
historyArchiveSupportEnabled, historyArchiveSupportEnabled,
pinMessageAllMembersEnabled, pinMessageAllMembersEnabled,
$bannerJson, $bannerJson)
encrypted)
if response.error != nil: if response.error != nil:
let error = Json.decode($response.error, RpcError) let error = Json.decode($response.error, RpcError)

View File

@ -70,8 +70,7 @@ proc createCommunity*(
aX: int, aY: int, bX: int, bY: int, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool, pinMessageAllMembersEnabled: bool,
bannerJsonStr: string, bannerJsonStr: string
encrypted: bool
): RpcResponse[JsonNode] {.raises: [Exception].} = ): RpcResponse[JsonNode] {.raises: [Exception].} =
let bannerImage = newCroppedImage(bannerJsonStr) let bannerImage = newCroppedImage(bannerJsonStr)
result = callPrivateRPC("createCommunity".prefix, %*[{ result = callPrivateRPC("createCommunity".prefix, %*[{
@ -91,8 +90,7 @@ proc createCommunity*(
"imageBy": bY, "imageBy": bY,
"historyArchiveSupportEnabled": historyArchiveSupportEnabled, "historyArchiveSupportEnabled": historyArchiveSupportEnabled,
"pinMessageAllMembersEnabled": pinMessageAllMembersEnabled, "pinMessageAllMembersEnabled": pinMessageAllMembersEnabled,
"banner": bannerImage, "banner": bannerImage
"encrypted": encrypted
}]) }])
proc editCommunity*( proc editCommunity*(
@ -131,7 +129,7 @@ proc editCommunity*(
"imageBy": bY, "imageBy": bY,
"banner": bannerImage, "banner": bannerImage,
"historyArchiveSupportEnabled": historyArchiveSupportEnabled, "historyArchiveSupportEnabled": historyArchiveSupportEnabled,
"pinMessageAllMembersEnabled": pinMessageAllMembersEnabled "pinMessageAllMembersEnabled": pinMessageAllMembersEnabled,
}]) }])
proc requestImportDiscordCommunity*( proc requestImportDiscordCommunity*(
@ -148,7 +146,6 @@ proc requestImportDiscordCommunity*(
pinMessageAllMembersEnabled: bool, pinMessageAllMembersEnabled: bool,
filesToImport: seq[string], filesToImport: seq[string],
fromTimestamp: int, fromTimestamp: int,
encrypted: bool,
): RpcResponse[JsonNode] {.raises: [Exception].} = ): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("requestImportDiscordCommunity".prefix, %*[{ result = callPrivateRPC("requestImportDiscordCommunity".prefix, %*[{
# TODO this will need to be renamed membership (small m) # TODO this will need to be renamed membership (small m)
@ -168,8 +165,7 @@ proc requestImportDiscordCommunity*(
"historyArchiveSupportEnabled": historyArchiveSupportEnabled, "historyArchiveSupportEnabled": historyArchiveSupportEnabled,
"pinMessageAllMembersEnabled": pinMessageAllMembersEnabled, "pinMessageAllMembersEnabled": pinMessageAllMembersEnabled,
"from": fromTimestamp, "from": fromTimestamp,
"filesToImport": filesToImport, "filesToImport": filesToImport
"encrypted": encrypted,
}]) }])
proc createCommunityTokenPermission*(communityId: string, permissionType: int, tokenCriteria: string, isPrivate: bool): RpcResponse[JsonNode] {.raises: [Exception].} = proc createCommunityTokenPermission*(communityId: string, permissionType: int, tokenCriteria: string, isPrivate: bool): RpcResponse[JsonNode] {.raises: [Exception].} =

View File

@ -12,9 +12,6 @@ Column {
property alias archiveSupportEnabled: archiveSupportToggle.checked property alias archiveSupportEnabled: archiveSupportToggle.checked
property alias requestToJoinEnabled: requestToJoinToggle.checked property alias requestToJoinEnabled: requestToJoinToggle.checked
property alias pinMessagesEnabled: pinMessagesToggle.checked property alias pinMessagesEnabled: pinMessagesToggle.checked
property alias encrypted: encryptedToggle.checked
property bool encryptReadOnly: false
spacing: 0 spacing: 0
@ -76,24 +73,4 @@ Column {
id: pinMessagesToggle id: pinMessagesToggle
} }
} }
RowLayout {
width: visible ? parent.width : 0
height: visible ? d.optionHeight : 0
visible: requestToJoinToggle.checked
StatusBaseText {
Layout.fillWidth: true
text: qsTr("Encrypted")
TapHandler {
enabled: !encryptReadOnly
onTapped: encryptedToggle.toggle()
}
}
StatusCheckBox {
id: encryptedToggle
enabled: !encryptReadOnly
}
}
} }

View File

@ -29,7 +29,6 @@ StackLayout {
property bool archiveSupportEnabled property bool archiveSupportEnabled
property bool requestToJoinEnabled property bool requestToJoinEnabled
property bool pinMessagesEnabled property bool pinMessagesEnabled
property bool encrypted
property string previousPageName: (currentIndex === 1) ? qsTr("Overview") : "" property string previousPageName: (currentIndex === 1) ? qsTr("Overview") : ""
property bool editable: false property bool editable: false
@ -188,8 +187,6 @@ StackLayout {
archiveSupportEnabled: root.archiveSupportEnabled archiveSupportEnabled: root.archiveSupportEnabled
requestToJoinEnabled: root.requestToJoinEnabled requestToJoinEnabled: root.requestToJoinEnabled
pinMessagesEnabled: root.pinMessagesEnabled pinMessagesEnabled: root.pinMessagesEnabled
encrypted: root.encrypted
encryptReadOnly: true
} }
bottomReservedSpace: editCommunityPage.settingsDirtyToastMessageImplicitSize bottomReservedSpace: editCommunityPage.settingsDirtyToastMessageImplicitSize

View File

@ -174,7 +174,6 @@ StatusSectionLayout {
tags: root.rootStore.communityTags tags: root.rootStore.communityTags
selectedTags: root.filteredSelectedTags selectedTags: root.filteredSelectedTags
archiveSupportEnabled: root.community.historyArchiveSupportEnabled archiveSupportEnabled: root.community.historyArchiveSupportEnabled
encrypted: root.community.encrypted
requestToJoinEnabled: root.community.access === Constants.communityChatOnRequestAccess requestToJoinEnabled: root.community.access === Constants.communityChatOnRequestAccess
pinMessagesEnabled: root.community.pinMessageAllMembersEnabled pinMessagesEnabled: root.community.pinMessageAllMembersEnabled
editable: root.community.amISectionAdmin editable: root.community.amISectionAdmin

View File

@ -509,7 +509,6 @@ StatusStackModal {
historyArchiveSupportEnabled: options.archiveSupportEnabled, historyArchiveSupportEnabled: options.archiveSupportEnabled,
checkedMembership: options.requestToJoinEnabled ? Constants.communityChatOnRequestAccess : Constants.communityChatPublicAccess, checkedMembership: options.requestToJoinEnabled ? Constants.communityChatOnRequestAccess : Constants.communityChatPublicAccess,
pinMessagesAllowedForMembers: options.pinMessagesEnabled, pinMessagesAllowedForMembers: options.pinMessagesEnabled,
encrypted: options.requestToJoinEnabled && options.encrypted // Only communities with memberships can be encrypted
}, },
bannerJsonStr: JSON.stringify({imagePath: String(bannerPicker.source).replace("file://", ""), cropRect: bannerPicker.cropRect}) bannerJsonStr: JSON.stringify({imagePath: String(bannerPicker.source).replace("file://", ""), cropRect: bannerPicker.cropRect})
} }

View File

@ -161,14 +161,13 @@ QtObject {
historyArchiveSupportEnabled: false, historyArchiveSupportEnabled: false,
checkedMembership: false, checkedMembership: false,
pinMessagesAllowedForMembers: false, pinMessagesAllowedForMembers: false,
encrypted: false
} }
}, from = 0) { }, from = 0) {
return communitiesModuleInst.requestImportDiscordCommunity( return communitiesModuleInst.requestImportDiscordCommunity(
args.name, args.description, args.introMessage, args.outroMessage, args.options.checkedMembership, args.name, args.description, args.introMessage, args.outroMessage, args.options.checkedMembership,
args.color, args.tags, args.color, args.tags,
args.image.src, args.image.AX, args.image.AY, args.image.BX, args.image.BY, args.image.src, args.image.AX, args.image.AY, args.image.BX, args.image.BY,
args.options.historyArchiveSupportEnabled, args.options.pinMessagesAllowedForMembers, from, args.options.encrypted); args.options.historyArchiveSupportEnabled, args.options.pinMessagesAllowedForMembers, from);
} }

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit e7fbc191f4916f5801704ed9b6a06c738019a73e Subproject commit 57b2432290347f15e0e452e6a38d76acef601bc5