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 Clipboard from '@react-native-community/clipboard';
import { ServerCard } from './components/ServerCard'; import { ServerCard } from './components/ServerCard';
import { useServerStore } from './store/server'; import { useServerStore } from './store/server';
import Dialog from 'react-native-ui-lib/dialog';
import { import {
Button, Button,
PanningProvider, PanningProvider,
@ -12,6 +11,7 @@ import {
ActionSheet, ActionSheet,
TextField, TextField,
TouchableOpacity, TouchableOpacity,
Dialog,
} from 'react-native-ui-lib'; } from 'react-native-ui-lib';
import { isValidUrl } from './lib/utils'; import { isValidUrl } from './lib/utils';
import { translate } from './lib/i18n'; import { translate } from './lib/i18n';

@ -106,7 +106,7 @@ export class GetuiClient {
title: string, title: string,
body: string, body: string,
payload: {} payload: {}
): Promise<SinglePushResPayload> { ): Promise<{ requestId: string; res: SinglePushResPayload }> {
const token = await this.getToken(); const token = await this.getToken();
const requestId = this.generateRequestId(); const requestId = this.generateRequestId();
const res = await got(`${this.baseUrl}/push/single/alias`, { const res = await got(`${this.baseUrl}/push/single/alias`, {
@ -131,14 +131,14 @@ export class GetuiClient {
}, },
}).json<SinglePushResPayload>(); }).json<SinglePushResPayload>();
return res; return { requestId, res };
} }
async allPush( async allPush(
title: string, title: string,
body: string, body: string,
payload: {} payload: {}
): Promise<AllPushResPayload> { ): Promise<{ requestId: string; res: AllPushResPayload }> {
const token = await this.getToken(); const token = await this.getToken();
console.log('token', token); console.log('token', token);
const requestId = this.generateRequestId(); const requestId = this.generateRequestId();
@ -162,6 +162,6 @@ export class GetuiClient {
}, },
}).json<AllPushResPayload>(); }).json<AllPushResPayload>();
return res; return { requestId, res };
} }
} }

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

@ -62,8 +62,14 @@ class GetuiService extends TcService {
}; };
try { try {
await client.singlePush(userId, title, content, payload); const { requestId } = await client.singlePush(
userId,
title,
content,
payload
);
await this.adapter.model.create({ await this.adapter.model.create({
requestId,
userId, userId,
title, title,
content, content,

Loading…
Cancel
Save