Skip to content

Commit 946ea97

Browse files
committed
#72: Add minimum length in Torrent Title
1 parent 6bf1b19 commit 946ea97

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/services/torrent.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,16 @@ impl Index {
9898
/// * Unable to get the category from the database.
9999
/// * Unable to insert the torrent into the database.
100100
/// * Unable to add the torrent to the whitelist.
101+
/// * Torrent title is too short.
101102
pub async fn add_torrent(&self, mut torrent_request: AddTorrentRequest, user_id: UserId) -> Result<TorrentId, ServiceError> {
102103
let _user = self.user_repository.get_compact(&user_id).await?;
103104

104105
torrent_request.torrent.set_announce_urls(&self.configuration).await;
105106

107+
if torrent_request.metadata.title.len() < 3 {
108+
return Err(ServiceError::BadRequest);
109+
}
110+
106111
let category = self
107112
.category_repository
108113
.get_by_name(&torrent_request.metadata.category)

0 commit comments

Comments
 (0)