1
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-06-19 09:50:09 +00:00

Fix mobile push blocking requests and spamming push server

This commit is contained in:
Bernd Schoolmann 2023-06-16 23:34:16 +02:00
parent 5b7d7390b0
commit e4606431d1
No known key found for this signature in database
7 changed files with 148 additions and 102 deletions

View file

@ -202,7 +202,7 @@ impl Device {
.from_db()
}}
}
pub async fn find_push_device_by_user(user_uuid: &str, conn: &mut DbConn) -> Vec<Self> {
pub async fn find_push_devices_by_user(user_uuid: &str, conn: &mut DbConn) -> Vec<Self> {
db_run! { conn: {
devices::table
.filter(devices::user_uuid.eq(user_uuid))
@ -212,4 +212,16 @@ impl Device {
.from_db()
}}
}
pub async fn check_user_has_push_device(user_uuid: &str, conn: &mut DbConn) -> bool {
db_run! { conn: {
devices::table
.filter(devices::user_uuid.eq(user_uuid))
.filter(devices::push_token.is_not_null())
.count()
.first::<i64>(conn)
.ok()
.unwrap_or(0) != 0
}}
}
}