-
-
Save sendbird-community/d3bb299eafa9ff3c934a885f8305cef1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildBackupGroupCallUrl: async function (data) { | |
const returnData = { | |
"service_user_id": data.userId, | |
"room_id": null, | |
"app_id": APP_ID, | |
"creds": { | |
"token": null, | |
"expires_at": null | |
} | |
} | |
try { | |
const userCredentials = await fetchNewSendBirdSessionToken(data.userId) | |
if (userCredentials.token) returnData.creds = userCredentials | |
} catch (e) { | |
if (e.message == 'Request failed: {"error":true,"message":"\\"User\\" not found.","code":400201}') { | |
//Create a new user. | |
try { | |
const newUser = await createNewSendbirdUser(data.userId) | |
returnData.service_user_id = newUser.user_id | |
} catch (e) { | |
renderData(e, null) | |
} | |
try { | |
const userCredentials = await fetchNewSendBirdSessionToken(data.userId) | |
if (userCredentials.token) returnData.creds = userCredentials | |
} catch (e) { | |
renderData(e, null) | |
} | |
} | |
} | |
try { | |
const newRoom = await createNewSendbirdGroupCallRoom() | |
if (newRoom.room.room_id) returnData.room_id = newRoom.room.room_id | |
renderData(null, returnData) | |
return | |
} catch (e) { | |
returnData(e, null) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment