mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
allowing for http protocol
This commit is contained in:
parent
aab471eed7
commit
b3ad138fa3
@ -2,13 +2,15 @@ import { checkResponse, fetchWithCustomTimeout } from './fetchUtil';
|
||||
import base64 from 'react-native-base64'
|
||||
|
||||
export async function addAccount(server, username, password, token) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let access = "";
|
||||
if (token) {
|
||||
access = `?token=${token}`
|
||||
}
|
||||
let headers = new Headers()
|
||||
headers.append('Credentials', 'Basic ' + base64.encode(username + ":" + password));
|
||||
let profile = await fetchWithCustomTimeout(`https://${server}/account/profile${access}`, { method: 'POST', headers: headers }, 60000)
|
||||
let profile = await fetchWithCustomTimeout(`${protocol}://${server}/account/profile${access}`, { method: 'POST', headers: headers }, 60000)
|
||||
checkResponse(profile);
|
||||
return await profile.json()
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function addAccountAccess(server, token, accountId) {
|
||||
let access = await fetchWithTimeout(`https://${server}/admin/accounts/${accountId}/auth?token=${token}`, { method: 'POST' })
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let access = await fetchWithTimeout(`${protocol}://${server}/admin/accounts/${accountId}/auth?token=${token}`, { method: 'POST' })
|
||||
checkResponse(access);
|
||||
return await access.json()
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function addAccountCreate(server, token) {
|
||||
let access = await fetchWithTimeout(`https://${server}/admin/accounts?token=${token}`, { method: 'POST' })
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let access = await fetchWithTimeout(`${protocol}://${server}/admin/accounts?token=${token}`, { method: 'POST' })
|
||||
checkResponse(access);
|
||||
return await access.json()
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function addCall(server, token, cardId) {
|
||||
let call = await fetchWithTimeout(`https://${server}/talk/calls?agent=${token}`, { method: 'POST', body: JSON.stringify(cardId)} );
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let call = await fetchWithTimeout(`${protocol}://${server}/talk/calls?agent=${token}`, { method: 'POST', body: JSON.stringify(cardId)} );
|
||||
checkResponse(call);
|
||||
return await call.json();
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function addCard(server, token, message) {
|
||||
let card = await fetchWithTimeout(`https://${server}/contact/cards?agent=${token}`, { method: 'POST', body: JSON.stringify(message)} );
|
||||
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?agent=${token}`, { method: 'POST', body: JSON.stringify(message)} );
|
||||
checkResponse(card);
|
||||
return await card.json();
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function addChannel(server, token, type, data, cards ) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let params = { dataType: type, data: JSON.stringify(data), groups: [], cards };
|
||||
let channel = await fetchWithTimeout(`https://${server}/content/channels?agent=${token}`, { method: 'POST', body: JSON.stringify(params)} );
|
||||
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels?agent=${token}`, { method: 'POST', body: JSON.stringify(params)} );
|
||||
checkResponse(channel);
|
||||
return await channel.json();
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function addChannelTopic(server, token, channelId, messageType, message, assets ): string {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
if (message == null && (assets == null || assets.length === 0)) {
|
||||
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?agent=${token}`,
|
||||
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?agent=${token}`,
|
||||
{ method: 'POST', body: JSON.stringify({}) });
|
||||
checkResponse(topic);
|
||||
let slot = await topic.json();
|
||||
@ -14,7 +16,7 @@ export async function addChannelTopic(server, token, channelId, messageType, mes
|
||||
if (value !== null) return value
|
||||
}), datatype: messageType };
|
||||
|
||||
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?agent=${token}&confirm=true`,
|
||||
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?agent=${token}&confirm=true`,
|
||||
{ method: 'POST', body: JSON.stringify(subject) });
|
||||
checkResponse(topic);
|
||||
let slot = await topic.json();
|
||||
@ -22,7 +24,7 @@ export async function addChannelTopic(server, token, channelId, messageType, mes
|
||||
}
|
||||
else {
|
||||
|
||||
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?agent=${token}`,
|
||||
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?agent=${token}`,
|
||||
{ method: 'POST', body: JSON.stringify({}) });
|
||||
checkResponse(topic);
|
||||
let slot = await topic.json();
|
||||
@ -34,7 +36,7 @@ export async function addChannelTopic(server, token, channelId, messageType, mes
|
||||
const formData = new FormData();
|
||||
formData.append('asset', asset.image);
|
||||
let transform = encodeURIComponent(JSON.stringify(["ithumb;photo", "icopy;photo"]));
|
||||
let topicAsset = await fetch(`https://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&agent=${token}`, { method: 'POST', body: formData });
|
||||
let topicAsset = await fetch(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&agent=${token}`, { method: 'POST', body: formData });
|
||||
checkResponse(topicAsset);
|
||||
let assetEntry = await topicAsset.json();
|
||||
message.assets.push({
|
||||
@ -49,7 +51,7 @@ export async function addChannelTopic(server, token, channelId, messageType, mes
|
||||
formData.append('asset', asset.video);
|
||||
let thumb = 'vthumb;video;' + asset.position;
|
||||
let transform = encodeURIComponent(JSON.stringify(["vlq;video", "vhd;video", thumb]));
|
||||
let topicAsset = await fetch(`https://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&agent=${token}`, { method: 'POST', body: formData });
|
||||
let topicAsset = await fetch(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&agent=${token}`, { method: 'POST', body: formData });
|
||||
checkResponse(topicAsset);
|
||||
let assetEntry = await topicAsset.json();
|
||||
message.assets.push({
|
||||
@ -64,7 +66,7 @@ export async function addChannelTopic(server, token, channelId, messageType, mes
|
||||
const formData = new FormData();
|
||||
formData.append('asset', asset.audio);
|
||||
let transform = encodeURIComponent(JSON.stringify(["acopy;audio"]));
|
||||
let topicAsset = await fetch(`https://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&agent=${token}`, { method: 'POST', body: formData });
|
||||
let topicAsset = await fetch(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&agent=${token}`, { method: 'POST', body: formData });
|
||||
checkResponse(topicAsset);
|
||||
let assetEntry = await topicAsset.json();
|
||||
message.assets.push({
|
||||
@ -80,11 +82,11 @@ export async function addChannelTopic(server, token, channelId, messageType, mes
|
||||
if (value !== null) return value
|
||||
}), datatype: messageType };
|
||||
|
||||
let unconfirmed = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${slot.id}/subject?agent=${token}`,
|
||||
let unconfirmed = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/subject?agent=${token}`,
|
||||
{ method: 'PUT', body: JSON.stringify(subject) });
|
||||
checkResponse(unconfirmed);
|
||||
|
||||
let confirmed = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${slot.id}/confirmed?agent=${token}`,
|
||||
let confirmed = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/confirmed?agent=${token}`,
|
||||
{ method: 'PUT', body: JSON.stringify('confirmed') });
|
||||
checkResponse(confirmed);
|
||||
return slot.id;
|
||||
|
@ -1,8 +1,11 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function addContactChannelTopic(server, token, channelId, messageType, message, assets ) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
if (message == null && (assets == null || assets.length === 0)) {
|
||||
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?contact=${token}`,
|
||||
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?contact=${token}`,
|
||||
{ method: 'POST', body: JSON.stringify({}) });
|
||||
checkResponse(topic);
|
||||
let slot = await topic.json();
|
||||
@ -13,14 +16,14 @@ export async function addContactChannelTopic(server, token, channelId, messageTy
|
||||
if (value !== null) return value
|
||||
}), datatype: messageType };
|
||||
|
||||
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?contact=${token}&confirm=true`,
|
||||
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?contact=${token}&confirm=true`,
|
||||
{ method: 'POST', body: JSON.stringify(subject) });
|
||||
checkResponse(topic);
|
||||
let slot = await topic.json();
|
||||
return slot.id;
|
||||
}
|
||||
else {
|
||||
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?contact=${token}`,
|
||||
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?contact=${token}`,
|
||||
{ method: 'POST', body: JSON.stringify({}) });
|
||||
checkResponse(topic);
|
||||
let slot = await topic.json();
|
||||
@ -32,7 +35,7 @@ export async function addContactChannelTopic(server, token, channelId, messageTy
|
||||
const formData = new FormData();
|
||||
formData.append('asset', asset.image);
|
||||
let transform = encodeURIComponent(JSON.stringify(["ithumb;photo", "icopy;photo"]));
|
||||
let topicAsset = await fetch(`https://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&contact=${token}`, { method: 'POST', body: formData });
|
||||
let topicAsset = await fetch(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&contact=${token}`, { method: 'POST', body: formData });
|
||||
checkResponse(topicAsset);
|
||||
let assetEntry = await topicAsset.json();
|
||||
message.assets.push({
|
||||
@ -47,7 +50,7 @@ export async function addContactChannelTopic(server, token, channelId, messageTy
|
||||
formData.append('asset', asset.video);
|
||||
let thumb = "vthumb;video;" + asset.position
|
||||
let transform = encodeURIComponent(JSON.stringify(["vhd;video", "vlq;video", thumb]));
|
||||
let topicAsset = await fetch(`https://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&contact=${token}`, { method: 'POST', body: formData });
|
||||
let topicAsset = await fetch(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&contact=${token}`, { method: 'POST', body: formData });
|
||||
checkResponse(topicAsset);
|
||||
let assetEntry = await topicAsset.json();
|
||||
message.assets.push({
|
||||
@ -62,7 +65,7 @@ export async function addContactChannelTopic(server, token, channelId, messageTy
|
||||
const formData = new FormData();
|
||||
formData.append('asset', asset.audio);
|
||||
let transform = encodeURIComponent(JSON.stringify(["acopy;audio"]));
|
||||
let topicAsset = await fetch(`https://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&contact=${token}`, { method: 'POST', body: formData });
|
||||
let topicAsset = await fetch(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&contact=${token}`, { method: 'POST', body: formData });
|
||||
checkResponse(topicAsset);
|
||||
let assetEntry = await topicAsset.json();
|
||||
message.assets.push({
|
||||
@ -78,11 +81,11 @@ export async function addContactChannelTopic(server, token, channelId, messageTy
|
||||
if (value !== null) return value
|
||||
}), datatype: messageType };
|
||||
|
||||
let unconfirmed = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${slot.id}/subject?contact=${token}`,
|
||||
let unconfirmed = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/subject?contact=${token}`,
|
||||
{ method: 'PUT', body: JSON.stringify(subject) });
|
||||
checkResponse(unconfirmed);
|
||||
|
||||
let confirmed = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${slot.id}/confirmed?contact=${token}`,
|
||||
let confirmed = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/confirmed?contact=${token}`,
|
||||
{ method: 'PUT', body: JSON.stringify('confirmed') });
|
||||
checkResponse(confirmed);
|
||||
return slot.id;
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function addContactRing(server, token, call) {
|
||||
let ring = await fetchWithTimeout(`https://${server}/talk/rings?contact=${token}`, { method: 'POST', body: JSON.stringify(call) });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let ring = await fetchWithTimeout(`${protocol}://${server}/talk/rings?contact=${token}`, { method: 'POST', body: JSON.stringify(call) });
|
||||
checkResponse(ring);
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,15 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function addFlag(server, guid, channel, topic) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
if (channel) {
|
||||
const param = topic ? `&topic=${topic}` : '';
|
||||
const flag = await fetchWithTimeout(`https://${server}/account/flag/${guid}?channel=${channel}${param}`, { method: 'POST' } );
|
||||
const flag = await fetchWithTimeout(`${protocol}://${server}/account/flag/${guid}?channel=${channel}${param}`, { method: 'POST' } );
|
||||
checkResponse(flag);
|
||||
}
|
||||
else {
|
||||
const flag = await fetchWithTimeout(`https://${server}/account/flag/${guid}`, { method: 'POST' } );
|
||||
const flag = await fetchWithTimeout(`${protocol}://${server}/account/flag/${guid}`, { method: 'POST' } );
|
||||
checkResponse(flag);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function clearChannelCard(server, token, channelId, cardId ) {
|
||||
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/cards/${cardId}?agent=${token}`, {method: 'DELETE'});
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/cards/${cardId}?agent=${token}`, {method: 'DELETE'});
|
||||
checkResponse(channel);
|
||||
return await channel.json();
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
import base64 from 'react-native-base64'
|
||||
|
||||
export async function clearLogin(server, token) {
|
||||
let logout = await fetchWithTimeout(`https://${server}/account/apps?agent=${token}`, { method: 'DELETE' })
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let logout = await fetchWithTimeout(`${protocol}://${server}/account/apps?agent=${token}`, { method: 'DELETE' })
|
||||
checkResponse(logout)
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
import base64 from 'react-native-base64'
|
||||
|
||||
export async function createAccount(username, password) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let headers = new Headers()
|
||||
headers.append('Credentials', 'Basic ' + base64.encode(username + ":" + password));
|
||||
let profile = await fetchWithTimeout("/account/profile", { method: 'POST', headers: headers })
|
||||
|
@ -1,4 +1,6 @@
|
||||
export function getAccountImageUrl(server, token, accountId) {
|
||||
return `https://${server}/admin/accounts/${accountId}/image?token=${token}`
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
return `${protocol}://${server}/admin/accounts/${accountId}/image?token=${token}`
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getAccountStatus(server, token) {
|
||||
let status = await fetchWithTimeout(`https://${server}/account/status?agent=${token}`, { method: 'GET' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let status = await fetchWithTimeout(`${protocol}://${server}/account/status?agent=${token}`, { method: 'GET' });
|
||||
checkResponse(status);
|
||||
return await status.json()
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getAvailable(server) {
|
||||
let available = await fetchWithTimeout(`https://${server}/account/available`, { method: 'GET' })
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let available = await fetchWithTimeout(`${protocol}://${server}/account/available`, { method: 'GET' })
|
||||
checkResponse(available)
|
||||
return await available.json()
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getCard(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 param = "?agent=" + token
|
||||
let card = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}${param}`, { method: 'GET' });
|
||||
let card = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}${param}`, { method: 'GET' });
|
||||
checkResponse(card);
|
||||
return await card.json()
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getCardCloseMessage(server, token, cardId) {
|
||||
let message = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/closeMessage?agent=${token}`, { method: 'GET' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let message = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/closeMessage?agent=${token}`, { method: 'GET' });
|
||||
checkResponse(message);
|
||||
return await message.json();
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getCardDetail(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 param = "?agent=" + token
|
||||
let detail = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/detail${param}`, { method: 'GET' });
|
||||
let detail = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/detail${param}`, { method: 'GET' });
|
||||
checkResponse(detail);
|
||||
return await detail.json()
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
export function getCardImageUrl(server, token, cardId, revision) {
|
||||
return `https://${server}/contact/cards/${cardId}/profile/image?agent=${token}&revision=${revision}`
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
return `${protocol}://${server}/contact/cards/${cardId}/profile/image?agent=${token}&revision=${revision}`
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getCardOpenMessage(server, token, cardId) {
|
||||
let message = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/openMessage?agent=${token}`, { method: 'GET' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let message = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/openMessage?agent=${token}`, { method: 'GET' });
|
||||
checkResponse(message);
|
||||
return await message.json();
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getCardProfile(server, token, cardId) {
|
||||
let profile = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/profile?agent=${token}`, { method: 'GET' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let profile = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/profile?agent=${token}`, { method: 'GET' });
|
||||
checkResponse(profile);
|
||||
return await profile.json()
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getCards(server, token, revision) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let param = "agent=" + token
|
||||
if (revision != null) {
|
||||
param += '&revision=' + revision
|
||||
}
|
||||
let cards = await fetchWithTimeout(`https://${server}/contact/cards?${param}`, { method: 'GET' });
|
||||
let cards = await fetchWithTimeout(`${protocol}://${server}/contact/cards?${param}`, { method: 'GET' });
|
||||
checkResponse(cards)
|
||||
return await cards.json()
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getChannelDetail(server, token, channelId) {
|
||||
let detail = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/detail?agent=${token}`, { method: 'GET' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let detail = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/detail?agent=${token}`, { method: 'GET' });
|
||||
checkResponse(detail)
|
||||
return await detail.json()
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getChannelNotifications(server, token, channelId) {
|
||||
const notify = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/notification?agent=${token}`, { method: 'GET' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
const notify = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/notification?agent=${token}`, { method: 'GET' });
|
||||
checkResponse(notify)
|
||||
return await notify.json()
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getChannelSummary(server, token, channelId) {
|
||||
let summary = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/summary?agent=${token}`, { method: 'GET' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let summary = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/summary?agent=${token}`, { method: 'GET' });
|
||||
checkResponse(summary)
|
||||
return await summary.json()
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getChannelTopic(server, token, channelId, topicId) {
|
||||
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${topicId}/detail?agent=${token}`,
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${topicId}/detail?agent=${token}`,
|
||||
{ method: 'GET' });
|
||||
checkResponse(topic)
|
||||
return await topic.json()
|
||||
|
@ -1,4 +1,6 @@
|
||||
export function getChannelTopicAssetUrl(server, token, channelId, topicId, assetId) {
|
||||
return `https://${server}/content/channels/${channelId}/topics/${topicId}/assets/${assetId}?agent=${token}`
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
return `${protocol}://${server}/content/channels/${channelId}/topics/${topicId}/assets/${assetId}?agent=${token}`
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getChannelTopics(server, token, channelId, revision, count, begin, end) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let rev = ''
|
||||
if (revision != null) {
|
||||
@ -18,7 +20,7 @@ export async function getChannelTopics(server, token, channelId, revision, count
|
||||
if (end != null) {
|
||||
edn = `&end=${end}`
|
||||
}
|
||||
let topics = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?agent=${token}${rev}${cnt}${bgn}${edn}`,
|
||||
let topics = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?agent=${token}${rev}${cnt}${bgn}${edn}`,
|
||||
{ method: 'GET' });
|
||||
checkResponse(topics)
|
||||
return {
|
||||
|
@ -1,12 +1,14 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getChannels(server, token, revision) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let param = "?agent=" + token
|
||||
if (revision != null) {
|
||||
param += `&channelRevision=${revision}`
|
||||
}
|
||||
param += `&types=${encodeURIComponent(JSON.stringify(['sealed','superbasic']))}`;
|
||||
let channels = await fetchWithTimeout(`https://${server}/content/channels${param}`, { method: 'GET' });
|
||||
let channels = await fetchWithTimeout(`${protocol}://${server}/content/channels${param}`, { method: 'GET' });
|
||||
checkResponse(channels)
|
||||
let ret = await channels.json()
|
||||
return ret;
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getContactChannelDetail(server, token, channelId) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let host = "";
|
||||
if (server) {
|
||||
host = `https://${server}`;
|
||||
host = `${protocol}://${server}`;
|
||||
}
|
||||
let detail = await fetchWithTimeout(`${host}/content/channels/${channelId}/detail?contact=${token}`, { method: 'GET' });
|
||||
checkResponse(detail)
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getContactChannelNotifications(server, token, channelId) {
|
||||
const notify = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/notification?contact=${token}`, { method: 'GET' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
const notify = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/notification?contact=${token}`, { method: 'GET' });
|
||||
checkResponse(notify)
|
||||
return await notify.json()
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getContactChannelSummary(server, token, channelId) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let host = "";
|
||||
if (server) {
|
||||
host = `https://${server}`;
|
||||
host = `${protocol}://${server}`;
|
||||
}
|
||||
let summary = await fetchWithTimeout(`${host}/content/channels/${channelId}/summary?contact=${token}`, { method: 'GET' });
|
||||
checkResponse(summary)
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getContactChannelTopic(server, token, channelId, topicId) {
|
||||
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${topicId}/detail?contact=${token}`,
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${topicId}/detail?contact=${token}`,
|
||||
{ method: 'GET' });
|
||||
checkResponse(topic)
|
||||
return await topic.json()
|
||||
|
@ -1,4 +1,6 @@
|
||||
export function getContactChannelTopicAssetUrl(server, token, channelId, topicId, assetId) {
|
||||
return `https://${server}/content/channels/${channelId}/topics/${topicId}/assets/${assetId}?contact=${token}`
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
return `${protocol}://${server}/content/channels/${channelId}/topics/${topicId}/assets/${assetId}?contact=${token}`
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getContactChannelTopics(server, token, channelId, revision, count, begin, end) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let rev = ''
|
||||
if (revision != null) {
|
||||
@ -18,7 +20,7 @@ export async function getContactChannelTopics(server, token, channelId, revision
|
||||
if (end != null) {
|
||||
edn = `&end=${end}`
|
||||
}
|
||||
let topics = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?contact=${token}${rev}${cnt}${bgn}${edn}`,
|
||||
let topics = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?contact=${token}${rev}${cnt}${bgn}${edn}`,
|
||||
{ method: 'GET' });
|
||||
checkResponse(topics)
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getContactChannels(server, token, viewRevision, channelRevision) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let param = "?contact=" + token
|
||||
if (viewRevision != null) {
|
||||
param += `&viewRevision=${viewRevision}`;
|
||||
@ -9,7 +12,7 @@ export async function getContactChannels(server, token, viewRevision, channelRev
|
||||
param += `&channelRevision=${channelRevision}`;
|
||||
}
|
||||
param += `&types=${encodeURIComponent(JSON.stringify(['sealed','superbasic']))}`;
|
||||
let channels = await fetchWithTimeout(`https://${server}/content/channels${param}`, { method: 'GET' });
|
||||
let channels = await fetchWithTimeout(`${protocol}://${server}/content/channels${param}`, { method: 'GET' });
|
||||
checkResponse(channels)
|
||||
return await channels.json()
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getContactProfile(server, token) {
|
||||
let profile = await fetchWithTimeout(`https://${server}/profile/message?contact=${token}`, { method: 'GET', });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let profile = await fetchWithTimeout(`${protocol}://${server}/profile/message?contact=${token}`, { method: 'GET', });
|
||||
checkResponse(profile);
|
||||
return await profile.json()
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getGroups(token, revision) {
|
||||
export async function getGroups(server, token, revision) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let param = "agent=" + token
|
||||
if (revision != null) {
|
||||
param += '&revision=' + revision
|
||||
}
|
||||
let groups = await fetchWithTimeout(`/alias/groups?${param}`, { method: 'GET' });
|
||||
let groups = await fetchWithTimeout(`${protocol}://server/alias/groups?${param}`, { method: 'GET' });
|
||||
checkResponse(groups)
|
||||
return await groups.json()
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getHandle(server, token, name) {
|
||||
let available = await fetchWithTimeout(`https://${server}/account/username?agent=${token}&name=${encodeURIComponent(name)}`, { method: 'GET' })
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let available = await fetchWithTimeout(`${protocol}://${server}/account/username?agent=${token}&name=${encodeURIComponent(name)}`, { method: 'GET' })
|
||||
checkResponse(available)
|
||||
return await available.json()
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getListing(server, filter) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
const param = filter ? `?filter=${filter}` : '';
|
||||
let listing = await fetchWithTimeout(`https://${server}/account/listing${param}`, { method: 'GET' });
|
||||
let listing = await fetchWithTimeout(`${protocol}://${server}/account/listing${param}`, { method: 'GET' });
|
||||
checkResponse(listing);
|
||||
return await listing.json();
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
export function getListingImageUrl(server, guid) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let host = "";
|
||||
if (server) {
|
||||
host = `https://${server}`;
|
||||
host = `${protocol}://${server}`;
|
||||
}
|
||||
|
||||
return `${host}/account/listing/${guid}/image`
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getListingMessage(server, guid) {
|
||||
let listing = await fetchWithTimeout(`https://${server}/account/listing/${guid}/message`, { method: 'GET' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let listing = await fetchWithTimeout(`${protocol}://${server}/account/listing/${guid}/message`, { method: 'GET' });
|
||||
checkResponse(listing);
|
||||
return await listing.json();
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getNodeAccounts(server, token) {
|
||||
let accounts = await fetchWithTimeout(`https://${server}/admin/accounts?token=${token}`, { method: 'GET' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let accounts = await fetchWithTimeout(`${protocol}://${server}/admin/accounts?token=${token}`, { method: 'GET' });
|
||||
checkResponse(accounts);
|
||||
return await accounts.json();
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getNodeConfig(server, token) {
|
||||
let config = await fetchWithTimeout(`https://${server}/admin/config?token=${token}`, { method: 'GET' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let config = await fetchWithTimeout(`${protocol}://${server}/admin/config?token=${token}`, { method: 'GET' });
|
||||
checkResponse(config);
|
||||
return await config.json();
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getNodeStatus(server) {
|
||||
let status = await fetchWithTimeout(`https://${server}/admin/status`, { method: 'GET' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let status = await fetchWithTimeout(`${protocol}://${server}/admin/status`, { method: 'GET' });
|
||||
checkResponse(status);
|
||||
return await status.json();
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getProfile(server, token) {
|
||||
let profile = await fetchWithTimeout(`https://${server}/profile?agent=${token}`, { method: 'GET' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let profile = await fetchWithTimeout(`${protocol}://${server}/profile?agent=${token}`, { method: 'GET' });
|
||||
checkResponse(profile)
|
||||
return await profile.json()
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
export function getProfileImageUrl(server, token, revision) {
|
||||
return `https://${server}/profile/image?agent=${token}&revision=${revision}`;
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
return `${protocol}://${server}/profile/image?agent=${token}&revision=${revision}`;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function getUsername(name, server, token) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let query = "";
|
||||
if (token && name) {
|
||||
query = `?name=${encodeURIComponent(name)}&token=${token}`;
|
||||
@ -12,7 +15,7 @@ export async function getUsername(name, server, token) {
|
||||
query = `?token=${token}`;
|
||||
}
|
||||
|
||||
let available = await fetchWithTimeout(`https://${server}/account/username${query}`, { method: 'GET' })
|
||||
let available = await fetchWithTimeout(`${protocol}://${server}/account/username${query}`, { method: 'GET' })
|
||||
checkResponse(available)
|
||||
return await available.json()
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function keepCall(server, token, callId) {
|
||||
let call = await fetchWithTimeout(`https://${server}/talk/calls/${callId}?agent=${token}`, { method: 'PUT' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let call = await fetchWithTimeout(`${protocol}://${server}/talk/calls/${callId}?agent=${token}`, { method: 'PUT' });
|
||||
checkResponse(call);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function removeAccount(server, token, accountId) {
|
||||
let res = await fetchWithTimeout(`https://${server}/admin/accounts/${accountId}?token=${token}`, { method: 'DELETE' })
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let res = await fetchWithTimeout(`${protocol}://${server}/admin/accounts/${accountId}?token=${token}`, { method: 'DELETE' })
|
||||
checkResponse(res);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function removeCall(server, token, callId) {
|
||||
let call = await fetchWithTimeout(`https://${server}/talk/calls/${callId}?agent=${token}`, { method: 'DELETE' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let call = await fetchWithTimeout(`${protocol}://${server}/talk/calls/${callId}?agent=${token}`, { method: 'DELETE' });
|
||||
checkResponse(call)
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function removeCard(server, token, cardId) {
|
||||
let card = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}?agent=${token}`, { method: 'DELETE' } );
|
||||
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}?agent=${token}`, { method: 'DELETE' } );
|
||||
checkResponse(card);
|
||||
return await card.json();
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function removeChannel(server, token, channelId) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}?agent=${token}`,
|
||||
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}?agent=${token}`,
|
||||
{ method: 'DELETE' });
|
||||
checkResponse(channel);
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function removeChannelTopic(server, token, channelId, topicId) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${topicId}?agent=${token}`,
|
||||
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${topicId}?agent=${token}`,
|
||||
{ method: 'DELETE' });
|
||||
checkResponse(channel);
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function removeContactCall(server, token, callId) {
|
||||
const call = await fetchWithTimeout(`https://${server}/talk/calls/${callId}?contact=${token}`, { method: 'DELETE' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
const call = await fetchWithTimeout(`${protocol}://${server}/talk/calls/${callId}?contact=${token}`, { method: 'DELETE' });
|
||||
checkResponse(call);
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function removeContactChannel(server, token, channelId) {
|
||||
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}?contact=${token}`,
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}?contact=${token}`,
|
||||
{ method: 'DELETE' });
|
||||
checkResponse(channel);
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function removeContactChannelTopic(server, token, channelId, topicId) {
|
||||
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${topicId}?contact=${token}`,
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${topicId}?contact=${token}`,
|
||||
{ method: 'DELETE' });
|
||||
checkResponse(channel);
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function removeProfile(server, token) {
|
||||
let profile = await fetchWithTimeout(`https://${server}/profile?agent=${token}`, { method: 'DELETE' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let profile = await fetchWithTimeout(`${protocol}://${server}/profile?agent=${token}`, { method: 'DELETE' });
|
||||
checkResponse(profile)
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setAccountAccess(server, token, appName, appVersion, platform, deviceToken, pushType, notifications) {
|
||||
let access = await fetchWithTimeout(`https://${server}/account/access?token=${token}&appName=${appName}&appVersion=${appVersion}&platform=${platform}&deviceToken=${deviceToken}&pushType=${pushType}`, { method: 'PUT', body: JSON.stringify(notifications) })
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let access = await fetchWithTimeout(`${protocol}://${server}/account/access?token=${token}&appName=${appName}&appVersion=${appVersion}&platform=${platform}&deviceToken=${deviceToken}&pushType=${pushType}`, { method: 'PUT', body: JSON.stringify(notifications) })
|
||||
checkResponse(access)
|
||||
return await access.json()
|
||||
}
|
||||
|
@ -2,9 +2,12 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
import base64 from 'react-native-base64'
|
||||
|
||||
export async function setAccountLogin(server, token, username, password) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let headers = new Headers()
|
||||
headers.append('Credentials', 'Basic ' + base64.encode(username + ":" + password));
|
||||
let res = await fetchWithTimeout(`https://${server}/account/login?agent=${token}`, { method: 'PUT', headers })
|
||||
let res = await fetchWithTimeout(`${protocol}://${server}/account/login?agent=${token}`, { method: 'PUT', headers })
|
||||
checkResponse(res);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setAccountNotifications(server, token, flag) {
|
||||
let res = await fetchWithTimeout(`https://${server}/account/notification?agent=${token}`, { method: 'PUT', body: JSON.stringify(flag) })
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let res = await fetchWithTimeout(`${protocol}://${server}/account/notification?agent=${token}`, { method: 'PUT', body: JSON.stringify(flag) })
|
||||
checkResponse(res);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setAccountSeal(server, token, seal) {
|
||||
let res = await fetchWithTimeout(`https://${server}/account/seal?agent=${token}`, { method: 'PUT', body: JSON.stringify(seal) })
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let res = await fetchWithTimeout(`${protocol}://${server}/account/seal?agent=${token}`, { method: 'PUT', body: JSON.stringify(seal) })
|
||||
checkResponse(res);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setAccountSearchable(server, token, flag) {
|
||||
let res = await fetchWithTimeout(`https://${server}/account/searchable?agent=${token}`, { method: 'PUT', body: JSON.stringify(flag) })
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let res = await fetchWithTimeout(`${protocol}://${server}/account/searchable?agent=${token}`, { method: 'PUT', body: JSON.stringify(flag) })
|
||||
checkResponse(res);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setAccountStatus(server, token, accountId, disabled) {
|
||||
let res = await fetchWithTimeout(`https://${server}/admin/accounts/${accountId}/status?token=${token}`, { method: 'PUT', body: JSON.stringify(disabled) })
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let res = await fetchWithTimeout(`${protocol}://${server}/admin/accounts/${accountId}/status?token=${token}`, { method: 'PUT', body: JSON.stringify(disabled) })
|
||||
checkResponse(res);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setCardCloseMessage(server, message) {
|
||||
let status = await fetchWithTimeout(`https://${server}/contact/closeMessage`, { method: 'PUT', body: JSON.stringify(message) });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let status = await fetchWithTimeout(`${protocol}://${server}/contact/closeMessage`, { method: 'PUT', body: JSON.stringify(message) });
|
||||
checkResponse(status);
|
||||
return await status.json();
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setCardOpenMessage(server, message) {
|
||||
let status = await fetchWithTimeout(`https://${server}/contact/openMessage`, { method: 'PUT', body: JSON.stringify(message) });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let status = await fetchWithTimeout(`${protocol}://${server}/contact/openMessage`, { method: 'PUT', body: JSON.stringify(message) });
|
||||
checkResponse(status);
|
||||
return await status.json();
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setCardProfile(server, token, cardId, message) {
|
||||
let profile = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/profile?agent=${token}`, { method: 'PUT', body: JSON.stringify(message) });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let profile = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/profile?agent=${token}`, { method: 'PUT', body: JSON.stringify(message) });
|
||||
checkResponse(profile);
|
||||
return await profile.json()
|
||||
}
|
||||
|
@ -1,19 +1,22 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setCardConnecting(server, token, cardId) {
|
||||
let card = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/status?agent=${token}`, { method: 'PUT', body: JSON.stringify('connecting') } );
|
||||
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('connecting') } );
|
||||
checkResponse(card);
|
||||
return await card.json();
|
||||
}
|
||||
|
||||
export async function setCardConnected(server, token, cardId, access, view, article, channel, profile) {
|
||||
let card = await fetchWithTimeout(`https://${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);
|
||||
return await card.json();
|
||||
}
|
||||
|
||||
export async function setCardConfirmed(server, token, cardId) {
|
||||
let card = await fetchWithTimeout(`https://${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);
|
||||
return await card.json();
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setChannelCard(server, token, channelId, cardId ) {
|
||||
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/cards/${cardId}?agent=${token}`, {method: 'PUT'});
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/cards/${cardId}?agent=${token}`, {method: 'PUT'});
|
||||
checkResponse(channel);
|
||||
return await channel.json();
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setChannelNotifications(server, token, channelId, flag) {
|
||||
const notify = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/notification?agent=${token}`, { method: 'PUT', body: JSON.stringify(flag) });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
const notify = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/notification?agent=${token}`, { method: 'PUT', body: JSON.stringify(flag) });
|
||||
checkResponse(notify)
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setChannelSubject(server, token, channelId, dataType, data ) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let params = { dataType, data: JSON.stringify(data) };
|
||||
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/subject?agent=${token}`, { method: 'PUT', body: JSON.stringify(params)} );
|
||||
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/subject?agent=${token}`, { method: 'PUT', body: JSON.stringify(params)} );
|
||||
checkResponse(channel);
|
||||
return await channel.json();
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setChannelTopicSubject(token, channelId, topicId, asset) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
if (asset.image) {
|
||||
const formData = new FormData();
|
||||
formData.append('asset', asset.image);
|
||||
|
@ -1,11 +1,14 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setChannelTopicSubject(server, token, channelId, topicId, dataType, data) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let subject = { data: JSON.stringify(data, (key, value) => {
|
||||
if (value !== null) return value
|
||||
}), datatype: dataType };
|
||||
|
||||
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${topicId}/subject?agent=${token}&confirm=true`,
|
||||
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${topicId}/subject?agent=${token}&confirm=true`,
|
||||
{ method: 'PUT', body: JSON.stringify(subject) });
|
||||
checkResponse(channel);
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setContactChannelNotifications(server, token, channelId, flag) {
|
||||
const notify = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/notification?contact=${token}`, { method: 'PUT', body: JSON.stringify(flag) });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
const notify = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/notification?contact=${token}`, { method: 'PUT', body: JSON.stringify(flag) });
|
||||
checkResponse(notify)
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setContactChannelTopicSubject(server, token, channelId, topicId, asset) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let host = "";
|
||||
if (server) {
|
||||
host = `https://${server}`;
|
||||
host = `${protocol}://${server}`;
|
||||
}
|
||||
|
||||
if (asset.image) {
|
||||
|
@ -1,11 +1,14 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setContactChannelTopicSubject(server, token, channelId, topicId, dataType, data) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let subject = { data: JSON.stringify(data, (key, value) => {
|
||||
if (value !== null) return value
|
||||
}), datatype: dataType };
|
||||
|
||||
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${topicId}/subject?contact=${token}&confirm=true`,
|
||||
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${topicId}/subject?contact=${token}&confirm=true`,
|
||||
{ method: 'PUT', body: JSON.stringify(subject) });
|
||||
checkResponse(channel);
|
||||
}
|
||||
|
@ -2,9 +2,12 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
import base64 from 'react-native-base64'
|
||||
|
||||
export async function setLogin(username, server, password, appName, appVersion, platform, deviceToken, pushType, notifications) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let headers = new Headers()
|
||||
headers.append('Authorization', 'Basic ' + base64.encode(username + ":" + password));
|
||||
let login = await fetchWithTimeout(`https://${server}/account/apps?appName=${appName}&appVersion=${appVersion}&platform=${platform}&deviceToken=${deviceToken}&pushType=${pushType}`, { method: 'POST', body: JSON.stringify(notifications), headers: headers })
|
||||
let login = await fetchWithTimeout(`${protocol}://${server}/account/apps?appName=${appName}&appVersion=${appVersion}&platform=${platform}&deviceToken=${deviceToken}&pushType=${pushType}`, { method: 'POST', body: JSON.stringify(notifications), headers: headers })
|
||||
checkResponse(login)
|
||||
return await login.json()
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setNodeConfig(server, token, config) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let body = JSON.stringify(config);
|
||||
let settings = await fetchWithTimeout(`https://${server}/admin/config?token=${token}`, { method: 'PUT', body });
|
||||
let settings = await fetchWithTimeout(`${protocol}://${server}/admin/config?token=${token}`, { method: 'PUT', body });
|
||||
checkResponse(settings);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setNodeStatus(server, token) {
|
||||
let status = await fetchWithTimeout(`https://${server}/admin/status?token=${token}`, { method: 'PUT' });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let status = await fetchWithTimeout(`${protocol}://${server}/admin/status?token=${token}`, { method: 'PUT' });
|
||||
checkResponse(status);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setProfileData(server, token, name, location, description) {
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let data = { name: name, location: location, description: description };
|
||||
let profile = await fetchWithTimeout(`https://${server}/profile/data?agent=${token}`, { method: 'PUT', body: JSON.stringify(data) });
|
||||
let profile = await fetchWithTimeout(`${protocol}://${server}/profile/data?agent=${token}`, { method: 'PUT', body: JSON.stringify(data) });
|
||||
checkResponse(profile)
|
||||
return await profile.json()
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setProfileImage(server, token, image) {
|
||||
let profile = await fetchWithTimeout(`https://${server}/profile/image?agent=${token}`, { method: 'PUT', body: JSON.stringify(image) });
|
||||
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
|
||||
const protocol = insecure ? 'http' : 'https';
|
||||
|
||||
let profile = await fetchWithTimeout(`${protocol}://${server}/profile/image?agent=${token}`, { method: 'PUT', body: JSON.stringify(image) });
|
||||
checkResponse(profile)
|
||||
return await profile.json()
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ export function useAddMember(item, members) {
|
||||
useEffect(() => {
|
||||
const { cardId, revision, profile } = item;
|
||||
const { name, handle, node } = profile;
|
||||
updateState({ cardId, name, handle: `${handle}@${node}`,
|
||||
updateState({ cardId, name, handle: `${handle}/${node}`,
|
||||
logo: profile.imageSet ? card.actions.getCardImageUrl(cardId) : 'avatar' });
|
||||
}, [card.state]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user