fix(curated_communities): support curated.communities.update signal

Fixes #12207
This commit is contained in:
Jonathan Rainville 2023-09-19 14:35:15 -04:00
parent e532abb448
commit fe0b0ee795
6 changed files with 31 additions and 1 deletions

View File

@ -8,6 +8,10 @@ import signal_type
type CommunitySignal* = ref object of Signal
community*: CommunityDto
type CuratedCommunitiesSignal* = ref object of Signal
communities*: seq[CommunityDto]
unknownCommunities*: seq[string]
type HistoryArchivesSignal* = ref object of Signal
communityId*: string
begin*: int
@ -40,6 +44,19 @@ proc fromEvent*(T: type CommunitySignal, event: JsonNode): CommunitySignal =
result.signalType = SignalType.CommunityFound
result.community = event["event"].toCommunityDto()
proc fromEvent*(T: type CuratedCommunitiesSignal, event: JsonNode): CuratedCommunitiesSignal =
result = CuratedCommunitiesSignal()
result.signalType = SignalType.CuratedCommunitiesUpdated
result.communities = @[]
if event["event"]["communities"].kind == JObject:
for (communityId, community) in event["event"]["communities"].pairs():
result.communities.add(community.toCommunityDto())
if event["event"]["unknownCommunities"].kind == JObject:
for communityId in event["event"]["unknownCommunities"].items():
result.unknownCommunities.add(communityId.getStr)
proc fromEvent*(T: type DiscordCategoriesAndChannelsExtractedSignal, event: JsonNode): DiscordCategoriesAndChannelsExtractedSignal =
result = DiscordCategoriesAndChannelsExtractedSignal()

View File

@ -20,6 +20,7 @@ type SignalType* {.pure.} = enum
SubscriptionsError = "subscriptions.error"
WhisperFilterAdded = "whisper.filter.added"
CommunityFound = "community.found"
CuratedCommunitiesUpdated = "curated.communities.update"
PeerStats = "wakuv2.peerstats"
Stats = "stats"
ChroniclesLogs = "chronicles-log"

View File

@ -81,6 +81,7 @@ QtObject:
of SignalType.MailserverRequestCompleted: MailserverRequestCompletedSignal.fromEvent(jsonSignal)
of SignalType.MailserverRequestExpired: MailserverRequestExpiredSignal.fromEvent(jsonSignal)
of SignalType.CommunityFound: CommunitySignal.fromEvent(jsonSignal)
of SignalType.CuratedCommunitiesUpdated: CuratedCommunitiesSignal.fromEvent(jsonSignal)
of SignalType.Stats: StatsSignal.fromEvent(jsonSignal)
of SignalType.ChroniclesLogs: ChroniclesLogsSignal.fromEvent(jsonSignal)
of SignalType.HistoryRequestCompleted: HistoryRequestCompletedSignal.fromEvent(jsonSignal)

View File

@ -111,6 +111,11 @@ proc init*(self: Controller) =
self.delegate.communityEdited(community)
self.delegate.curatedCommunityEdited(community)
self.events.on(SIGNAL_CURATED_COMMUNITIES_UPDATED) do(e:Args):
let args = CommunitiesArgs(e)
for community in args.communities:
self.delegate.curatedCommunityEdited(community)
self.events.on(SIGNAL_COMMUNITY_MUTED) do(e:Args):
let args = CommunityMutedArgs(e)
self.delegate.communityMuted(args.communityId, args.muted)

View File

@ -174,6 +174,7 @@ const SIGNAL_COMMUNITY_KICKED* = "communityKicked"
const SIGNAL_NEW_REQUEST_TO_JOIN_COMMUNITY* = "newRequestToJoinCommunity"
const SIGNAL_REQUEST_TO_JOIN_COMMUNITY_CANCELED* = "requestToJoinCommunityCanceled"
const SIGNAL_CURATED_COMMUNITY_FOUND* = "curatedCommunityFound"
const SIGNAL_CURATED_COMMUNITIES_UPDATED* = "curatedCommunitiesUpdated"
const SIGNAL_COMMUNITY_MUTED* = "communityMuted"
const SIGNAL_CATEGORY_MUTED* = "categoryMuted"
const SIGNAL_CATEGORY_UNMUTED* = "categoryUnmuted"
@ -286,6 +287,11 @@ QtObject:
self.communities[receivedData.community.id].isAvailable:
self.events.emit(SIGNAL_CURATED_COMMUNITY_FOUND, CommunityArgs(community: self.communities[receivedData.community.id]))
self.events.on(SignalType.CuratedCommunitiesUpdated.event) do(e: Args):
var receivedData = CuratedCommunitiesSignal(e)
self.events.emit(SIGNAL_CURATED_COMMUNITIES_UPDATED,
CommunitiesArgs(communities: receivedData.communities))
self.events.on(SignalType.Message.event) do(e: Args):
var receivedData = MessageSignal(e)
# Handling community updates

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 57c7054dd2831386cbf1a67caf3ce25ad5d99691
Subproject commit 0f065a9f07aebcb25fdad8ff6a153cc3444ecf0d