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,
historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool,
bannerJsonStr: string,
encrypted: bool) =
bannerJsonStr: string) =
self.communityService.createCommunity(
name,
description,
@ -152,8 +151,7 @@ proc createCommunity*(
aX, aY, bX, bY,
historyArchiveSupportEnabled,
pinMessageAllMembersEnabled,
bannerJsonStr,
encrypted)
bannerJsonStr)
proc requestImportDiscordCommunity*(
self: Controller,
@ -169,8 +167,7 @@ proc requestImportDiscordCommunity*(
historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool,
filesToImport: seq[string],
fromTimestamp: int,
encrypted: bool) =
fromTimestamp: int) =
self.communityService.requestImportDiscordCommunity(
name,
description,
@ -184,8 +181,7 @@ proc requestImportDiscordCommunity*(
historyArchiveSupportEnabled,
pinMessageAllMembersEnabled,
filesToImport,
fromTimestamp,
encrypted)
fromTimestamp)
proc reorderCommunityChat*(
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,
color: string, tags: string, imagePath: string, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool, bannerJsonStr: string,
encrypted: bool) {.base.} =
historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool, bannerJsonStr: string) {.base.} =
raise newException(ValueError, "No implementation available")
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,
historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool, filesToImport: seq[string],
fromTimestamp: int, encrypted: bool) {.base.} =
fromTimestamp: int) {.base.} =
raise newException(ValueError, "No implementation available")
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,
historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool,
bannerJsonStr: string,
encrypted: bool) =
bannerJsonStr: string) =
self.controller.createCommunity(name, description, introMessage, outroMessage, access, color, tags,
imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled,
bannerJsonStr, encrypted)
bannerJsonStr)
method deleteCommunityCategory*(self: Module, communityId: string, categoryId: string) =
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,
color: string, tags: string, imagePath: string, aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool, filesToImport: seq[string],
fromTimestamp: int, encrypted: bool) =
fromTimestamp: int) =
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 =
return initDiscordImportTaskItem(

View File

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

View File

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

View File

@ -70,8 +70,7 @@ proc createCommunity*(
aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool,
bannerJsonStr: string,
encrypted: bool
bannerJsonStr: string
): RpcResponse[JsonNode] {.raises: [Exception].} =
let bannerImage = newCroppedImage(bannerJsonStr)
result = callPrivateRPC("createCommunity".prefix, %*[{
@ -91,8 +90,7 @@ proc createCommunity*(
"imageBy": bY,
"historyArchiveSupportEnabled": historyArchiveSupportEnabled,
"pinMessageAllMembersEnabled": pinMessageAllMembersEnabled,
"banner": bannerImage,
"encrypted": encrypted
"banner": bannerImage
}])
proc editCommunity*(
@ -131,7 +129,7 @@ proc editCommunity*(
"imageBy": bY,
"banner": bannerImage,
"historyArchiveSupportEnabled": historyArchiveSupportEnabled,
"pinMessageAllMembersEnabled": pinMessageAllMembersEnabled
"pinMessageAllMembersEnabled": pinMessageAllMembersEnabled,
}])
proc requestImportDiscordCommunity*(
@ -148,7 +146,6 @@ proc requestImportDiscordCommunity*(
pinMessageAllMembersEnabled: bool,
filesToImport: seq[string],
fromTimestamp: int,
encrypted: bool,
): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("requestImportDiscordCommunity".prefix, %*[{
# TODO this will need to be renamed membership (small m)
@ -168,8 +165,7 @@ proc requestImportDiscordCommunity*(
"historyArchiveSupportEnabled": historyArchiveSupportEnabled,
"pinMessageAllMembersEnabled": pinMessageAllMembersEnabled,
"from": fromTimestamp,
"filesToImport": filesToImport,
"encrypted": encrypted,
"filesToImport": filesToImport
}])
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 requestToJoinEnabled: requestToJoinToggle.checked
property alias pinMessagesEnabled: pinMessagesToggle.checked
property alias encrypted: encryptedToggle.checked
property bool encryptReadOnly: false
spacing: 0
@ -76,24 +73,4 @@ Column {
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 requestToJoinEnabled
property bool pinMessagesEnabled
property bool encrypted
property string previousPageName: (currentIndex === 1) ? qsTr("Overview") : ""
property bool editable: false
@ -188,8 +187,6 @@ StackLayout {
archiveSupportEnabled: root.archiveSupportEnabled
requestToJoinEnabled: root.requestToJoinEnabled
pinMessagesEnabled: root.pinMessagesEnabled
encrypted: root.encrypted
encryptReadOnly: true
}
bottomReservedSpace: editCommunityPage.settingsDirtyToastMessageImplicitSize

View File

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

View File

@ -509,7 +509,6 @@ StatusStackModal {
historyArchiveSupportEnabled: options.archiveSupportEnabled,
checkedMembership: options.requestToJoinEnabled ? Constants.communityChatOnRequestAccess : Constants.communityChatPublicAccess,
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})
}

View File

@ -161,14 +161,13 @@ QtObject {
historyArchiveSupportEnabled: false,
checkedMembership: false,
pinMessagesAllowedForMembers: false,
encrypted: false
}
}, from = 0) {
return communitiesModuleInst.requestImportDiscordCommunity(
args.name, args.description, args.introMessage, args.outroMessage, args.options.checkedMembership,
args.color, args.tags,
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