Fix scheduled posts only broadcasting to first room

All scheduled post dedup keys (wotd, holidays, gaming, anime, movies,
concerts, birthdays) were global — after posting to the first room,
the job was marked complete and the second room was skipped. Fixed by
including the room ID in each dedup key so posts go to all broadcast
rooms. Birthday XP grants and DMs remain once-per-user-per-year.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
prosolis
2026-03-09 00:09:11 -07:00
parent c1cca5ae12
commit 2c191ec464
7 changed files with 47 additions and 42 deletions

View File

@@ -260,13 +260,10 @@ func (p *BirthdayPlugin) CheckAndPost(roomID id.RoomID) error {
}
for _, m := range matches {
// Check if already fired this year
var fired int
err := d.QueryRow(
`SELECT 1 FROM birthday_fired WHERE user_id = ? AND year = ?`, m.userID, year,
).Scan(&fired)
if err == nil {
continue // Already fired this year
// Check if already announced in THIS room this year
roomKey := fmt.Sprintf("%s:%d:%s", m.userID, year, roomID)
if db.JobCompleted("birthday", roomKey) {
continue
}
// Build announcement
@@ -282,6 +279,17 @@ func (p *BirthdayPlugin) CheckAndPost(roomID id.RoomID) error {
continue
}
db.MarkJobCompleted("birthday", roomKey)
// XP grant and DM only once per user per year (not per room)
var fired int
err := d.QueryRow(
`SELECT 1 FROM birthday_fired WHERE user_id = ? AND year = ?`, m.userID, year,
).Scan(&fired)
if err == nil {
continue // Already granted XP and sent DM
}
// Send DM to the birthday person
dmMsg := fmt.Sprintf("Happy Birthday! The community wishes you a wonderful day!%s You've been granted 100 bonus XP as a birthday gift!", ageStr)
if err := p.SendDM(id.UserID(m.userID), dmMsg); err != nil {
@@ -295,7 +303,7 @@ func (p *BirthdayPlugin) CheckAndPost(roomID id.RoomID) error {
p.grantBirthdayXP(id.UserID(m.userID), 100)
}
// Mark as fired
// Mark as fired (for XP/DM dedup)
_, err = d.Exec(
`INSERT INTO birthday_fired (user_id, year) VALUES (?, ?)
ON CONFLICT(user_id, year) DO NOTHING`,