make ts happy

This commit is contained in:
idranme
2024-08-06 01:47:51 +08:00
parent a9902d9109
commit 897f691d6c
64 changed files with 485 additions and 420 deletions

View File

@@ -1,9 +1,10 @@
import BaseAction from '../BaseAction'
import { NTQQMsgApi, Peer } from '../../../ntqqapi/api'
import { ChatType, RawMessage } from '../../../ntqqapi/types'
import { dbUtil } from '../../../common/db'
import { getUidByUin } from '../../../common/data'
import { NTQQMsgApi } from '@/ntqqapi/api'
import { ChatType, RawMessage } from '@/ntqqapi/types'
import { dbUtil } from '@/common/db'
import { getUidByUin } from '@/common/data'
import { ActionName } from '../types'
import { Peer } from '@/ntqqapi/types'
interface Payload {
message_id: number
@@ -15,16 +16,16 @@ interface Response {
message_id: number
}
class ForwardSingleMsg extends BaseAction<Payload, Response> {
abstract class ForwardSingleMsg extends BaseAction<Payload, Response> {
protected async getTargetPeer(payload: Payload): Promise<Peer> {
if (payload.user_id) {
return { chatType: ChatType.friend, peerUid: getUidByUin(payload.user_id.toString()) }
return { chatType: ChatType.friend, peerUid: getUidByUin(payload.user_id.toString())! }
}
return { chatType: ChatType.group, peerUid: payload.group_id.toString() }
}
protected async _handle(payload: Payload): Promise<Response> {
const msg = await dbUtil.getMsgByShortId(payload.message_id)
const msg = (await dbUtil.getMsgByShortId(payload.message_id))!
const peer = await this.getTargetPeer(payload)
const sentMsg = await NTQQMsgApi.forwardMsg(
{
@@ -35,7 +36,7 @@ class ForwardSingleMsg extends BaseAction<Payload, Response> {
[msg.msgId],
)
const ob11MsgId = await dbUtil.addMsg(sentMsg)
return {message_id: ob11MsgId}
return { message_id: ob11MsgId! }
}
}