chore: receive all non-approved requests to join through the API allNonApprovedCommunitiesRequestsToJoin (#12941)

This commit is contained in:
Mykhailo Prakhov 2023-12-05 16:37:58 +01:00 committed by GitHub
parent 02589421bb
commit 24f2540ffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 17 deletions

View File

@ -10,11 +10,13 @@ const asyncLoadCommunitiesDataTask: Task = proc(argEncoded: string) {.gcsafe, ni
let responseTags = status_go.getCommunityTags()
let responseCommunities = status_go.getAllCommunities()
let responseSettings = status_go.getCommunitiesSettings()
let responseNonApprovedRequestsToJoin = status_go.allNonApprovedCommunitiesRequestsToJoin()
arg.finish(%* {
"tags": responseTags,
"communities": responseCommunities,
"settings": responseSettings,
"nonAprrovedRequestsToJoin": responseNonApprovedRequestsToJoin,
"error": "",
})
except Exception as e:

View File

@ -467,22 +467,6 @@ proc toCommunityDto*(jsonObj: JsonNode): CommunityDto =
result.shard = jsonObj.getShard()
var requestsToJoinCommunityObj: JsonNode
if(jsonObj.getProp("requestsToJoinCommunity", requestsToJoinCommunityObj) and requestsToJoinCommunityObj.kind == JArray):
for requestObj in requestsToJoinCommunityObj:
let request = requestObj.toCommunityMembershipRequestDto()
case RequestToJoinType(request.state):
of RequestToJoinType.Pending, RequestToJoinType.AcceptedPending, RequestToJoinType.DeclinedPending:
result.pendingRequestsToJoin.add(request)
of RequestToJoinType.Declined:
result.declinedRequestsToJoin.add(request)
of RequestToJoinType.Canceled:
result.canceledRequestsToJoin.add(request)
of RequestToJoinType.AwaitingAddress:
result.waitingForSharedAddressesRequestsToJoin.add(request)
of RequestToJoinType.Accepted:
continue
proc toMembershipRequestState*(state: CommunityMemberPendingBanOrKick): MembershipRequestState =
case state:
of CommunityMemberPendingBanOrKick.Banned:

View File

@ -775,6 +775,27 @@ QtObject:
if self.communities.hasKey(settings.id):
self.communities[settings.id].settings = settings
# Non approver requests to join for all communities
let nonAprrovedRequestsToJoinObj = responseObj["nonAprrovedRequestsToJoin"]
if nonAprrovedRequestsToJoinObj{"result"}.kind != JNull:
for jsonCommunityReqest in nonAprrovedRequestsToJoinObj["result"]:
let communityRequest = jsonCommunityReqest.toCommunityMembershipRequestDto()
if not (communityRequest.communityId in self.communities):
warn "community was not found for community request", communityID=communityRequest.communityId, requestId=communityRequest.id
continue
case RequestToJoinType(communityRequest.state):
of RequestToJoinType.Pending, RequestToJoinType.AcceptedPending, RequestToJoinType.DeclinedPending:
self.communities[communityRequest.communityId].pendingRequestsToJoin.add(communityRequest)
of RequestToJoinType.Declined:
self.communities[communityRequest.communityId].declinedRequestsToJoin.add(communityRequest)
of RequestToJoinType.Canceled:
self.communities[communityRequest.communityId].canceledRequestsToJoin.add(communityRequest)
of RequestToJoinType.AwaitingAddress:
self.communities[communityRequest.communityId].waitingForSharedAddressesRequestsToJoin.add(communityRequest)
of RequestToJoinType.Accepted:
continue
self.events.emit(SIGNAL_COMMUNITY_DATA_LOADED, Args())
except Exception as e:
let errDesription = e.msg

View File

@ -118,6 +118,9 @@ proc checkAllCommunityChannelsPermissions*(communityId: string, addresses: seq[s
"addresses": addresses,
}])
proc allNonApprovedCommunitiesRequestsToJoin*(): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("allNonApprovedCommunitiesRequestsToJoin".prefix)
proc cancelRequestToJoinCommunity*(requestId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("cancelRequestToJoinCommunity".prefix, %*[{
"id": requestId

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 058120fad95056627badd8854b6655d70258db4c
Subproject commit 04c533b8d5f1e0249b9edd38ef1304b9e9ef81de