diff --git a/bots/src/API/Docs/Responses.hs b/bots/src/API/Docs/Responses.hs index e2700ec100..18392ae1b5 100644 --- a/bots/src/API/Docs/Responses.hs +++ b/bots/src/API/Docs/Responses.hs @@ -135,7 +135,6 @@ undocumentedResponses = "CRArchiveExported", "CRArchiveImported", "CRBadgeLedger", - "CRBadgePurchaseDelivered", "CRBadgeRedeemed", "CRBadgeState", "CRBroadcastSent", diff --git a/src/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs index f524cd7ace..a90431f7de 100644 --- a/src/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -871,7 +871,6 @@ data ChatResponse | CRServiceResponse {user :: User, responseData :: J.Object} | CRServiceReplyAccepted {user :: User, connectionId :: AgentConnId} | CRBadgeRedeemed {user :: User, redeemedBadge :: LocalBadge, newBadge :: Bool, badgeState :: Maybe BadgeState} - | CRBadgePurchaseDelivered {user :: User} -- credited, but to another profile, which is not disclosed: it may be hidden | CRBadgeState {user :: User, badgeState :: Maybe BadgeState} | CRBadgeLedger {user :: User, badgeLedger :: [StatementEntry]} | CRUserAcceptedGroupSent {user :: User, groupInfo :: GroupInfo, hostContact :: Maybe Contact} diff --git a/src/Simplex/Chat/Library/Commands.hs b/src/Simplex/Chat/Library/Commands.hs index 309b7ff60e..4bc1dc4e5e 100644 --- a/src/Simplex/Chat/Library/Commands.hs +++ b/src/Simplex/Chat/Library/Commands.hs @@ -5257,10 +5257,8 @@ purchaseBadge nm presentingUser payment = do requestStashedBadge nm user sendTarget stash BSCPurchaseBadge {masterKey, payment, upgrade = Nothing} terminalReceiptError -- outside the badge lock: the chat lock must not be taken under it mapM_ presentUserBadgeToContacts present_ - -- the owner may be hidden, so the answer is the same whether it is or not, and names only the presenter - pure $ if userId == presentingUserId then purchased else CRBadgePurchaseDelivered presentingUser + pure purchased where - User {userId = presentingUserId} = presentingUser -- the receipt will never be credited to this key; any other refusal may pass on a retry terminalReceiptError = \case BSEReceiptInvalid -> True diff --git a/src/Simplex/Chat/View.hs b/src/Simplex/Chat/View.hs index eb292d4b92..84aeef023c 100644 --- a/src/Simplex/Chat/View.hs +++ b/src/Simplex/Chat/View.hs @@ -193,7 +193,6 @@ chatResponseToView hu cfg@ChatConfig {logLevel, showReactions, showFullLinks, te CRServiceReplyAccepted u (AgentConnId cId) -> ttyUser u [plain $ "service reply accepted, connection id: " <> safeDecodeUtf8 (strEncode cId)] -- the badge is only shown when it is the one now on the profile; a replayed code's badge may not be CRBadgeRedeemed u badge newBadge _ -> ttyUser u $ if newBadge then "badge redeemed" : viewContactBadge (Just badge) else ["badge already redeemed"] - CRBadgePurchaseDelivered u -> ttyUser u ["badge purchase delivered to another profile"] CRBadgeState u st -> ttyUser u $ viewUserBadgeState st CRBadgeLedger u entries -> ttyUser u $ viewBadgeLedger entries CRGroupCreated u g -> ttyUser u $ viewGroupCreated g testView diff --git a/tests/Bots/BadgeService/BotTests.hs b/tests/Bots/BadgeService/BotTests.hs index a812f5f1c2..1e8ec7ef03 100644 --- a/tests/Bots/BadgeService/BotTests.hs +++ b/tests/Bots/BadgeService/BotTests.hs @@ -1699,7 +1699,7 @@ testPurchaseSameReceiptOtherProfile ps = showActiveUser alice "alisa" -- the store transaction is the device's, so it stays with the profile it was bought under alice ##> ("/_badge purchase 2 " <> paymentArg supporterPlay) - alice <## "badge purchase delivered to another profile" + alice <## "[user: alice] badge already redeemed" rowCount cc "sx_badge_service_badge_purchases" `shouldReturn` 1 alice ##> "/p" showActiveUser alice "alisa" @@ -1716,7 +1716,9 @@ testPurchaseStrandedUnderOtherProfile ps = settlePending store -- presented again under whichever profile is active, the purchase reaches the keys alice stashed alice ##> unsettled 2 - alice <## "badge purchase delivered to another profile" + alice <## "[user: alice] badge redeemed" + alice <## "supporter badge - active" + alice <##. "expires " (alice unsettled 2 - alice <## "badge purchase delivered to another profile" (alice "/user alice password" showActiveUser alice "alice (Alice, * supporter)"