mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-03 16:58:53 +00:00
core: drop CRBadgePurchaseDelivered
This commit is contained in:
@@ -135,7 +135,6 @@ undocumentedResponses =
|
||||
"CRArchiveExported",
|
||||
"CRArchiveImported",
|
||||
"CRBadgeLedger",
|
||||
"CRBadgePurchaseDelivered",
|
||||
"CRBadgeRedeemed",
|
||||
"CRBadgeState",
|
||||
"CRBroadcastSent",
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 </)
|
||||
rowCount (chatController alice) "badge_store_receipts" `shouldReturn` 1
|
||||
rowCount cc "sx_badge_service_badge_purchases" `shouldReturn` 1
|
||||
@@ -1737,9 +1739,8 @@ testPurchaseDeliveredToHiddenProfile ps =
|
||||
alice <## "messages are hidden (use /tail to view)"
|
||||
alice <## "profile is hidden"
|
||||
settlePending store
|
||||
-- the answer names only the presenting profile, and nothing printed names the hidden one
|
||||
-- the answer is the hidden owner's, so the view prints none of it
|
||||
alice ##> unsettled 2
|
||||
alice <## "badge purchase delivered to another profile"
|
||||
(alice </)
|
||||
alice ##> "/user alice password"
|
||||
showActiveUser alice "alice (Alice, * supporter)"
|
||||
|
||||
Reference in New Issue
Block a user