Remove importCommunity from QML and Nim code (#14814)

* Remove importCommunity from QML and Nim code

Handling issue 14310. Removed functions associated with the API.

* Updated pr for suggested changes.

* Updated module.nim

---------

Co-authored-by: Eliza <elsorber@gmail.com>
This commit is contained in:
Jonathan Rainville 2024-05-16 17:30:32 -04:00 committed by GitHub
parent cd7de2a2e5
commit bbd1adcabb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 0 additions and 117 deletions

View File

@ -330,9 +330,6 @@ proc getChatDetailsByIds*(self: Controller, chatIds: seq[string]): seq[ChatDto]
proc requestCommunityInfo*(self: Controller, communityId: string, shard: Shard, importing: bool) =
self.communityService.requestCommunityInfo(communityId, shard, importing)
proc importCommunity*(self: Controller, communityKey: string) =
self.communityService.asyncImportCommunity(communityKey)
proc setCommunityMuted*(self: Controller, communityId: string, mutedType: int) =
self.communityService.setCommunityMuted(communityId, mutedType)

View File

@ -80,9 +80,6 @@ method requestCommunityInfo*(self: AccessInterface, communityId: string, shardCl
method requestCommunityInfo*(self: AccessInterface, communityId: string, shard: Shard, importing: bool) {.base.} =
raise newException(ValueError, "No implementation available")
method importCommunity*(self: AccessInterface, communityKey: string) {.base.} =
raise newException(ValueError, "No implementation available")
method myRequestAdded*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -420,10 +420,6 @@ method userCanJoin*(self: Module, communityId: string): bool =
method isMyCommunityRequestPending*(self: Module, communityId: string): bool =
self.controller.isMyCommunityRequestPending(communityId)
method communityImported*(self: Module, community: CommunityDto) =
self.view.addOrUpdateItem(self.getCommunityItem(community))
self.view.emitImportingCommunityStateChangedSignal(community.id, ImportCommunityState.Imported.int, errorMsg = "")
method communityDataImported*(self: Module, community: CommunityDto) =
self.view.addItem(self.getCommunityItem(community))
self.buildTokensAndCollectiblesFromCommunities(@[community])
@ -432,16 +428,9 @@ method communityDataImported*(self: Module, community: CommunityDto) =
method communityInfoRequestFailed*(self: Module, communityId: string, errorMsg: string) =
self.view.emitCommunityInfoRequestCompleted(communityId, errorMsg)
method importCommunity*(self: Module, communityId: string) =
self.view.emitImportingCommunityStateChangedSignal(communityId, ImportCommunityState.ImportingInProgress.int, errorMsg = "")
self.controller.importCommunity(communityId)
method onImportCommunityErrorOccured*(self: Module, communityId: string, error: string) =
self.view.emitImportingCommunityStateChangedSignal(communityId, ImportCommunityState.ImportingError.int, error)
method onImportCommunityCancelled*(self: Module, communityId: string) =
self.view.emitImportingCommunityStateChangedSignal(communityId, ImportCommunityState.ImportingCanceled.int, errorMsg = "")
method requestExtractDiscordChannelsAndCategories*(self: Module, filesToImport: seq[string]) =
self.view.setDiscordDataExtractionInProgress(true)
self.controller.requestExtractDiscordChannelsAndCategories(filesToImport)

View File

@ -603,9 +603,6 @@ QtObject:
proc isMyCommunityRequestPending*(self: View, communityId: string): bool {.slot.} =
self.delegate.isMyCommunityRequestPending(communityId)
proc importCommunity*(self: View, communityKey: string) {.slot.} =
self.delegate.importCommunity(communityKey)
proc importingCommunityStateChanged*(self:View, communityId: string, state: int, errorMsg: string) {.signal.}
proc emitImportingCommunityStateChangedSignal*(self: View, communityId: string, state: int, errorMsg: string) =
self.importingCommunityStateChanged(communityId, state, errorMsg)

View File

@ -225,23 +225,6 @@ const asyncCheckPermissionsToJoinTask: Task = proc(argEncoded: string) {.gcsafe,
"error": e.msg,
})
type
AsyncImportCommunityTaskArg = ref object of QObjectTaskArg
communityKey: string
const asyncImportCommunityTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let arg = decode[AsyncImportCommunityTaskArg](argEncoded)
try:
let response = status_go.importCommunity(arg.communityKey)
arg.finish(%* {
"response": response,
"error": "",
})
except Exception as e:
arg.finish(%* {
"error": e.msg,
})
type
AsyncGetRevealedAccountsArg = ref object of QObjectTaskArg
communityId: string

View File

@ -1900,71 +1900,6 @@ QtObject:
)
self.threadpool.start(arg)
proc asyncImportCommunity*(self: Service, communityKey: string) =
let arg = AsyncImportCommunityTaskArg(
tptr: cast[ByteAddress](asyncImportCommunityTask),
vptr: cast[ByteAddress](self.vptr),
slot: "onAsyncImportCommunityCompleted",
communityKey: communityKey,
)
self.threadpool.start(arg)
proc onAsyncImportCommunityCompleted*(self: Service, response: string) {.slot.} =
try:
let rpcResponseObj = response.parseJson
if rpcResponseObj{"error"}.kind != JNull and rpcResponseObj{"error"}.getStr != "":
raise newException(RpcException, rpcResponseObj["error"].getStr)
## after `importCommunity` call everything should be handled in a slot cnnected to `SignalType.CommunityFound.event`
## but because of insufficient data (chats details are missing) sent as a payload of that signal we're unable to do
## that until `status-go` part gets improved in ragards of that.
if rpcResponseObj["response"]{"error"}.kind != JNull:
let error = Json.decode(rpcResponseObj["response"]["error"].getStr, RpcError)
raise newException(RpcException, error.message)
if rpcResponseObj["response"]{"result"} == nil or rpcResponseObj["response"]{"result"}.kind != JObject:
raise newException(RpcException, "response is empty or not an json object")
var communityJArr: JsonNode
if not rpcResponseObj["response"]{"result"}.getProp("communities", communityJArr):
raise newException(RpcException, "there is no `communities` key in the response")
if communityJArr.len == 0:
raise newException(RpcException, "`communities` array is empty in the response")
var communitiesSettingsJArr: JsonNode
if not rpcResponseObj["response"]{"result"}.getProp("communitiesSettings", communitiesSettingsJArr):
raise newException(RpcException, "there is no `communitiesSettings` key in the response")
if communitiesSettingsJArr.len == 0:
raise newException(RpcException, "`communitiesSettings` array is empty in the response")
var communityDto = communityJArr[0].toCommunityDto()
let communitySettingsDto = communitiesSettingsJArr[0].toCommunitySettingsDto()
communityDto.settings = communitySettingsDto
self.communities[communityDto.id] = communityDto
var chatsJArr: JsonNode
if rpcResponseObj["response"]{"result"}.getProp("chats", chatsJArr):
for chatObj in chatsJArr:
let chatDto = chatObj.toChatDto(communityDto.id)
self.chatService.updateOrAddChat(chatDto) # we have to update chats stored in the chat service.
for chat in communityDto.chats:
let fullChatId = communityDto.id & chat.id
var chatDetails = self.chatService.getChatById(fullChatId)
chatDetails.updateMissingFields(chat)
self.chatService.updateOrAddChat(chatDetails) # we have to update chats stored in the chat service.
self.events.emit(SIGNAL_COMMUNITY_IMPORTED, CommunityArgs(community: communityDto))
except Exception as e:
error "Error importing the community: ", msg = e.msg
# We should apply some notification mechanism on the application level which will deal with errors and
# notify user about them. Till then we're using this way.
self.events.emit(SIGNAL_COMMUNITY_IMPORTED, CommunityArgs(error: "Error while importing the community"))
proc exportCommunity*(self: Service, communityId: string): string =
try:
let response = status_go.exportCommunity(communityId)

