core: badge service rpc dispatcher

This commit is contained in:
shum
2026-08-27 10:28:26 +00:00
parent 412e5dfb48
commit a16695326c
5 changed files with 617 additions and 34 deletions
+16
View File
@@ -12,6 +12,8 @@ module Simplex.Chat.Badges.Service
BadgeServiceVersion,
VersionBadgeService,
pattern VersionBadgeService,
minSupportedBadgeVersion,
currentBadgeVersion,
BadgeUpgrade (..),
BadgeServiceResponse (..),
BadgeServiceErrorCode (..),
@@ -52,6 +54,20 @@ type VersionBadgeService = Version BadgeServiceVersion
pattern VersionBadgeService :: Word16 -> VersionBadgeService
pattern VersionBadgeService v = Version v
-- | The oldest client version the service still answers (badges-rpc.md:9): a request below
-- this gets 'BSEUnsupportedVersion'. Below 'currentBadgeVersion' only because a version bump
-- is expected to stay backwards compatible for a while, not because the service itself has
-- ever spoken more than one version yet.
minSupportedBadgeVersion :: VersionBadgeService
minSupportedBadgeVersion = VersionBadgeService 1
-- | The newest version this service deployment speaks. A response answers within
-- @min(request.version, currentBadgeVersion)@; at version 1 there is no version-conditional
-- field, so this constant has no runtime effect yet -- it exists so a later version bump has
-- something to gate on from day one.
currentBadgeVersion :: VersionBadgeService
currentBadgeVersion = VersionBadgeService 1
data BadgeServiceRequest = BadgeServiceRequest
{ version :: VersionBadgeService,
purchaseKey :: Maybe C.PublicKeyEd25519, -- optional for BSCGetBadgeCatalog, required for other commands