From 61baa2ffb02fac1eb65e6134de99f2c284bbdd66 Mon Sep 17 00:00:00 2001 From: Roardom Date: Tue, 19 Dec 2023 23:19:05 +0000 Subject: [PATCH] add: custom schema changes Add: - `users.is_donor` - `users.is_lifetime` Co-authored-by: HDVinnie --- src/announce.rs | 6 ++++-- src/tracker/user.rs | 10 +++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/announce.rs b/src/announce.rs index 44f2096..09b5fe3 100644 --- a/src/announce.rs +++ b/src/announce.rs @@ -377,8 +377,9 @@ pub async fn announce( _ => (), } - // Make sure user isn't leeching more torrents than their group allows + // Make sure user isn't leeching more torrents than their group allows unless they are a lifetime user let has_hit_download_slot_limit = queries.left > 0 + && !user.is_lifetime && matches!(group.download_slots, Some(slots) if slots <= user.num_leeching); // Change of upload/download compared to previous announce @@ -707,6 +708,7 @@ pub async fn announce( .featured_torrents .read() .contains(&FeaturedTorrent { torrent_id }) + || user.is_donor { 0 } else { @@ -769,7 +771,7 @@ pub async fn announce( queries.downloaded, queries.left == 0, queries.event != Event::Stopped, - group.is_immune, + group.is_immune || user.is_donor, completed_at, ); diff --git a/src/tracker/user.rs b/src/tracker/user.rs index 35e16f9..328ebd4 100644 --- a/src/tracker/user.rs +++ b/src/tracker/user.rs @@ -36,7 +36,9 @@ impl Map { users.passkey as `passkey: Passkey`, users.can_download as `can_download: bool`, CAST(COALESCE(SUM(peers.seeder = 1 AND peers.active = 1 AND peers.visible = 1), 0) AS UNSIGNED) as `num_seeding: u32`, - CAST(COALESCE(SUM(peers.seeder = 0 AND peers.active = 1 AND peers.visible = 1), 0) AS UNSIGNED) as `num_leeching: u32` + CAST(COALESCE(SUM(peers.seeder = 0 AND peers.active = 1 AND peers.visible = 1), 0) AS UNSIGNED) as `num_leeching: u32`, + users.is_donor as `is_donor: bool`, + users.is_lifetime as `is_lifetime: bool` FROM users LEFT JOIN @@ -78,6 +80,8 @@ impl Map { can_download: user.can_download, num_seeding: user.num_seeding, num_leeching: user.num_leeching, + is_donor: user.is_donor, + is_lifetime: user.is_lifetime, }, ); @@ -140,6 +144,8 @@ pub struct User { pub can_download: bool, pub num_seeding: u32, pub num_leeching: u32, + pub is_donor: bool, + pub is_lifetime: bool, } #[derive(Clone, Deserialize, Hash)] @@ -150,6 +156,8 @@ pub struct APIInsertUser { pub can_download: bool, pub num_seeding: u32, pub num_leeching: u32, + pub is_donor: bool, + pub is_lifetime: bool, } #[derive(Clone, Deserialize, Hash)]