forked from microsoft/BotBuilder-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
activityLog.js
31 lines (26 loc) · 923 Bytes
/
activityLog.js
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
class ActivityLog {
constructor(storage) {
this._storage = storage;
}
async append(activityId, activity) {
if (activityId == null) {
throw new TypeError('activityId is required for ActivityLog.append');
}
if (activity == null) {
throw new TypeError('activity is required for ActivityLog.append');
}
const obj = {};
obj[activityId] = { activity };
await this._storage.write(obj);
}
async find(activityId) {
if (activityId == null) {
throw new TypeError('activityId is required for ActivityLog.find');
}
var items = await this._storage.read([activityId]);
return (items && items[activityId]) ? items[activityId].activity : null;
}
}
exports.ActivityLog = ActivityLog;