View File

@ -457,9 +457,6 @@ proc requestCommunityInfo*(communityId: string, tryDatabase: bool, shardCluster:
"waitForResponse": true
}])
proc importCommunity*(communityKey: string): RpcResponse[JsonNode] =
result = callPrivateRPC("importCommunity".prefix, %*[communityKey])
proc exportCommunity*(communityId: string): RpcResponse[JsonNode] =
result = callPrivateRPC("exportCommunity".prefix, %*[communityId])

View File

@ -304,10 +304,6 @@ QtObject {
args.bannerJsonStr, args.options.encrypted);
}
function importCommunity(communityKey) {
root.communitiesModuleInst.importCommunity(communityKey);
}
function createCommunityCategory(categoryName, channels) {
chatCommunitySectionModule.createCommunityCategory(categoryName, channels)
}

View File

@ -95,10 +95,6 @@ QtObject {
args.bannerJsonStr, args.options.encrypted);
}
function importCommunity(communityKey) {
root.communitiesModuleInst.importCommunity(communityKey);
}
function getCommunityPublicKeyFromPrivateKey(privateKey) {
return root.communitiesModuleInst.getCommunityPublicKeyFromPrivateKey(privateKey);
}

View File

@ -205,10 +205,6 @@ QtObject {
}
}
function importCommunity(communityKey) {
root.communitiesModuleInst.importCommunity(communityKey);
}
function getCurrentVersion() {
return aboutModuleInst.getCurrentVersion()
}