From 4a068ee3d5e720d8bf0a43e14f1838210e90af57 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 4 Apr 2023 14:41:09 +0800 Subject: [PATCH] feat(getui): add requestId record with single push --- client/mobile/src/Entry.tsx | 2 +- server/plugins/com.msgbyte.getui/lib/GetuiClient.ts | 8 ++++---- server/plugins/com.msgbyte.getui/models/log.ts | 3 +++ .../plugins/com.msgbyte.getui/services/getui.service.ts | 8 +++++++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/client/mobile/src/Entry.tsx b/client/mobile/src/Entry.tsx index 3920f022..9e36e8cd 100644 --- a/client/mobile/src/Entry.tsx +++ b/client/mobile/src/Entry.tsx @@ -3,7 +3,6 @@ import { Alert, StyleSheet, ScrollView } from 'react-native'; import Clipboard from '@react-native-community/clipboard'; import { ServerCard } from './components/ServerCard'; import { useServerStore } from './store/server'; -import Dialog from 'react-native-ui-lib/dialog'; import { Button, PanningProvider, @@ -12,6 +11,7 @@ import { ActionSheet, TextField, TouchableOpacity, + Dialog, } from 'react-native-ui-lib'; import { isValidUrl } from './lib/utils'; import { translate } from './lib/i18n'; diff --git a/server/plugins/com.msgbyte.getui/lib/GetuiClient.ts b/server/plugins/com.msgbyte.getui/lib/GetuiClient.ts index 3a85c7b9..7496026a 100644 --- a/server/plugins/com.msgbyte.getui/lib/GetuiClient.ts +++ b/server/plugins/com.msgbyte.getui/lib/GetuiClient.ts @@ -106,7 +106,7 @@ export class GetuiClient { title: string, body: string, payload: {} - ): Promise { + ): Promise<{ requestId: string; res: SinglePushResPayload }> { const token = await this.getToken(); const requestId = this.generateRequestId(); const res = await got(`${this.baseUrl}/push/single/alias`, { @@ -131,14 +131,14 @@ export class GetuiClient { }, }).json(); - return res; + return { requestId, res }; } async allPush( title: string, body: string, payload: {} - ): Promise { + ): Promise<{ requestId: string; res: AllPushResPayload }> { const token = await this.getToken(); console.log('token', token); const requestId = this.generateRequestId(); @@ -162,6 +162,6 @@ export class GetuiClient { }, }).json(); - return res; + return { requestId, res }; } } diff --git a/server/plugins/com.msgbyte.getui/models/log.ts b/server/plugins/com.msgbyte.getui/models/log.ts index fd120e67..1b5cfb06 100644 --- a/server/plugins/com.msgbyte.getui/models/log.ts +++ b/server/plugins/com.msgbyte.getui/models/log.ts @@ -11,6 +11,9 @@ export class GetuiLog extends TimeStamps implements db.Base { _id: db.Types.ObjectId; id: string; + @prop() + requestId: string; + @prop() userId: string; diff --git a/server/plugins/com.msgbyte.getui/services/getui.service.ts b/server/plugins/com.msgbyte.getui/services/getui.service.ts index 4c054e20..a9a6f7b1 100644 --- a/server/plugins/com.msgbyte.getui/services/getui.service.ts +++ b/server/plugins/com.msgbyte.getui/services/getui.service.ts @@ -62,8 +62,14 @@ class GetuiService extends TcService { }; try { - await client.singlePush(userId, title, content, payload); + const { requestId } = await client.singlePush( + userId, + title, + content, + payload + ); await this.adapter.model.create({ + requestId, userId, title, content,