feat(getui): add requestId record with single push

pull/90/head
moonrailgun 2 years ago
parent 4192d35234
commit 4a068ee3d5

@ -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';

@ -106,7 +106,7 @@ export class GetuiClient {
title: string,
body: string,
payload: {}
): Promise<SinglePushResPayload> {
): 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<SinglePushResPayload>();
return res;
return { requestId, res };
}
async allPush(
title: string,
body: string,
payload: {}
): Promise<AllPushResPayload> {
): 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<AllPushResPayload>();
return res;
return { requestId, res };
}
}

@ -11,6 +11,9 @@ export class GetuiLog extends TimeStamps implements db.Base {
_id: db.Types.ObjectId;
id: string;
@prop()
requestId: string;
@prop()
userId: string;

@ -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,

Loading…
Cancel
Save