Skip to content

Commit 2c55246

Browse files
author
timmydoza
authored
Merge pull request #69 from twilio-labs/add-conversations-timers
Add conversations timers
2 parents d875a5f + 69391c9 commit 2c55246

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.8.1
4+
5+
### Enhancement
6+
7+
- Specified a timer when creating a Twilio Conversation. This will automatically close the conversation after 24 hours, which is equal to the maximum duration of a video room. This helps to clean up old conversations since there is a limit that a single participant can not be added to more than 1,000 open conversations.
8+
39
## 0.8.0
410

511
### New Features

src/serverless/functions/token.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ module.exports.handler = async (context, event, callback) => {
9393
} catch (e) {
9494
try {
9595
// If conversation doesn't exist, create it.
96-
await conversationsClient.conversations.create({ uniqueName: room.sid });
96+
// Here we add a timer to close the conversation after the maximum length of a room (24 hours).
97+
// This helps to clean up old conversations since there is a limit that a single participant
98+
// can not be added to more than 1,000 open conversations.
99+
await conversationsClient.conversations.create({ uniqueName: room.sid, 'timers.closed': 'P1D' });
97100
} catch (e) {
98101
response.setStatusCode(500);
99102
response.setBody({

test/serverless/functions/token.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('the video-token-server', () => {
5959
);
6060

6161
expect(mockFns.createRoom).toHaveBeenCalledWith({ type: 'group', uniqueName: 'test-room' });
62-
expect(mockFns.createConversation).toHaveBeenCalledWith({ uniqueName: 'mockNewRoomSid' });
62+
expect(mockFns.createConversation).toHaveBeenCalledWith({ uniqueName: 'mockNewRoomSid', 'timers.closed': 'P1D' });
6363
expect(callback).toHaveBeenCalledWith(null, {
6464
body: { token: expect.any(String), room_type: 'group' },
6565
headers: { 'Content-Type': 'application/json' },

0 commit comments

Comments
 (0)