mirror of
https://github.com/balzack/databag.git
synced 2025-05-02 06:25:18 +00:00
implementing focus module
This commit is contained in:
parent
4075ad184c
commit
0e24bf1bb4
@ -16,7 +16,9 @@ import { getContactChannelTopicDetail } from './net/getContactChannelTopicDetail
|
||||
import { addChannelTopic } from './net/addChannelTopic';
|
||||
import { addContactChannelTopic } from './net/addContactChannelTopic';
|
||||
import { setChannelTopicSubject } from './net/setChannelTopicSubject';
|
||||
import { addContactChannelTopicSubject } from './net/setContactChannelTopicSubject';
|
||||
import { setContactChannelTopicSubject } from './net/setContactChannelTopicSubject';
|
||||
import { removeChannelTopic } from './net/removeChannelTopic';
|
||||
import { removeContactChannelTopic } from './net/removeContactChannelTopic';
|
||||
|
||||
const BATCH_COUNT = 64;
|
||||
const MIN_LOAD_SIZE = 32;
|
||||
@ -1081,6 +1083,19 @@ export class FocusModule implements Focus {
|
||||
}
|
||||
}
|
||||
|
||||
private async removeRemoveChannelTopic(topicId: string) {
|
||||
const { cardId, channelId, connection } = this;
|
||||
if (!connection) {
|
||||
throw new Error('disconnected from channel');
|
||||
}
|
||||
const { node, secure, token } = this.connection;
|
||||
if (cardId) {
|
||||
return await removeContactChannelTopicSubject(node, secure, token, channelId, topicId);
|
||||
} else {
|
||||
return await removeChannelTopic(node, secure, token, channelId, topicId);
|
||||
}
|
||||
}
|
||||
|
||||
private isTopicBlocked(topicId: string): boolean {
|
||||
const { cardId, channelId } = this;
|
||||
const card = cardId ? `"${cardId}"` : 'null';
|
||||
|
7
app/sdk/src/net/removeChannelTopic.ts
Normal file
7
app/sdk/src/net/removeChannelTopic.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function removeChannelTopic(node: string, secure: boolean, token: string, channelId: string, topicId: string): Promise<void> {
|
||||
const endpoint = `http${secure ? 's' : ''}://${node}/content/channels/${channelId}/${topics}/${topicId}?agent=${token}`;
|
||||
const { status } = await fetchWithTimeout(endpoint, { method: 'DELETE' });
|
||||
checkResponse(status);
|
||||
}
|
7
app/sdk/src/net/removeContactChannelTopic.ts
Normal file
7
app/sdk/src/net/removeContactChannelTopic.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function removeContactChannelTopic(node: string, secure: boolean, guidToken: string, channelId: string) {
|
||||
const endpoint = `http${secure ? 's' : ''}://${node}/content/channels/${channelId}/topics/${topicId}?contact=${guidToken}`;
|
||||
const response = await fetchWithTimeout(endpoint, { method: 'DELETE' });
|
||||
checkResponse(response.status);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setContactChannelTopicSubject(node: string, secure: boolean, guidToken: string, channelId: topicId: string, dataType: string, data: any) {
|
||||
export async function setContactChannelTopicSubject(node: string, secure: boolean, guidToken: string, channelId: string, topicId: string, dataType: string, data: any) {
|
||||
const subject = { data: JSON.stringify(data), dataType };
|
||||
const endpoint = `http${secure ? 's' : '' }://${node}/content/channels/${channelId}/topics/${topicId}/subject?contact=${guidToken}&confirm=true`;
|
||||
const { status } = await fetchWithTimeout(endpoint, { method: 'PUT', body: JSON.stringify(subject) });
|
||||
|
Loading…
x
Reference in New Issue
Block a user