-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathtest_notification.js
More file actions
44 lines (36 loc) · 1.05 KB
/
test_notification.js
File metadata and controls
44 lines (36 loc) · 1.05 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
41
42
43
44
import stream from "getstream";
import dotenv from "dotenv";
dotenv.config();
async function main() {
const apiKey = process.env.STREAM_API_KEY;
const apiSecret = process.env.STREAM_API_SECRET;
const appId = process.env.STREAM_APP_ID;
if (!apiKey) {
console.error("STREAM_API_KEY should be set");
return;
}
if (!appId) {
console.error("STREAM_APP_ID should be set");
return;
}
if (!apiSecret) {
console.error("STREAM_SECRET should be set");
return;
}
console.log(apiKey, apiSecret);
const serverClient = stream.connect(apiKey, apiSecret, appId);
function createUserClient(userId) {
return stream.connect(apiKey, serverClient.createUserToken(userId), appId);
}
const batman = createUserClient("batman");
const content = "test2";
console.log(await batman.feed("notification").get({ limit: 1 }));
await batman.feed("notification").addActivity({
actor: batman.currentUser,
verb: "post",
object: content,
content
});
console.log(await batman.feed("notification").get({ limit: 1 }));
}
main();