mirror of
https://github.com/modrinth/code.git
synced 2026-08-28 10:34:53 +00:00
[DO NOT MERGE] Email notification system (#4338)
* Migration
* Fixup db models
* Redis
* Stuff
* Switch PKs to BIGSERIALs, insert to notifications_deliveries when inserting notifications
* Queue, templates
* Query cache
* Fixes, fixtures
* Perf, cache template data & HTML bodies
* Notification type configuration, ResetPassword notification type
* Reset password
* Query cache
* Clippy + fmt
* Traces, fix typo, fix user email in ResetPassword
* send_email
* Models, db
* Remove dead code, adjust notification settings in migration
* Clippy fmt
* Delete dead code, fixes
* Fmt
* Update apps/labrinth/src/queue/email.rs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: François-Xavier Talbot <108630700+fetchfern@users.noreply.github.com>
* Remove old fixtures
* Unify email retry delay
* Fix type
* External notifications
* Remove `notifications_types_preference_restrictions`, as user notification preferences is out of scope for this PR
* Query cache, fmt, clippy
* Fix join in get_many_user_exposed_on_site
* Remove migration comment
* Query cache
* Update html body urls
* Remove comment
* Add paymentfailed.service variable to PaymentFailed notification variant
* Fix compile error
* Fix deleting notifications
* Update apps/labrinth/src/database/models/user_item.rs
Co-authored-by: Josiah Glosson <soujournme@gmail.com>
Signed-off-by: François-Xavier Talbot <108630700+fetchfern@users.noreply.github.com>
* Update apps/labrinth/src/database/models/user_item.rs
Co-authored-by: Josiah Glosson <soujournme@gmail.com>
Signed-off-by: François-Xavier Talbot <108630700+fetchfern@users.noreply.github.com>
* Update Cargo.toml
Co-authored-by: Josiah Glosson <soujournme@gmail.com>
Signed-off-by: François-Xavier Talbot <108630700+fetchfern@users.noreply.github.com>
* Update apps/labrinth/migrations/20250902133943_notification-extension.sql
Co-authored-by: Josiah Glosson <soujournme@gmail.com>
Signed-off-by: François-Xavier Talbot <108630700+fetchfern@users.noreply.github.com>
* Address review comments
* Fix compliation
* Update apps/labrinth/src/database/models/users_notifications_preferences_item.rs
Co-authored-by: Josiah Glosson <soujournme@gmail.com>
Signed-off-by: François-Xavier Talbot <108630700+fetchfern@users.noreply.github.com>
* Use strfmt to format emails
* Configurable Reply-To
* Configurable Reply-To
* Refactor for email background task
* Send some emails inline
* Fix account creation email check
* Revert "Use strfmt to format emails"
This reverts commit e0d6614afe.
* Reintroduce fill_template
* Set password reset email inline
* Process more emails per index
* clippy fmt
* Query cache
---------
Signed-off-by: François-Xavier Talbot <108630700+fetchfern@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Josiah Glosson <soujournme@gmail.com>
This commit is contained in:
co-authored by
Copilot
Josiah Glosson
parent
1491642209
commit
902d749293
@@ -233,7 +233,7 @@ impl DBUser {
|
||||
exec: E,
|
||||
) -> Result<Option<DBUserId>, sqlx::Error>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let user = sqlx::query!(
|
||||
"
|
||||
@@ -254,7 +254,7 @@ impl DBUser {
|
||||
exec: E,
|
||||
) -> Result<Vec<DBUserId>, sqlx::Error>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let users = sqlx::query!(
|
||||
"
|
||||
@@ -270,13 +270,32 @@ impl DBUser {
|
||||
Ok(users)
|
||||
}
|
||||
|
||||
/// Returns `false` if any of the specified user IDs do not exist.
|
||||
pub async fn exists_many<'a, E>(
|
||||
user_ids: &[DBUserId],
|
||||
exec: E,
|
||||
) -> Result<bool, sqlx::Error>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let ids = user_ids.iter().map(|x| x.0).collect::<Vec<_>>();
|
||||
let count = sqlx::query_scalar!(
|
||||
r#"SELECT COUNT(*) "count!" FROM users WHERE id = ANY($1)"#,
|
||||
&ids
|
||||
)
|
||||
.fetch_one(exec)
|
||||
.await?;
|
||||
|
||||
Ok(count as usize == user_ids.len())
|
||||
}
|
||||
|
||||
pub async fn get_projects<'a, E>(
|
||||
user_id: DBUserId,
|
||||
exec: E,
|
||||
redis: &RedisPool,
|
||||
) -> Result<Vec<DBProjectId>, DatabaseError>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
@@ -324,7 +343,7 @@ impl DBUser {
|
||||
exec: E,
|
||||
) -> Result<Vec<DBOrganizationId>, sqlx::Error>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
@@ -349,7 +368,7 @@ impl DBUser {
|
||||
exec: E,
|
||||
) -> Result<Vec<DBCollectionId>, sqlx::Error>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
@@ -373,7 +392,7 @@ impl DBUser {
|
||||
exec: E,
|
||||
) -> Result<Vec<DBProjectId>, sqlx::Error>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
@@ -397,7 +416,7 @@ impl DBUser {
|
||||
exec: E,
|
||||
) -> Result<Vec<DBReportId>, sqlx::Error>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
@@ -421,7 +440,7 @@ impl DBUser {
|
||||
exec: E,
|
||||
) -> Result<Vec<String>, sqlx::Error>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user