mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-05 19:17:32 +00:00
fixup! core: send a badge request at once from a build for the dev badge service
This commit is contained in:
1 parent
c0619385e9
commit
0ea43ea59e
2 files changed
+5
-6
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user