Saltar al contenido principal

Regalos — Referencia técnica

← Volver a Regalos

Dónde vive esto

Backend

Los regalos en vivo son un sistema separado (live-stream-gift.type.js / live-stream-gift.resolver.js / LiveStreamGift.js, mutation sendLiveGift); no confundas los dos.

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 desglosa los regalos acumulados en un destino como byType: [GiftTargetStatItem!] (por sticker: count, totalCoins) más totalCoins / totalGifts.

Notas

  • El precio es el coinAmount del catálogo; el manager verifica el saldo del remitente antes de transferir, de modo que sendGift devuelve success:false con un message en lugar de lanzar un error cuando los fondos son insuficientes.
  • sendGift también crea una notificación de tipo gift para el destinatario y devuelve el saldo del remitente después del regalo (newBalance, vía coinTransactionManager#getUserBalance); ambas cosas son best-effort y nunca hacen fallar el regalo en sí.
  • myGiftablePosts no forma parte de este sistema pese al nombre — vive en top-fans.type.js / top-fans.resolver.js / top-fans.manager.js y lista las publicaciones de pago de un creador ofrecidas como recompensa rewardTopFan (premium_post), usada solo por RewardFanModal.tsx. Consulta la referencia de Top Fans.