Skip to content

Instantly share code, notes, and snippets.

@sendbird-community
Created March 17, 2023 19:29
Show Gist options
  • Save sendbird-community/d3bb299eafa9ff3c934a885f8305cef1 to your computer and use it in GitHub Desktop.
Save sendbird-community/d3bb299eafa9ff3c934a885f8305cef1 to your computer and use it in GitHub Desktop.
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