fixing contact acceptance error

This commit is contained in:
Roland Osborne 2024-06-20 12:41:05 -07:00
parent f7001136e6
commit 76512cfe88

View File

@ -10,12 +10,18 @@ export async function setCardConnecting(server, token, cardId) {
} }
export async function setCardConnected(server, token, cardId, access, view, article, channel, profile) { export async function setCardConnected(server, token, cardId, access, view, article, channel, profile) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let card = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/status?agent=${token}&token=${access}&viewRevision=${view}&articleRevision=${article}&channelRevision=${channel}&profileRevision=${profile}`, { method: 'PUT', body: JSON.stringify('connected') } ); let card = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/status?agent=${token}&token=${access}&viewRevision=${view}&articleRevision=${article}&channelRevision=${channel}&profileRevision=${profile}`, { method: 'PUT', body: JSON.stringify('connected') } );
checkResponse(card); checkResponse(card);
return await card.json(); return await card.json();
} }
export async function setCardConfirmed(server, token, cardId) { export async function setCardConfirmed(server, token, cardId) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let card = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/status?agent=${token}`, { method: 'PUT', body: JSON.stringify('confirmed') } ); let card = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/status?agent=${token}`, { method: 'PUT', body: JSON.stringify('confirmed') } );
checkResponse(card); checkResponse(card);
return await card.json(); return await card.json();