From 0ea43ea59e2e5c7281feacef0328630d02c2eada Mon Sep 17 00:00:00 2001 From: spacedandy-agents-simplex <342056592+spacedandy-agents-simplex@users.noreply.github.com> Date: Tue, 20 Oct 2026 10:29:01 +0000 Subject: [PATCH] fixup! core: send a badge request at once from a build for the dev badge service --- src/Simplex/Chat/Controller.hs | 2 +- src/Simplex/Chat/Library/Commands.hs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs index a9e77f70d0..a782586a4a 100644 --- a/src/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -676,7 +676,7 @@ data ChatCommand -- episode is last because it is free text: it is the value that makes one occurrence of an -- alert distinct from the next, and the app returns whatever it was given | APIAckBadgeAlert {userId :: UserId, badgePurchaseId :: Int64, alertKind :: BadgeAlertKind, snooze :: Bool, episode :: Text} - | APIRequestBadge {userId :: UserId} -- dev builds only: send a badge request now and run the badge pass on its answer + | APIRequestBadge {userId :: UserId} | ShowProfileImage | SetUserFeature AChatFeature FeatureAllowed -- UserId (not used in UI) | SetContactFeature AChatFeature ContactName (Maybe FeatureAllowed) diff --git a/src/Simplex/Chat/Library/Commands.hs b/src/Simplex/Chat/Library/Commands.hs index 47687d159a..b930d5c193 100644 --- a/src/Simplex/Chat/Library/Commands.hs +++ b/src/Simplex/Chat/Library/Commands.hs @@ -3644,9 +3644,7 @@ processChatCommand cxt nm = \case -- after the write, so the pass it signals reads the ack rather than raising the alert again lift $ startBadgeWork user badgeStateResponse user - APIRequestBadge userId -> withUserId userId $ \user -> do - unlessM (asks $ badgeDevRequests . config) $ throwCmdError "/_badge request is only available in builds for a dev badge service" - requestBadgeNow user + APIRequestBadge userId -> withUserId userId requestBadgeNow SetBotCommands commands -> withUserProfileLock "updateProfile" $ withUser $ \user@User {profile} -> do let LocalProfile {preferences} = profile prefs = Just (fromMaybe emptyChatPrefs preferences :: Preferences) {commands = Just commands} @@ -5501,9 +5499,10 @@ badgeNow = asks (badgeCurrentTime . config) >>= liftIO startBadgeWork :: User -> CM' () startBadgeWork user = whenM (isJust <$> asks (badgeServiceAddress . config)) $ void $ getBadgeWorker user --- | Off the shared expiry every client requests at, which is why only dev builds send it. +-- | Sent off the shared request moment, so only a build for a dev badge service may send it. requestBadgeNow :: User -> CM ChatResponse -requestBadgeNow user@User {userId} = +requestBadgeNow user@User {userId} = do + unlessM (asks $ badgeDevRequests . config) $ throwCmdError "/_badge request is only available in builds for a dev badge service" withStore' (`getUserBadgePurchase` user) >>= \case Just p@UserBadgePurchase {shown = True} -> do void $ requestBadgeIssue userId p =<< badgeNow