mirror of
https://github.com/balzack/databag.git
synced 2025-04-24 02:25:26 +00:00
cleanup on content api
This commit is contained in:
parent
a733a2246f
commit
d1215afee2
@ -293,46 +293,10 @@ Automate allocates the Bot interface for ia specific communication channel
|
||||
|
||||
```Contact::cancelCard(cardId: string): Promise<void>```
|
||||
|
||||
The current articles can be access with an [Article](https://github.com/balzack/databag/blob/sdk/app/sdk/src/types.ts) listener
|
||||
|
||||
```Contact::addArticleListener(id: string | null, ev: (arg: { cardId: string; articles: Article[] }) => void): void```
|
||||
|
||||
```Contact::removeArticleListener(id: string | null, ev: (arg: { cardId: string; articles: Article[] }) => void): void```
|
||||
|
||||
Relinquish access to shared article
|
||||
|
||||
```Contact::removeArticle(cardId: string): Promise<void>```
|
||||
|
||||
The current channels can be access with a [Channel](https://github.com/balzack/databag/blob/sdk/app/sdk/src/types.ts) listener
|
||||
|
||||
```Contact::addChannelListener(id: string | null, ev: (arg: { cardId: string; channels: Channel[] }) => void): void```
|
||||
|
||||
```Contact::removeChannelListener(id: string | null, ev: (arg: { cardId: string; channels: Channel[] }) => void): void```
|
||||
|
||||
Relinquish access to shared channel
|
||||
|
||||
```Contact::removeChannel(cardId: string): Promise<void>```
|
||||
|
||||
Enable or disable push notification associated with specified contact channel
|
||||
|
||||
```Contact::setChannelNotifications(cardId: string, channelId: string, enabled: boolean): Promise<void>```
|
||||
|
||||
Get whether notifications are enabled on specified contact channel
|
||||
|
||||
```Contact::getChannelNotifications(cardId: string, channelId: string): Promise<boolean>```
|
||||
|
||||
Mark contact channel as read or unread with setUnreadChannel
|
||||
|
||||
```Contact::setUnreadChannel(cardId: string, channelId: string, unread: boolean): Promise<void>```
|
||||
|
||||
Get list of searchable accounts of specified server with getRegistry
|
||||
|
||||
```Contact::getRegistry(server: string, secure: boolean): Promise<Profile[]>```
|
||||
|
||||
Get URL of profile image for searchable contact on specified server
|
||||
|
||||
```Contact::getRegistryImageUrl(server: string, secure: boolean, guid: string): string```
|
||||
|
||||
Block or unblock contact to hide locally with setBlockedCard
|
||||
|
||||
```Contact::setBlockedCard(cardId: string, boolean: blocked): Promise<void>```
|
||||
@ -345,35 +309,74 @@ Automate allocates the Bot interface for ia specific communication channel
|
||||
|
||||
```Contact::flagCard(cardId: string): Promise<void>```
|
||||
|
||||
Block or unblock contact article to hide locallay with setBlockedArticle
|
||||
</ul>
|
||||
|
||||
```Contact::setBlockedArticle(cardId: string, articleId: string, boolean: blocked): Promise<void>```
|
||||
<br>
|
||||
</details>
|
||||
|
||||
Get list of all blocked contact articles with getBlockedArticles
|
||||
<details>
|
||||
<summary>Contact interface module manages contacts and the shared articles and channels</summary><br>
|
||||
|
||||
```Contact::getBlockedArticles(): Promise<Article[]>```
|
||||
<ul>
|
||||
|
||||
Flag article for review by admin with flagArticle
|
||||
The current channels can be access with a [Channel](https://github.com/balzack/databag/blob/sdk/app/sdk/src/types.ts) listener
|
||||
|
||||
```Contact::flagArticle(cardId: string, articleId: string): Promise<void>```
|
||||
```Content::addChannelListener(ev: (arg: { channels: Channel[], cardId: string | null }) => void): void```
|
||||
|
||||
Block or unblock contact channel with setBlockedChanenl
|
||||
```Content::removeChannelListener(ev: (arg: { channels: Channel[], cardId: string | null }) => void): void```
|
||||
|
||||
```Contact::setBlockedChannel(cardId: string, channelId: string, boolean: blocked): Promise<void>```
|
||||
Add a new channel shared with specified contacts with addChannel
|
||||
|
||||
Get list of all blocked contact channels with getBlockedChannels
|
||||
```Content::addChannel(sealed: boolean, type: string, subject: any, cardIds: string[]): Promise<string>```
|
||||
|
||||
```Contact::getBlockedChannels(): Promise<Channel[]>```
|
||||
Remove a hosted channel with removeChannel
|
||||
|
||||
```Content::removeChannel(channelId: string): Promise<void>```
|
||||
|
||||
Leave a channel hosted by a contact with leaveChannel
|
||||
|
||||
```Content::leaveChannel(cardId: string, channelId: string): Promise<void>```
|
||||
|
||||
Update the subject on specified channel
|
||||
|
||||
```Content::setChannelSubject(channelId: string, subject: string): Promise<void>```
|
||||
|
||||
Add member to specified channel
|
||||
|
||||
```Content::setChannelCard(channelId: string, cardId: string): Promise<void>```
|
||||
|
||||
Remove member from specified channel
|
||||
|
||||
```Content::clearChannelCard(channelId: string, cardId: string): Promise<void>```
|
||||
|
||||
Enable or disable push notification associated with specified channel
|
||||
|
||||
```Content::setChannelNotifications(cardId: string | null, channelId: string, enabled: boolean): Promise<void>```
|
||||
|
||||
Get whether notifications are enabled on specified channel
|
||||
|
||||
```Content::getChannelNotifications(cardId: string | null, channelId: string): Promise<boolean>```
|
||||
|
||||
Mark channel as read or unread with setUnreadChannel
|
||||
|
||||
```Content::setUnreadChannel(cardId: string | null, channelId: string, unread: boolean): Promise<void>```
|
||||
|
||||
Block or unblock channel with setBlockedChannel
|
||||
|
||||
```Content::setBlockedChannel(cardId: string | null, channelId: string, boolean: blocked): Promise<void>```
|
||||
|
||||
Get list of all blocked channels with getBlockedChannels
|
||||
|
||||
```Content::getBlockedChannels(): Promise<Channel[]>```
|
||||
|
||||
Flag channel for review by admin with flagChannel
|
||||
|
||||
```Contact::flagChannel(cardId: string, channelId: string): Promise<void>```
|
||||
```Content::flagChannel(cardId: string | null, channelId: string): Promise<void>```
|
||||
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
</details>
|
||||
|
||||
|
||||
## Admin Communication
|
||||
|
||||
|
@ -88,7 +88,7 @@ export interface Contact {
|
||||
}
|
||||
|
||||
export interface Content {
|
||||
addChannel(sealed: boolean, type: string, subject: string, cardIds: string[]): Promise<string>;
|
||||
addChannel(sealed: boolean, type: string, subject: any, cardIds: string[]): Promise<string>;
|
||||
removeChannel(channelId: string): Promise<void>;
|
||||
setChannelSubject(channelId: string, subject: string): Promise<void>;
|
||||
setChannelCard(channelId: string, cardId: string): Promise<void>;
|
||||
@ -100,7 +100,7 @@ export interface Content {
|
||||
setChannelNotifications(cardId: string | null, channelId: string, enabled: boolean): Promise<void>;
|
||||
setUnreadChannel(cardId: string | null, channelId: string, unread: boolean): Promise<void>;
|
||||
|
||||
flagChannel(cardId: string, channelId: string): Promise<void>;
|
||||
flagChannel(cardId: string | null, channelId: string): Promise<void>;
|
||||
setBlockedChannel(cardId: string | null, channelId: string, blocked: boolean): Promise<void>;
|
||||
getBlockedChannels(): Promise<Channel[]>;
|
||||
|
||||
|
@ -18,7 +18,7 @@ export class ContentModule implements Content {
|
||||
this.crypto = crypto;
|
||||
}
|
||||
|
||||
public async addChannel(sealed: boolean, type: string, subject: string, cardIds: string[]): Promise<string> {
|
||||
public async addChannel(sealed: boolean, type: string, subject: any, cardIds: string[]): Promise<string> {
|
||||
if (sealed) {
|
||||
if (!this.crypto) {
|
||||
throw new Error('crypto not set');
|
||||
@ -77,7 +77,7 @@ export class ContentModule implements Content {
|
||||
return await this.stream.setUnreadChannel(channelId, unread);
|
||||
}
|
||||
|
||||
public async flagChannel(cardId: string, channelId: string): Promise<void> {
|
||||
public async flagChannel(cardId: string | null, channelId: string): Promise<void> {
|
||||
if (cardId) {
|
||||
return await this.contact.flagChannel(cardId, channelId);
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ export class StreamModule {
|
||||
await this.sync();
|
||||
}
|
||||
|
||||
public async addSealedChannel(type: string, subject: string, cardIds: string[], aesKeyHex: string, seals: { publicKey: string, sealedKey: string}[]): Promise<string> {
|
||||
public async addSealedChannel(type: string, subject: any, cardIds: string[], aesKeyHex: string, seals: { publicKey: string, sealedKey: string}[]): Promise<string> {
|
||||
const { node, secure, token, crypto, seal } = this;
|
||||
if (!crypto) {
|
||||
throw new Error('crypto not set');
|
||||
@ -235,14 +235,15 @@ export class StreamModule {
|
||||
}
|
||||
const sealKey = await this.crypto.rsaEncrypt(aesKeyHex, seal.publicKey);
|
||||
const { ivHex } = await crypto.aesIv();
|
||||
const { encryptedDataB64 } = await crypto.aesEncrypt(subject, ivHex, aesKeyHex);
|
||||
const subjectData = JSON.stringify(subject);
|
||||
const { encryptedDataB64 } = await crypto.aesEncrypt(subjectData, ivHex, aesKeyHex);
|
||||
const sealedSubject = { subjectEncrypted: encryptedDataB64, subjectIv: ivHex, seals: [ ...seals, sealKey ] };
|
||||
return await addChannel(node, secure, token, type, sealedSubject, cardIds);
|
||||
}
|
||||
|
||||
public async addUnsealedChannel(type: string, subject: string, cardIds: string[]): Promise<string> {
|
||||
public async addUnsealedChannel(type: string, subject: any, cardIds: string[]): Promise<string> {
|
||||
const { node, secure, token } = this;
|
||||
return await addChannel(node, secure, token, type, { subject }, cardIds);
|
||||
return await addChannel(node, secure, token, type, subject, cardIds);
|
||||
}
|
||||
|
||||
public async removeChannel(channelId: string): Promise<void> {
|
||||
@ -279,11 +280,22 @@ export class StreamModule {
|
||||
|
||||
public async setChannelCard(channelId: string, cardId: string): Promise<void> {
|
||||
const { node, secure, token } = this;
|
||||
const channel = this.channelEntries.get(channelId);
|
||||
if (!channel) {
|
||||
throw new Error('channel not found');
|
||||
}
|
||||
if (channel.item.sealed) {
|
||||
throw new Error('sealed channels cannot add members');
|
||||
}
|
||||
await setChannelCard(node, secure, token, channelId, cardId);
|
||||
}
|
||||
|
||||
public async clearChannelCard(channelId: string, cardId: string): Promise<void> {
|
||||
const { node, secure, token } = this;
|
||||
const channel = this.channelEntries.get(channelId);
|
||||
if (!channel) {
|
||||
throw new Error('channel not found');
|
||||
}
|
||||
await clearChannelCard(node, secure, token, channelid, cardId);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user