Skip to content

Commit 0cd8fe1

Browse files
committed
examples: Fix typing-notifications examples to send by user ID.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent fba8098 commit 0cd8fe1

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

examples/typing-notifications/send-and-recieve.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const [
2929
realm,
3030
});
3131

32+
const { user_id: recipientId } = await recipientClient.users.me.getProfile();
33+
3234
const res = await recipientClient.queues.register({
3335
event_types: ['typing'],
3436
});
@@ -37,7 +39,7 @@ const [
3739

3840
console.log(
3941
await senderClient.typing.send({
40-
to: recipient,
42+
to: [recipientId],
4143
op: 'start',
4244
})
4345
);

examples/typing-notifications/send-often.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const zulip = require('../../lib');
22

33
if (process.argv.length < 6) {
44
console.log(
5-
'Usage: $node examples/typing-notifications/send-often.js realm-url sender-username sender-API-key recipient-username'
5+
'Usage: $node examples/typing-notifications/send-often.js realm-url sender-username sender-API-key recipient-user-ID'
66
);
77
process.exit(1);
88
}
@@ -17,7 +17,7 @@ const [, , realm, sender, senderAPIKey, recipient] = process.argv;
1717
});
1818
setInterval(async () => {
1919
await senderClient.typing.send({
20-
to: recipient,
20+
to: [Number(recipient)],
2121
op: 'start',
2222
});
2323
}, 1500);

examples/typing-notifications/send.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
const zulip = require('../../lib');
22

3-
let recipient = process.env.ZULIP_USERNAME;
4-
if (process.env.ZULIP_TYPING_RECIPIENT) {
5-
recipient = process.env.ZULIP_TYPING_RECIPIENT;
6-
}
3+
const recipient = Number(process.env.ZULIP_TYPING_RECIPIENT);
74

85
const config = {
96
username: process.env.ZULIP_USERNAME,
@@ -23,7 +20,7 @@ const config = {
2320

2421
// Send typing started notification
2522
await z.typing.send({
26-
to: recipient,
23+
to: [recipient],
2724
op: 'start',
2825
});
2926
console.log('sent typing params');

0 commit comments

Comments
 (0)