removed all "paid" features - no more stars, gifts, or grams

This commit is contained in:
onysd 2026-08-07 01:50:10 +03:00
parent d4451d753c
commit 21d8e91756
165 changed files with 318 additions and 40948 deletions

View file

@ -199,70 +199,6 @@ ORDER BY channel_id ASC, message_id ASC, reaction_date DESC, reacted_user_id DES
recentRows.Close()
}
// 3) 付费 reaction(Stars):跨频道一次取所有 reactor 行,Go 内按 (channel,message) 聚合
// 总星数 + viewer 自身 + top reactors,挂到 message.Reactions.Paid(tg 转换注入 ReactionPaid)。
// 绝大多数消息无付费 reaction(索引扫描即返回空);总星数须含全部 reactor 故取全行。
if err := populateChannelMessagesPaidReactions(ctx, db, viewerUserID, channelsByID, indexes, messages, pairChannels, pairMessages); err != nil {
return err
}
return nil
}
func populateChannelMessagesPaidReactions(ctx context.Context, db sqlcgen.DBTX, viewerUserID int64, channelsByID map[int64]domain.Channel, indexes map[channelReactionMessageKey][]int, messages []domain.ChannelMessage, pairChannels []int64, pairMessages []int32) error {
rows, err := db.Query(ctx, `
SELECT channel_id, message_id, reactor_user_id, stars, anonymous
FROM channel_message_paid_reactions
WHERE (channel_id, message_id) IN (SELECT * FROM unnest($1::bigint[], $2::int[]))
ORDER BY channel_id ASC, message_id ASC, stars DESC, reactor_user_id ASC`, pairChannels, pairMessages)
if err != nil {
return fmt.Errorf("load channel message paid reactions: %w", err)
}
defer rows.Close()
aggByKey := make(map[channelReactionMessageKey]*domain.ChannelMessagePaidReactions)
for rows.Next() {
var channelID int64
var msgID int
var r domain.PaidReactor
if err := rows.Scan(&channelID, &msgID, &r.UserID, &r.Stars, &r.Anonymous); err != nil {
return err
}
key := channelReactionMessageKey{channelID: channelID, messageID: msgID}
agg := aggByKey[key]
if agg == nil {
agg = &domain.ChannelMessagePaidReactions{}
aggByKey[key] = agg
}
agg.TotalStars += r.Stars
r.My = r.UserID == viewerUserID
if r.My {
agg.MyStars = r.Stars
agg.MyAnonymous = r.Anonymous
}
// top reactors 取前 N(已按 stars DESC);viewer 自身若不在前 N 也补一条(始终在列)。
if len(agg.TopReactors) < domain.MaxPaidReactionTopReactors {
agg.TopReactors = append(agg.TopReactors, r)
} else if r.My {
agg.TopReactors = append(agg.TopReactors, r)
}
}
if err := rows.Err(); err != nil {
return err
}
for key, agg := range aggByKey {
if agg.TotalStars <= 0 {
continue
}
ch := channelsByID[key.channelID]
for _, idx := range indexes[key] {
if messages[idx].Reactions == nil {
reactions := emptyChannelMessageReactions(ch)
messages[idx].Reactions = &reactions
}
paidCopy := *agg
paidCopy.TopReactors = append([]domain.PaidReactor(nil), agg.TopReactors...)
messages[idx].Reactions.Paid = &paidCopy
}
}
return nil
}