Skip to content

Commit 206a41a

Browse files
committed
bug fix
1 parent fe4f1c9 commit 206a41a

25 files changed

+5117
-6768
lines changed

.tsd.json.icloud

-156 Bytes
Binary file not shown.

app/localWebServer.js

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,7 @@ class localServer {
191191
return this.catchCmd(mail, uuid);
192192
}, _exitFunction);
193193
};
194-
if (!this.CoNETConnectCalss || this.CoNETConnectCalss.alreadyExit) {
195-
saveLog(`!this.CoNETConnectCalss || this.CoNETConnectCalss.alreadyExit`);
196-
return makeConnect(false);
197-
}
198-
return this.CoNETConnectCalss.tryConnect1();
194+
return makeConnect(false);
199195
}
200196
listenAfterPassword(socket, sessionHash) {
201197
//console.log (`localServer listenAfterPassword for sessionHash [${ sessionHash }]`)
@@ -291,7 +287,7 @@ class localServer {
291287
});
292288
});
293289
socket.on('sendMedia', (uuid, rawData, CallBack) => {
294-
return this.CoNETConnectCalss.sendDataToUuidFolder(Buffer.from(rawData).toString('base64'), uuid, CallBack);
290+
return this.CoNETConnectCalss.sendDataToANewUuidFolder(Buffer.from(rawData).toString('base64'), uuid, uuid, CallBack);
295291
});
296292
socket.on('mime', (_mime, CallBack) => {
297293
let y = mime.lookup(_mime);
@@ -326,58 +322,6 @@ class localServer {
326322
});
327323
});
328324
}
329-
getMedia(mediaString, CallBack) {
330-
//saveLog (` getMedia mediaString = [${ mediaString }]`)
331-
if (/^http[s]*\:\/\//.test(mediaString)) {
332-
return CallBack(null, mediaString);
333-
}
334-
const files = mediaString.split(',');
335-
if (!files || !files.length) {
336-
return CallBack(null, '');
337-
}
338-
//console.log ( files )
339-
return Imap.imapGetMediaFile(this.imapConnectData, files[0], CallBack);
340-
}
341-
getHTMLCompleteZIP(fileName, saveFolder, CallBack) {
342-
if (!fileName || !fileName.length) {
343-
return CallBack(new Error(`getHTMLComplete function Error: filename empty!`));
344-
}
345-
return this.getMedia(fileName, (err, data) => {
346-
if (err) {
347-
return CallBack(err);
348-
}
349-
Fs.writeFileSync(Path.join(saveFolder, fileName), data);
350-
return JSZip.loadAsync(Buffer.from(data.toString(), 'base64'))
351-
.then(zip => {
352-
let u = true;
353-
Async.each(Object.keys(zip.files), (_filename, next) => {
354-
zip.files[_filename].async('nodebuffer').then(content => {
355-
if (content.length) {
356-
return Fs.writeFile(Path.join(saveFolder, _filename), content, next);
357-
}
358-
Fs.mkdir(Path.join(saveFolder, _filename), { recursive: true }, next);
359-
});
360-
}, CallBack);
361-
});
362-
});
363-
}
364-
getVideo(m, CallBack) {
365-
if (!m || !m.QTDownload) {
366-
return CallBack();
367-
}
368-
return this.getMedia(m.QTDownload, (err, data) => {
369-
if (data) {
370-
const file = Uuid.v4() + '.mp4';
371-
const viode = Buffer.from(data, 'base64');
372-
return Fs.writeFile(Path.join(Tool.QTGateVideo, file), viode, err => {
373-
m.QTDownload = `/tempfile/videoTemp/${file}`;
374-
console.log(`save video file: [${file}]`);
375-
return CallBack();
376-
});
377-
}
378-
return CallBack();
379-
});
380-
}
381325
passwordFail(CallBack) {
382326
return CallBack(null, true);
383327
}

app/localWebServer.ts

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ export default class localServer {
160160
return makeConnect ( sendMail = false )
161161
}
162162
}
163-
164-
165163
}
166164

