-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-messages.js
More file actions
40 lines (37 loc) · 1.14 KB
/
get-messages.js
File metadata and controls
40 lines (37 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// import * as Sentry from '@sentry/node';
import { ResponseUtil } from './util';
import { MessageDao } from "./dao";
import { AuthApiFactory } from "./service";
// Sentry.init({ dsn: process.env.sentryDsn });
const messageDao = new MessageDao();
export async function main(event, context) {
try {
const body = JSON.parse(event.body);
const {
eosAccount2,
limit,
lastEvaluatedKey
} = body;
const authApi = AuthApiFactory.getInstance(event, body);
const { appId } = await authApi.getApp();
if (!eosAccount2) {
return ResponseUtil.failure("eosAccount2 parameter is required");
}
const eosAccount1 = await authApi.getUserName();
const messages = await messageDao.getByParticipants({
appId,
eosAccount1,
eosAccount2,
limit,
lastEvaluatedKey
});
return ResponseUtil.success({
status: true,
messages,
});
} catch (e) {
console.error(e);
// Sentry.captureException(e);
return ResponseUtil.failure(e);
}
}