mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-16 08:52:42 +00:00
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:
@@ -203,19 +203,25 @@ func (p *HolidaysPlugin) PostHolidays(roomID id.RoomID) error {
|
||||
today := time.Now().UTC().Format("2006-01-02")
|
||||
d := db.Get()
|
||||
|
||||
// Per-room dedup
|
||||
roomKey := fmt.Sprintf("%s:%s", today, roomID)
|
||||
if db.JobCompleted("holidays", roomKey) {
|
||||
slog.Info("holidays: already posted today", "date", today, "room", roomID)
|
||||
return nil
|
||||
}
|
||||
|
||||
var dataStr string
|
||||
var posted int
|
||||
err := d.QueryRow(
|
||||
`SELECT data, posted FROM holidays_log WHERE date = ?`, today,
|
||||
).Scan(&dataStr, &posted)
|
||||
`SELECT data FROM holidays_log WHERE date = ?`, today,
|
||||
).Scan(&dataStr)
|
||||
if err == sql.ErrNoRows {
|
||||
slog.Warn("holidays: no entry for today, attempting prefetch", "date", today)
|
||||
if err := p.Prefetch(); err != nil {
|
||||
return fmt.Errorf("holidays: prefetch failed: %w", err)
|
||||
}
|
||||
err = d.QueryRow(
|
||||
`SELECT data, posted FROM holidays_log WHERE date = ?`, today,
|
||||
).Scan(&dataStr, &posted)
|
||||
`SELECT data FROM holidays_log WHERE date = ?`, today,
|
||||
).Scan(&dataStr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("holidays: still no entry after prefetch: %w", err)
|
||||
}
|
||||
@@ -223,11 +229,6 @@ func (p *HolidaysPlugin) PostHolidays(roomID id.RoomID) error {
|
||||
return fmt.Errorf("holidays: query: %w", err)
|
||||
}
|
||||
|
||||
if posted == 1 {
|
||||
slog.Info("holidays: already posted today", "date", today)
|
||||
return nil
|
||||
}
|
||||
|
||||
var data holidaysDayData
|
||||
if err := json.Unmarshal([]byte(dataStr), &data); err != nil {
|
||||
return fmt.Errorf("holidays: unmarshal: %w", err)
|
||||
@@ -243,10 +244,7 @@ func (p *HolidaysPlugin) PostHolidays(roomID id.RoomID) error {
|
||||
return fmt.Errorf("holidays: send: %w", err)
|
||||
}
|
||||
|
||||
_, err = d.Exec(`UPDATE holidays_log SET posted = 1 WHERE date = ?`, today)
|
||||
if err != nil {
|
||||
slog.Error("holidays: mark posted", "err", err)
|
||||
}
|
||||
db.MarkJobCompleted("holidays", roomKey)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user