@@ -33,16 +33,6 @@ export const uploadTorrent = async (req, res, next) => {
3333 const torrent = Buffer . from ( req . body . torrent , "base64" ) ;
3434 const parsed = bencode . decode ( torrent ) ;
3535
36- if ( parsed . info . private !== 1 ) {
37- res . status ( 400 ) . send ( "Torrent must be set to private" ) ;
38- return ;
39- }
40-
41- if ( ! parsed . announce || parsed [ "announce-list" ] ) {
42- res . status ( 400 ) . send ( "One and only one announce URL must be set" ) ;
43- return ;
44- }
45-
4636 if ( process . env . SQ_TORRENT_CATEGORIES . length && ! req . body . type ) {
4737 res . status ( 400 ) . send ( "Torrent must have a category" ) ;
4838 return ;
@@ -67,14 +57,6 @@ export const uploadTorrent = async (req, res, next) => {
6757
6858 const user = await User . findOne ( { _id : req . userId } ) . lean ( ) ;
6959
70- if (
71- parsed . announce . toString ( ) !==
72- `${ process . env . SQ_BASE_URL } /sq/${ user . uid } /announce`
73- ) {
74- res . status ( 400 ) . send ( "Announce URL is invalid" ) ;
75- return ;
76- }
77-
7860 const infoHash = crypto
7961 . createHash ( "sha1" )
8062 . update ( bencode . encode ( parsed . info ) )
@@ -87,6 +69,10 @@ export const uploadTorrent = async (req, res, next) => {
8769 return ;
8870 }
8971
72+ parsed . info . private = 1 ;
73+ parsed . announce = `${ process . env . SQ_BASE_URL } /sq/${ user . uid } /announce` ;
74+ delete parsed [ "announce-list" ] ;
75+
9076 let files ;
9177 if ( parsed . info . files ) {
9278 files = parsed . info . files . map ( ( file ) => ( {
0 commit comments