Skip to content

Commit a75d759

Browse files
RoardomHDVinnie
andcommitted
add: custom schema changes
Add: - `users.is_donor` - `users.is_lifetime` Co-authored-by: HDVinnie <hdinnovations@protonmail.com>
1 parent d8c7453 commit a75d759

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/announce.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,9 @@ pub async fn announce(
359359
_ => (),
360360
}
361361

362-
// Make sure user isn't leeching more torrents than their group allows
362+
// Make sure user isn't leeching more torrents than their group allows unless they are a lifetime user
363363
let has_hit_download_slot_limit = queries.left > 0
364+
&& !user.is_lifetime
364365
&& matches!(group.download_slots, Some(slots) if slots <= user.num_leeching);
365366

366367
// Change of upload/download compared to previous announce
@@ -664,6 +665,7 @@ pub async fn announce(
664665
.featured_torrents
665666
.read()
666667
.contains(&FeaturedTorrent { torrent_id })
668+
|| user.is_donor
667669
{
668670
0
669671
} else {
@@ -726,7 +728,7 @@ pub async fn announce(
726728
queries.downloaded,
727729
queries.left == 0,
728730
queries.event != Event::Stopped,
729-
group.is_immune,
731+
group.is_immune || user.is_donor,
730732
completed_at,
731733
);
732734

src/tracker/user.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ impl Map {
3636
users.passkey as `passkey: Passkey`,
3737
users.can_download as `can_download: bool`,
3838
CAST(COALESCE(SUM(peers.seeder = 1 AND peers.active = 1 AND peers.visible = 1), 0) AS UNSIGNED) as `num_seeding: u32`,
39-
CAST(COALESCE(SUM(peers.seeder = 0 AND peers.active = 1 AND peers.visible = 1), 0) AS UNSIGNED) as `num_leeching: u32`
39+
CAST(COALESCE(SUM(peers.seeder = 0 AND peers.active = 1 AND peers.visible = 1), 0) AS UNSIGNED) as `num_leeching: u32`,
40+
users.is_donor as `is_donor: bool`,
41+
users.is_lifetime as `is_lifetime: bool`
4042
FROM
4143
users
4244
LEFT JOIN
@@ -78,6 +80,8 @@ impl Map {
7880
can_download: user.can_download,
7981
num_seeding: user.num_seeding,
8082
num_leeching: user.num_leeching,
83+
is_donor: user.is_donor,
84+
is_lifetime: user.is_lifetime,
8185
},
8286
);
8387

@@ -140,6 +144,8 @@ pub struct User {
140144
pub can_download: bool,
141145
pub num_seeding: u32,
142146
pub num_leeching: u32,
147+
pub is_donor: bool,
148+
pub is_lifetime: bool,
143149
}
144150

145151
#[derive(Clone, Deserialize, Hash)]
@@ -150,6 +156,8 @@ pub struct APIInsertUser {
150156
pub can_download: bool,
151157
pub num_seeding: u32,
152158
pub num_leeching: u32,
159+
pub is_donor: bool,
160+
pub is_lifetime: bool,
153161
}
154162

155163
#[derive(Clone, Deserialize, Hash)]

0 commit comments

Comments
 (0)