@@ -1612,38 +1612,35 @@ const request_file = async (address, topic, file, room, dm = false) => {
16121612} ;
16131613
16141614const process_files = async ( data , active , con , topic ) => {
1615- //Check if the latest 10 files are in sync
1616- if ( Hugin . syncImages ) {
1617- if ( ! Array . isArray ( data . files ) ) return 'Ban' ;
1618- if ( data . files . length > 10 ) return 'Ban' ;
1619- for ( const file of data . files ) {
1620- const old = ( Date . now ( ) - file . time ) > ONE_DAY
1621- if ( old ) continue
1622- if ( Hugin . files . some ( ( a ) => a === file . hash ) ) continue ;
1623- if ( ! check_hash ( file . hash ) ) continue ;
1624- const [ isMedia ] = check_if_media ( file . fileName , file . size ) ;
1625- await sleep ( 50 ) ;
1626- if ( isMedia ) {
1627- request_file ( con . address , topic , file , active . key ) ;
1628- continue ;
1629- }
1630- if ( ! con . driveKey ) continue ;
1631- const fromAddr = file . address || con . address ;
1632- const remoteFile = {
1633- fileName : file . fileName ,
1634- address : fromAddr ,
1635- size : file . size ,
1636- topic,
1637- key : active . key ,
1638- chat : fromAddr ,
1639- hash : file . hash ,
1640- name : file . name || con . name ,
1641- time : file . time ,
1642- driveKey : con . driveKey ,
1643- } ;
1644- Hugin . send ( 'room-remote-file-added' , { chat : active . key , remoteFiles : [ remoteFile ] } ) ;
1645- save_file_info ( file , topic , fromAddr , file . time , false , con . name ) ;
1615+ if ( ! Array . isArray ( data . files ) ) return 'Ban' ;
1616+ if ( data . files . length > 10 ) return 'Ban' ;
1617+ for ( const file of data . files ) {
1618+ const old = ( Date . now ( ) - file . time ) > ONE_DAY
1619+ if ( old ) continue
1620+ if ( Hugin . files . some ( ( a ) => a === file . hash ) ) continue ;
1621+ if ( ! check_hash ( file . hash ) ) continue ;
1622+ const [ isMedia ] = check_if_media ( file . fileName , file . size ) ;
1623+ await sleep ( 50 ) ;
1624+ if ( isMedia && Hugin . syncImages ) {
1625+ request_file ( con . address , topic , file , active . key ) ;
1626+ continue ;
16461627 }
1628+ if ( ! con . driveKey ) continue ;
1629+ const fromAddr = file . address || con . address ;
1630+ const remoteFile = {
1631+ fileName : file . fileName ,
1632+ address : fromAddr ,
1633+ size : file . size ,
1634+ topic,
1635+ key : active . key ,
1636+ chat : fromAddr ,
1637+ hash : file . hash ,
1638+ name : file . name || con . name ,
1639+ time : file . time ,
1640+ driveKey : con . driveKey ,
1641+ } ;
1642+ Hugin . send ( 'room-remote-file-added' , { chat : active . key , remoteFiles : [ remoteFile ] } ) ;
1643+ save_file_info ( file , topic , fromAddr , file . time , false , con . name ) ;
16471644 }
16481645} ;
16491646
0 commit comments