feat: add configurable repository digest alerts - #47
Conversation
Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7272d1de6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| weeklyDigestLastSentAt: user.weeklyDigestLastSentAt, | ||
| }) | ||
| .from(user) | ||
| .where(eq(user.weeklyDigestEnabled, true)); |
There was a problem hiding this comment.
Process enabled repository alerts independently
If a user keeps an enabled repository-alert template but turns off the separate weekly digest preference, PATCH /api/digest-preference sets this flag to false without disabling the template. This query then excludes the user before getRepositoryAlertSchedule runs, so their daily, weekly, or fortnightly repository alerts silently stop. Include users with enabled repository templates in the cron recipient set rather than filtering exclusively on the weekly preference.
Useful? React with 👍 / 👎.
| if (input.enabled) { | ||
| await database | ||
| .update(user) | ||
| .set({ weeklyDigestEnabled: true }) | ||
| .where(eq(user.id, session.user.id)); |
There was a problem hiding this comment.
Preserve the weekly-digest opt-in when saving alerts
Saving any enabled repository template—including the default template with no repositories—silently changes the separate weekly digest preference to true. On Monday the cron consequently includes saved-search recommendations, so a user who disabled or never enabled that digest can receive an unrelated weekly email; disabling repository alerts later also leaves this preference enabled. Repository-alert enrollment should not overwrite the saved-search digest opt-in.
Useful? React with 👍 / 👎.
| const url = new URL("https://api.github.com/search/issues"); | ||
| url.searchParams.set( | ||
| "q", | ||
| `repo:${repositoryFullName} is:issue`, |
There was a problem hiding this comment.
Restrict repository digest searches to open issues
When a repository's newest issues include closed tickets, this query returns them because it has no state qualifier; closed tickets can also occupy the five-result limit and hide older open issues. The resulting email therefore presents closed work as current opportunities despite the digest's open-issue messaging. Add is:open to the repository issue query.
Useful? React with 👍 / 👎.
Summary
Implements configurable email digests for saved searches and repository alerts.
Closes #18
Closes #14
Changes
Database migrations
0003_weekly_digest.sql0004_repository_digest.sql0005_repository_digest_frequency.sqlThe migrations add:
Configuration
Required production environment variables:
CRON_SECRETSMTP_USERSMTP_APP_PASSWORDDIGEST_FROM_EMAILThe Vercel cron runs daily at
09:00 UTC. Saved-search digests remain restricted to Mondays, while repository alerts follow the user-selected frequency.Verification