Skip to content

Commit 1fc5967

Browse files
author
Tim Mendoza
committed
Add a timer to close all conversations after 24 hours
1 parent d875a5f commit 1fc5967

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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.close': 'P1D' });
97100
} catch (e) {
98101
response.setStatusCode(500);
99102
response.setBody({

0 commit comments

Comments
 (0)