mirror of
https://github.com/balzack/databag.git
synced 2025-04-22 09:35:16 +00:00
adding registry methods
This commit is contained in:
parent
15d1eb1618
commit
70e96f171c
@ -1,10 +1,7 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function removeContactChannel(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(`${protocol}://${server}/content/channels/${channelId}?contact=${token}`,
|
||||
{ method: 'DELETE' });
|
||||
checkResponse(channel);
|
||||
export async function removeContactChannel(node: string, secure: boolean, guid: string, token: string, channelId: string) {
|
||||
const endpoint = `http${secure ? 's' : ''}://${node}/content/channels/${channelId}?contact=${guid}.${token}`;
|
||||
const status = await fetchWithTimeout(endpoint, { method: 'DELETE' });
|
||||
checkResponse(status);
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ import { setCardConnected } from "./net/setCardConnected";
|
||||
import { removeContactChannel } from './net/removeContactChannel';
|
||||
import { getContactChannelNotifications } from './net/getContactChannelNotifications';
|
||||
import { setContactChannelNotifications } from './net/setContactChannelNotifications';
|
||||
import { getRegistryImageUrl } from './net/getRegistryImageUrl';
|
||||
import { getRegistryListing } from './net/getRegistryListing';
|
||||
|
||||
const CLOSE_POLL_MS = 100;
|
||||
const RETRY_POLL_MS = 2000;
|
||||
@ -780,12 +782,20 @@ export class ContactModule implements Contact {
|
||||
}
|
||||
}
|
||||
|
||||
public async getRegistry(server: string): Promise<Profile[]> {
|
||||
return [];
|
||||
public async getRegistry(server: string, secure: boolean): Promise<Profile[]> {
|
||||
const listing = await getRegistryListing(server, secure);
|
||||
return listing.map(entity => {
|
||||
const { guid, handle, name, description, location, image, seal, version, node } = entity;
|
||||
return {
|
||||
guid, handle, name, description, location, node, version,
|
||||
sealSet: Boolean(seal),
|
||||
imageSet: Boolean(image),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public getRegistryImageUrl(server: string, guid: string): string {
|
||||
return "";
|
||||
public getRegistryImageUrl(server: string, secure: boolean, guid: string): string {
|
||||
return getRegistryImageUrl(server, secure, guid);
|
||||
}
|
||||
|
||||
public getCardImageUrl(cardId: string): string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user