parent
22df203653
commit
0ba7f1d609
|
@ -90,12 +90,12 @@ proc setIsCurrentSectionActive*(self: Controller, active: bool) =
|
||||||
self.isCurrentSectionActive = active
|
self.isCurrentSectionActive = active
|
||||||
|
|
||||||
proc requestToJoinCommunityAuthenticated*(self: Controller, password: string) =
|
proc requestToJoinCommunityAuthenticated*(self: Controller, password: string) =
|
||||||
self.communityService.requestToJoinCommunity(self.tmpRequestToJoinCommunityId, self.tmpRequestToJoinEnsName, password)
|
self.communityService.asyncRequestToJoinCommunity(self.tmpRequestToJoinCommunityId, self.tmpRequestToJoinEnsName, password)
|
||||||
self.tmpRequestToJoinCommunityId = ""
|
self.tmpRequestToJoinCommunityId = ""
|
||||||
self.tmpRequestToJoinEnsName = ""
|
self.tmpRequestToJoinEnsName = ""
|
||||||
|
|
||||||
proc requestToJoinCommunity*(self: Controller, communityId: string, ensName: string) =
|
proc requestToJoinCommunity*(self: Controller, communityId: string, ensName: string) =
|
||||||
self.communityService.requestToJoinCommunity(communityId, ensName, "")
|
self.communityService.asyncRequestToJoinCommunity(communityId, ensName, "")
|
||||||
|
|
||||||
proc authenticate*(self: Controller, keyUid = "") =
|
proc authenticate*(self: Controller, keyUid = "") =
|
||||||
let data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_MAIN_MODULE_AUTH_IDENTIFIER,
|
let data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_MAIN_MODULE_AUTH_IDENTIFIER,
|
||||||
|
|
|
@ -123,7 +123,7 @@ proc cancelRequestToJoinCommunity*(self: Controller, communityId: string) =
|
||||||
self.communityService.cancelRequestToJoinCommunity(communityId)
|
self.communityService.cancelRequestToJoinCommunity(communityId)
|
||||||
|
|
||||||
proc requestToJoinCommunity*(self: Controller, communityId: string, ensName: string) =
|
proc requestToJoinCommunity*(self: Controller, communityId: string, ensName: string) =
|
||||||
self.communityService.requestToJoinCommunity(communityId, ensName, password="")
|
self.communityService.asyncRequestToJoinCommunity(communityId, ensName, password="")
|
||||||
|
|
||||||
proc createCommunity*(
|
proc createCommunity*(
|
||||||
self: Controller,
|
self: Controller,
|
||||||
|
|
|
@ -79,3 +79,26 @@ const asyncAcceptRequestToJoinCommunityTask: Task = proc(argEncoded: string) {.g
|
||||||
"communityId": arg.communityId,
|
"communityId": arg.communityId,
|
||||||
"requestId": arg.requestId
|
"requestId": arg.requestId
|
||||||
})
|
})
|
||||||
|
|
||||||
|
type
|
||||||
|
AsyncRequestToJoinCommunityTaskArg = ref object of QObjectTaskArg
|
||||||
|
communityId: string
|
||||||
|
ensName: string
|
||||||
|
password: string
|
||||||
|
|
||||||
|
const asyncRequestToJoinCommunityTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||||
|
let arg = decode[AsyncRequestToJoinCommunityTaskArg](argEncoded)
|
||||||
|
try:
|
||||||
|
let response = status_go.requestToJoinCommunity(arg.communityId, arg.ensName, arg.password)
|
||||||
|
arg.finish(%* {
|
||||||
|
"response": response,
|
||||||
|
"communityId": arg.communityId,
|
||||||
|
"error": "",
|
||||||
|
})
|
||||||
|
except Exception as e:
|
||||||
|
arg.finish(%* {
|
||||||
|
"error": e.msg,
|
||||||
|
"communityId": arg.communityId,
|
||||||
|
"ensName": arg.ensName,
|
||||||
|
"password": arg.password
|
||||||
|
})
|
|
@ -825,17 +825,6 @@ QtObject:
|
||||||
error "Error joining the community", msg = e.msg
|
error "Error joining the community", msg = e.msg
|
||||||
result = fmt"Error joining the community: {e.msg}"
|
result = fmt"Error joining the community: {e.msg}"
|
||||||
|
|
||||||
proc requestToJoinCommunity*(self: Service, communityId: string, ensName: string, password: string) =
|
|
||||||
try:
|
|
||||||
let response = status_go.requestToJoinCommunity(communityId, ensName, password)
|
|
||||||
self.activityCenterService.parseActivityCenterResponse(response)
|
|
||||||
|
|
||||||
if not self.processRequestsToJoinCommunity(response.result):
|
|
||||||
error "error: ", procName="requestToJoinCommunity", errDesription = "no 'requestsToJoinCommunity' key in response"
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
error "Error requesting to join the community", msg = e.msg, communityId, ensName
|
|
||||||
|
|
||||||
proc canceledRequestsToJoinForCommunity*(self: Service, communityId: string): seq[CommunityMembershipRequestDto] =
|
proc canceledRequestsToJoinForCommunity*(self: Service, communityId: string): seq[CommunityMembershipRequestDto] =
|
||||||
try:
|
try:
|
||||||
let response = status_go.canceledRequestsToJoinForCommunity(communityId)
|
let response = status_go.canceledRequestsToJoinForCommunity(communityId)
|
||||||
|
@ -1351,6 +1340,38 @@ QtObject:
|
||||||
|
|
||||||
self.events.emit(SIGNAL_COMMUNITY_DATA_IMPORTED, CommunityArgs(community: community))
|
self.events.emit(SIGNAL_COMMUNITY_DATA_IMPORTED, CommunityArgs(community: community))
|
||||||
|
|
||||||
|
proc asyncRequestToJoinCommunity*(self: Service, communityId: string, ensName: string, password: string) =
|
||||||
|
try:
|
||||||
|
let arg = AsyncRequestToJoinCommunityTaskArg(
|
||||||
|
tptr: cast[ByteAddress](asyncRequestToJoinCommunityTask),
|
||||||
|
vptr: cast[ByteAddress](self.vptr),
|
||||||
|
slot: "onAsyncRequestToJoinCommunityDone",
|
||||||
|
communityId: communityId,
|
||||||
|
ensName: ensName,
|
||||||
|
password: password
|
||||||
|
)
|
||||||
|
self.threadpool.start(arg)
|
||||||
|
except Exception as e:
|
||||||
|
error "Error request to join community", msg = e.msg
|
||||||
|
|
||||||
|
proc onAsyncRequestToJoinCommunityDone*(self: Service, communityIdAndRpcResponse: string) {.slot.} =
|
||||||
|
try:
|
||||||
|
let rpcResponseObj = communityIdAndRpcResponse.parseJson
|
||||||
|
if (rpcResponseObj{"response"}{"error"}.kind != JNull):
|
||||||
|
let error = Json.decode($rpcResponseObj["response"]["error"], RpcError)
|
||||||
|
error "Error requesting community info", msg = error.message
|
||||||
|
return
|
||||||
|
|
||||||
|
let communityId = rpcResponseObj{"communityId"}.getStr()
|
||||||
|
let rpcResponse = Json.decode($rpcResponseObj["response"], RpcResponse[JsonNode])
|
||||||
|
self.activityCenterService.parseActivityCenterResponse(rpcResponse)
|
||||||
|
|
||||||
|
if not self.processRequestsToJoinCommunity(rpcResponse.result):
|
||||||
|
error "error: ", procName="onAsyncRequestToJoinCommunityDone", errDesription = "no 'requestsToJoinCommunity' key in response"
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
error "Error requesting to join the community", msg = e.msg
|
||||||
|
|
||||||
proc asyncAcceptRequestToJoinCommunity*(self: Service, communityId: string, requestId: string) =
|
proc asyncAcceptRequestToJoinCommunity*(self: Service, communityId: string, requestId: string) =
|
||||||
try:
|
try:
|
||||||
let userKey = self.getUserPubKeyFromPendingRequest(communityId, requestId)
|
let userKey = self.getUserPubKeyFromPendingRequest(communityId, requestId)
|
||||||
|
|
|
@ -95,6 +95,7 @@ Item {
|
||||||
function onCommunityAccessRequested(communityId: string) {
|
function onCommunityAccessRequested(communityId: string) {
|
||||||
if (communityId === communityData.id) {
|
if (communityId === communityData.id) {
|
||||||
joinCommunityButton.invitationPending = root.store.isCommunityRequestPending(communityData.id)
|
joinCommunityButton.invitationPending = root.store.isCommunityRequestPending(communityData.id)
|
||||||
|
joinCommunityButton.loading = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +109,10 @@ Item {
|
||||||
imageSrc: communityData.image
|
imageSrc: communityData.image
|
||||||
accessType: communityData.access
|
accessType: communityData.access
|
||||||
|
|
||||||
onJoined: root.store.requestToJoinCommunity(communityData.id, root.store.userProfileInst.name)
|
onJoined: {
|
||||||
|
joinCommunityButton.loading = true
|
||||||
|
root.store.requestToJoinCommunity(communityData.id, root.store.userProfileInst.name)
|
||||||
|
}
|
||||||
onCancelMembershipRequest: {
|
onCancelMembershipRequest: {
|
||||||
root.store.cancelPendingRequest(communityData.id)
|
root.store.cancelPendingRequest(communityData.id)
|
||||||
joinCommunityButton.invitationPending = root.store.isCommunityRequestPending(communityData.id)
|
joinCommunityButton.invitationPending = root.store.isCommunityRequestPending(communityData.id)
|
||||||
|
|
Loading…
Reference in New Issue