@@ -4,21 +4,25 @@ import { SendElement } from '@/ntqqapi/entities'
44import { uri2local } from '@/common/utils'
55import { createPeer , CreatePeerMode } from '../../helper/createMessage'
66
7- interface UploadPrivateFilePayload {
7+ interface Payload {
88 user_id : number | string
99 file : string
1010 name : string
1111}
1212
13- export class UploadPrivateFile extends BaseAction < UploadPrivateFilePayload , null > {
13+ interface Response {
14+ file_id : string
15+ }
16+
17+ export class UploadPrivateFile extends BaseAction < Payload , Response > {
1418 actionName = ActionName . GoCQHTTP_UploadPrivateFile
1519 payloadSchema = Schema . object ( {
1620 user_id : Schema . union ( [ Number , String ] ) . required ( ) ,
1721 file : Schema . string ( ) . required ( ) ,
1822 name : Schema . string ( )
1923 } )
2024
21- protected async _handle ( payload : UploadPrivateFilePayload ) : Promise < null > {
25+ protected async _handle ( payload : Payload ) {
2226 const { success, errMsg, path, fileName } = await uri2local ( this . ctx , payload . file )
2327 if ( ! success ) {
2428 throw new Error ( errMsg )
@@ -29,7 +33,9 @@ export class UploadPrivateFile extends BaseAction<UploadPrivateFilePayload, null
2933 }
3034 const sendFileEle = await SendElement . file ( this . ctx , path , name )
3135 const peer = await createPeer ( this . ctx , payload , CreatePeerMode . Private )
32- await this . ctx . app . sendMessage ( this . ctx , peer , [ sendFileEle ] , [ ] )
33- return null
36+ const msg = await this . ctx . app . sendMessage ( this . ctx , peer , [ sendFileEle ] , [ ] )
37+ return {
38+ file_id : msg . elements [ 0 ] . fileElement ! . fileUuid
39+ }
3440 }
3541}
0 commit comments