Skip to main content

Gifts — Technical Reference

← Back to Gifts

Where this lives

Backend

Live gifts are a separate system (live-stream-gift.type.js / live-stream-gift.resolver.js / LiveStreamGift.js, mutation sendLiveGift); don't confuse the two.

Frontend

GraphQL

type GiftCatalogItem { giftType: String! label: String! emoji: String! coinAmount: Int! }

input SendGiftInput {
"One of: post, story, clip, user."
targetType: String!
targetId: ID!
giftType: String!
message: String
}

type SendGiftResponse {
success: Boolean!
message: String # error detail when success is false (e.g. insufficient balance)
giftType: String
emoji: String
coinAmount: Int
newBalance: Int # sender's coin balance after the gift
}

extend type Query {
giftCatalog: [GiftCatalogItem!]!
giftStatsForTarget(targetType: String!, targetId: ID!): GiftTargetStats!
giftsForTarget(targetType: String!, targetId: ID!, limit: Int, offset: Int): [Gift!]!
}
extend type Mutation {
sendGift(input: SendGiftInput!): SendGiftResponse!
}

GiftTargetStats breaks down accumulated gifts on a target as byType: [GiftTargetStatItem!] (per sticker: count, totalCoins) plus totalCoins / totalGifts.

Notes

  • Pricing is the catalog coinAmount; the manager verifies the sender's balance before transferring, so sendGift returns success:false with a message rather than throwing on insufficient funds.
  • sendGift also creates a gift-type notification for the recipient and returns the sender's post-gift balance (newBalance, via coinTransactionManager#getUserBalance); both are best-effort and never fail the gift itself.
  • myGiftablePosts is not part of this system despite the name — it lives in top-fans.type.js / top-fans.resolver.js / top-fans.manager.js and lists a creator's paid posts offered as a rewardTopFan reward (premium_post), used only by RewardFanModal.tsx. See the Top Fans reference.