167165
const makeConnect = ( sendMail: boolean ) => {
@@ -192,12 +190,7 @@ export default class localServer {
192190

193191
}
194192

195-
if ( !this.CoNETConnectCalss || this.CoNETConnectCalss.alreadyExit ) {
196-
saveLog( `!this.CoNETConnectCalss || this.CoNETConnectCalss.alreadyExit` )
197-
return makeConnect ( false )
198-
}
199-
200-
return this.CoNETConnectCalss.tryConnect1 ()
193+
return makeConnect ( false )
201194

202195
}
203196

@@ -271,10 +264,6 @@ export default class localServer {
271264
})
272265

273266
}
274-
275-
276-
277-
278267
})
279268

280269
socket.on ( 'doingRequest', ( uuid, request, CallBack ) => {
@@ -317,7 +306,7 @@ export default class localServer {
317306

318307
socket.on ( 'sendMedia', ( uuid, rawData, CallBack ) => {
319308

320-
return this.CoNETConnectCalss.sendDataToUuidFolder ( Buffer.from ( rawData ).toString ( 'base64' ), uuid, CallBack )
309+
return this.CoNETConnectCalss.sendDataToANewUuidFolder ( Buffer.from ( rawData ).toString ( 'base64' ), uuid, uuid, CallBack )
321310
})
322311

323312
socket.on ( 'mime', ( _mime, CallBack ) => {
@@ -361,68 +350,6 @@ export default class localServer {
361350

362351
}
363352

364-
private getMedia ( mediaString: string, CallBack ) {
365-
//saveLog (` getMedia mediaString = [${ mediaString }]`)
366-
if ( /^http[s]*\:\/\//.test ( mediaString )) {
367-
return CallBack ( null, mediaString )
368-
}
369-
const files = mediaString.split (',')
370-
if ( !files || !files.length ) {
371-
return CallBack ( null, '')
372-
}
373-
//console.log ( files )
374-
return Imap.imapGetMediaFile ( this.imapConnectData, files[0], CallBack )
375-
}
376-
377-
public getHTMLCompleteZIP ( fileName: string, saveFolder: string, CallBack ) {
378-
379-
if ( !fileName || !fileName.length ) {
380-
return CallBack ( new Error (`getHTMLComplete function Error: filename empty!`))
381-
}
382-
383-
return this.getMedia ( fileName, ( err, data: Buffer ) => {
384-
if ( err ) {
385-
return CallBack ( err )
386-
}
387-
Fs.writeFileSync ( Path.join( saveFolder, fileName ), data )
388-
389-
return JSZip.loadAsync ( Buffer.from ( data.toString(), 'base64' ))
390-
.then ( zip => {
391-
let u = true
392-
Async.each ( Object.keys ( zip.files ), ( _filename, next ) => {
393-
zip.files [ _filename ].async ( 'nodebuffer' ).then ( content => {
394-
395-
if ( content.length ) {
396-
return Fs.writeFile ( Path.join ( saveFolder, _filename ), content, next )
397-
}
398-
399-
Fs.mkdir ( Path.join ( saveFolder, _filename ), { recursive : true }, next )
400-
401-
})
402-
}, CallBack )
403-
})
404-
})
405-
}
406-
407-
private getVideo ( m: twitter_media_video_info, CallBack ) {
408-
if ( !m || !m.QTDownload ) {
409-
return CallBack ()
410-
}
411-
return this.getMedia ( m.QTDownload, ( err, data ) => {
412-
if ( data ) {
413-
const file = Uuid.v4() + '.mp4'
414-
const viode = Buffer.from ( data, 'base64' )
415-
return Fs.writeFile ( Path.join ( Tool.QTGateVideo, file ), viode, err => {
416-
m.QTDownload = `/tempfile/videoTemp/${ file }`
417-
console.log (`save video file: [${ file }]`)
418-
return CallBack ()
419-
})
420-
}
421-
return CallBack ()
422-
423-
})
424-
}
425-
426353
private passwordFail ( CallBack: ( err?, login? ) => void ) {
427354
return CallBack ( null, true )
428355
}

0 commit comments

Comments
 (0)