1
1
import AbortController from 'abort-controller' ;
2
- import { isNumber } from 'lodash' ;
2
+ import { isString , toNumber } from 'lodash' ;
3
3
import { batchFirstSubIsSuccess , batchGlobalIsSuccess , sogsBatchSend } from './sogsV3BatchPoll' ;
4
4
import { uploadFileToRoomSogs3 } from './sogsV3SendFile' ;
5
5
import { OpenGroupRequestCommonType } from '../../../../data/types' ;
@@ -17,25 +17,30 @@ import { DURATION } from '../../../constants';
17
17
export const uploadImageForRoomSogsV3 = async (
18
18
fileContent : Uint8Array ,
19
19
roomInfos : OpenGroupRequestCommonType
20
- ) : Promise < { fileUrl : string ; fileId : number } | null > => {
20
+ ) : Promise < { fileUrl : string } | null > => {
21
21
if ( ! fileContent || ! fileContent . length ) {
22
22
return null ;
23
23
}
24
24
25
25
const result = await uploadFileToRoomSogs3 ( fileContent , roomInfos ) ;
26
- if ( ! result || ! isNumber ( result . fileId ) ) {
26
+ if ( ! result || ! isString ( result . fileId ) ) {
27
27
return null ;
28
28
}
29
- const { fileId , fileUrl } = result ;
30
- if ( ! fileId || ! fileContent . length ) {
29
+ const { fileUrl } = result ;
30
+ if ( ! fileContent . length ) {
31
31
return null ;
32
32
}
33
33
34
34
const batchResult = await sogsBatchSend (
35
35
roomInfos . serverUrl ,
36
36
new Set ( [ roomInfos . roomId ] ) ,
37
37
new AbortController ( ) . signal ,
38
- [ { type : 'updateRoom' , updateRoom : { roomId : roomInfos . roomId , imageId : fileId } } ] ,
38
+ [
39
+ {
40
+ type : 'updateRoom' ,
41
+ updateRoom : { roomId : roomInfos . roomId , imageId : toNumber ( result . fileId ) } ,
42
+ } ,
43
+ ] ,
39
44
'batch' ,
40
45
30 * DURATION . SECONDS // longer time for image upload
41
46
) ;
@@ -45,6 +50,5 @@ export const uploadImageForRoomSogsV3 = async (
45
50
}
46
51
return {
47
52
fileUrl,
48
- fileId,
49
53
} ;
50
54
} ;
0 commit comments