feat: Add api to remove a community private key (nim part) (#11640)
Close #11475
This commit is contained in:
parent
45c5a8d3c5
commit
0e5594b02e
|
@ -74,6 +74,11 @@ proc init*(self: Controller) =
|
|||
let args = CommunityArgs(e)
|
||||
self.delegate.communityAdded(args.community)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_PRIVATE_KEY_REMOVED) do(e:Args):
|
||||
let args = CommunityArgs(e)
|
||||
self.delegate.communityEdited(args.community)
|
||||
self.delegate.communityPrivateKeyRemoved(args.community.id)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_IMPORTED) do(e:Args):
|
||||
let args = CommunityArgs(e)
|
||||
if(args.error.len > 0):
|
||||
|
@ -234,6 +239,9 @@ proc getChatDetailsByIds*(self: Controller, chatIds: seq[string]): seq[ChatDto]
|
|||
proc requestCommunityInfo*(self: Controller, communityId: string, importing: bool) =
|
||||
self.communityService.requestCommunityInfo(communityId, importing)
|
||||
|
||||
proc removePrivateKey*(self: Controller, communityId: string) =
|
||||
self.communityService.removePrivateKey(communityId)
|
||||
|
||||
proc importCommunity*(self: Controller, communityKey: string) =
|
||||
self.communityService.importCommunity(communityKey)
|
||||
|
||||
|
|
|
@ -64,6 +64,9 @@ method cancelRequestToJoinCommunity*(self: AccessInterface, communityId: string)
|
|||
method requestCommunityInfo*(self: AccessInterface, communityId: string, importing: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method removePrivateKey*(self: AccessInterface, communityId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method importCommunity*(self: AccessInterface, communityKey: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
@ -88,6 +91,9 @@ method communityCategoryEdited*(self: AccessInterface) {.base.} =
|
|||
method communityCategoryDeleted*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method communityPrivateKeyRemoved*(self: AccessInterface, communityId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method communityEdited*(self: AccessInterface, community: CommunityDto) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -238,6 +238,9 @@ method navigateToCommunity*(self: Module, communityId: string) =
|
|||
else:
|
||||
self.delegate.setActiveSectionById(communityId)
|
||||
|
||||
method communityPrivateKeyRemoved*(self: Module, communityId: string) =
|
||||
self.view.communityPrivateKeyRemoved(communityId)
|
||||
|
||||
method communityEdited*(self: Module, community: CommunityDto) =
|
||||
self.view.model().editItem(self.getCommunityItem(community))
|
||||
self.view.communityChanged(community.id)
|
||||
|
@ -333,6 +336,9 @@ method communityImported*(self: Module, community: CommunityDto) =
|
|||
method communityDataImported*(self: Module, community: CommunityDto) =
|
||||
self.view.addItem(self.getCommunityItem(community))
|
||||
|
||||
method removePrivateKey*(self: Module, communityId: string) =
|
||||
self.controller.removePrivateKey(communityId)
|
||||
|
||||
method importCommunity*(self: Module, communityId: string) =
|
||||
self.view.emitImportingCommunityStateChangedSignal(communityId, ImportCommunityState.ImportingInProgress.int, errorMsg = "")
|
||||
self.controller.importCommunity(communityId)
|
||||
|
|
|
@ -106,6 +106,7 @@ QtObject:
|
|||
|
||||
proc communityAdded*(self: View, communityId: string) {.signal.}
|
||||
proc communityChanged*(self: View, communityId: string) {.signal.}
|
||||
proc communityPrivateKeyRemoved*(self: View, communityId: string) {.signal.}
|
||||
proc discordOldestMessageTimestampChanged*(self: View) {.signal.}
|
||||
proc discordImportErrorsCountChanged*(self: View) {.signal.}
|
||||
proc communityAccessRequested*(self: View, communityId: string) {.signal.}
|
||||
|
@ -495,6 +496,9 @@ QtObject:
|
|||
proc isCommunityRequestPending*(self: View, communityId: string): bool {.slot.} =
|
||||
self.delegate.isCommunityRequestPending(communityId)
|
||||
|
||||
proc removePrivateKey*(self: View, communityId: string) {.slot.} =
|
||||
self.delegate.removePrivateKey(communityId)
|
||||
|
||||
proc importCommunity*(self: View, communityKey: string) {.slot.} =
|
||||
self.delegate.importCommunity(communityKey)
|
||||
|
||||
|
|
|
@ -254,6 +254,10 @@ proc init*(self: Controller) =
|
|||
let args = CommunityArgs(e)
|
||||
self.delegate.communityEdited(args.community)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_PRIVATE_KEY_REMOVED) do(e:Args):
|
||||
let args = CommunityArgs(e)
|
||||
self.delegate.communityEdited(args.community)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITIES_UPDATE) do(e:Args):
|
||||
let args = CommunitiesArgs(e)
|
||||
for community in args.communities:
|
||||
|
|
|
@ -60,6 +60,10 @@ proc init*(self: Controller) =
|
|||
let args = CommunityArgs(e)
|
||||
self.delegate.editCommunity(args.community)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_PRIVATE_KEY_REMOVED) do(e:Args):
|
||||
let args = CommunityArgs(e)
|
||||
self.delegate.editCommunity(args.community)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITIES_UPDATE) do(e:Args):
|
||||
let args = CommunitiesArgs(e)
|
||||
for community in args.communities:
|
||||
|
|
|
@ -187,6 +187,8 @@ const TOKEN_PERMISSIONS_MODIFIED = "tokenPermissionsModified"
|
|||
|
||||
const SIGNAL_CHECK_PERMISSIONS_TO_JOIN_RESPONSE* = "checkPermissionsToJoinResponse"
|
||||
|
||||
const SIGNAL_COMMUNITY_PRIVATE_KEY_REMOVED* = "communityPrivateKeyRemoved"
|
||||
|
||||
QtObject:
|
||||
type
|
||||
Service* = ref object of QObject
|
||||
|
@ -1567,6 +1569,20 @@ QtObject:
|
|||
)
|
||||
self.threadpool.start(arg)
|
||||
|
||||
proc removePrivateKey*(self: Service, communityId: string) =
|
||||
try:
|
||||
let response = status_go.removePrivateKey(communityId)
|
||||
if (response.error != nil):
|
||||
let error = Json.decode($response.error, RpcError)
|
||||
raise newException(RpcException, fmt"err: {error.message}")
|
||||
|
||||
var community = self.communities[communityId]
|
||||
community.isControlNode = false
|
||||
self.communities[communityId] = community
|
||||
self.events.emit(SIGNAL_COMMUNITY_PRIVATE_KEY_REMOVED, CommunityArgs(community: community))
|
||||
except Exception as e:
|
||||
error "Error removing community private key: ", msg = e.msg
|
||||
|
||||
proc importCommunity*(self: Service, communityKey: string) =
|
||||
try:
|
||||
let response = status_go.importCommunity(communityKey)
|
||||
|
|
|
@ -355,6 +355,9 @@ proc deleteCommunityCategory*(
|
|||
proc requestCommunityInfo*(communityId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
result = callPrivateRPC("requestCommunityInfoFromMailserver".prefix, %*[communityId])
|
||||
|
||||
proc removePrivateKey*(communityId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
result = callPrivateRPC("removePrivateKey".prefix, %*[communityId])
|
||||
|
||||
proc importCommunity*(communityKey: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
result = callPrivateRPC("importCommunity".prefix, %*[communityKey])
|
||||
|
||||
|
|
Loading…
Reference in New Issue