diff --git a/go/cmd/emailnotifierjob/main.go b/go/cmd/emailnotifierjob/main.go index 325cdc3..2a227c8 100644 --- a/go/cmd/emailnotifierjob/main.go +++ b/go/cmd/emailnotifierjob/main.go @@ -26,7 +26,7 @@ const ( // Minimum time a message must be unread before we consider notifying unreadThreshold = 10 * time.Minute // Minimum time between emails to the same user - emailCooldown = 1 * time.Hour + emailCooldown = 12 * time.Hour ) func main() { @@ -107,17 +107,15 @@ func runNotificationCycle( behindCounts := map[string]int{} latestActivity := map[string]time.Time{} - // Get all currently connected humans (empty channel_ids = all connections) + // Get all currently connected humans allOnline := map[string]bool{} - presenceResp, err := pusherSvc.BulkGetPresence(ctx, &pbpusher.BulkGetPresenceRequest{}) + onlineResp, err := pusherSvc.GetOnlineHumanIds(ctx, &pbpusher.GetOnlineHumanIdsRequest{}) if err != nil { - slog.Error("failed to get connected humans", "error", err) - // Continue without presence data — worst case we send an email to someone who's online - } else if ch, ok := presenceResp.Presences["_all"]; ok { - slog.Info("gathered bulk presence", "# of humans present", fmt.Sprintf("%d", len(ch.HumanIds))) - for _, id := range ch.HumanIds { - allOnline[id] = true - } + return fmt.Errorf("failed to get online humans: %w", err) + } + slog.Info("gathered online presence", "onlineCount", len(onlineResp.HumanIds), "humanIds", onlineResp.HumanIds) + for _, id := range onlineResp.HumanIds { + allOnline[id] = true } for _, net := range networks { @@ -288,7 +286,7 @@ func buildEmailHTML(name string, count int, streamsWord string) string {
You have unread messages in %d %s on Flowy.llink.
Open the app to catch up with your team.
- Best,
Flowy Team
+ Best,
Flowy Team
Note: disable email notifications from in-app settings.