feat: Add scanCommunitiesMembersForName endpoint (#13789)

Close #13434
This commit is contained in:
Mikhail Rogachev 2024-03-01 22:12:19 +03:00 committed by GitHub
parent 00af1d0e90
commit 0455832f92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 35 additions and 1 deletions

View File

@ -218,6 +218,9 @@ proc getCommunityTags*(self: Controller): string =
proc getAllCommunities*(self: Controller): seq[CommunityDto] =
result = self.communityService.getAllCommunities()
proc isDisplayNameDupeOfCommunityMember*(self: Controller, displayName: string): bool =
result = self.communityService.isDisplayNameDupeOfCommunityMember(displayName)
proc getCommunityById*(self: Controller, communityId: string): CommunityDto =
result = self.communityService.getCommunityById(communityId)

View File

@ -35,6 +35,9 @@ method setCuratedCommunities*(self: AccessInterface, curatedCommunities: seq[Com
method getCommunityItem*(self: AccessInterface, community: CommunityDto): SectionItem {.base.} =
raise newException(ValueError, "No implementation available")
method isDisplayNameDupeOfCommunityMember*(self: AccessInterface, displayName: string): bool {.base.} =
raise newException(ValueError, "No implementation available")
method navigateToCommunity*(self: AccessInterface, communityId: string) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -290,6 +290,9 @@ proc getDiscordChannelItem(self: Module, c: DiscordChannelDto): DiscordChannelIt
c.filePath,
true)
method isDisplayNameDupeOfCommunityMember*(self: Module, displayName: string): bool =
self.controller.isDisplayNameDupeOfCommunityMember(displayName)
method setCommunityTags*(self: Module, communityTags: string) =
self.view.setCommunityTags(communityTags)

View File

@ -482,6 +482,9 @@ QtObject:
proc spectateCommunity*(self: View, communityId: string) {.slot.} =
discard self.delegate.spectateCommunity(communityId)
proc isDisplayNameDupeOfCommunityMember*(self: View, displayName: string): bool {.slot.} =
return self.delegate.isDisplayNameDupeOfCommunityMember(displayName)
proc createCommunity*(self: View, name: string,
description: string, introMessage: string, outroMessage: string,
access: int, color: string, tags: string,

View File

@ -852,6 +852,20 @@ QtObject:
proc getCommunityIds*(self: Service): seq[string] =
return toSeq(self.communities.keys)
proc isDisplayNameDupeOfCommunityMember*(self: Service, displayName: string): bool =
try:
let response = status_go.isDisplayNameDupeOfCommunityMember(displayName)
if response.error != nil:
let error = Json.decode($response.error, RpcError)
raise newException(RpcException, "Error scanning communities for member name: " & error.message)
if response.result.kind != JNull:
return response.result.getBool
except Exception as e:
error "error scanning communities for member name: ", errMsg = e.msg
proc getCommunityTokenBySymbol*(self: Service, communityId: string, symbol: string): CommunityTokenDto =
let community = self.getCommunityById(communityId)
for metadata in community.communityTokensMetadata:

View File

@ -29,6 +29,9 @@ proc getCuratedCommunities*(): RpcResponse[JsonNode] {.raises: [Exception].} =
proc getAllCommunities*(): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("communities".prefix)
proc isDisplayNameDupeOfCommunityMember*(displayName: string): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("isDisplayNameDupeOfCommunityMember".prefix, %* [displayName])
proc spectateCommunity*(communityId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("spectateCommunity".prefix, %*[communityId])

View File

@ -100,6 +100,11 @@ QtObject {
return root.communitiesModuleInst.getCommunityPublicKeyFromPrivateKey(privateKey);
}
// Returns true if the provided displayName occurs in community members
function isDisplayNameDupeOfCommunityMember(displayName) {
root.communitiesModuleInst.isDisplayNameDupeOfCommunityMember(displayName)
}
function requestCommunityInfo(communityKey, shardCluster, shardIndex, importing = false) {
const publicKey = Utils.isCompressedPubKey(communityKey)
? Utils.changeCommunityKeyCompression(communityKey)

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 577db512c6953bec5a82b961cd901c58851362dd
Subproject commit 571f30777ebe32501df0d25f5eb79dbcbbb277c0