Implement MessageSender
parent
cbc32b9989
commit
1dad49057b
@ -0,0 +1,25 @@
|
||||
import {
|
||||
Quote,
|
||||
AttachmentPointer,
|
||||
Preview,
|
||||
} from '../../ts/session/messages/outgoing';
|
||||
|
||||
declare class LokiAppDotNetServerAPI {
|
||||
constructor(ourKey: string, url: string);
|
||||
findOrCreateChannel(
|
||||
api: LokiPublicChatFactoryAPI,
|
||||
channelId: number,
|
||||
conversationId: string
|
||||
): Promise<LokiPublicChannelAPI>;
|
||||
}
|
||||
|
||||
export interface LokiPublicChannelAPI {
|
||||
sendMessage(data: {
|
||||
quote?: Quote;
|
||||
attachments: Array<AttachmentPointer>;
|
||||
preview: Array<Preview>;
|
||||
body?: string;
|
||||
}): Promise<boolean>;
|
||||
}
|
||||
|
||||
export default LokiAppDotNetServerAPI;
|
@ -0,0 +1,11 @@
|
||||
declare class LokiMessageAPI {
|
||||
constructor(ourKey: string);
|
||||
sendMessage(
|
||||
pubKey: string,
|
||||
data: Uint8Array,
|
||||
messageTimeStamp: number,
|
||||
ttl: number
|
||||
): Promise<void>;
|
||||
}
|
||||
|
||||
export default LokiMessageAPI;
|
@ -0,0 +1,13 @@
|
||||
import { LokiPublicChannelAPI } from './loki_app_dot_net_api';
|
||||
|
||||
declare class LokiPublicChatFactoryAPI {
|
||||
constructor(ourKey: string);
|
||||
findOrCreateServer(url: string): Promise<void>;
|
||||
findOrCreateChannel(
|
||||
url: string,
|
||||
channelId: number,
|
||||
conversationId: string
|
||||
): Promise<LokiPublicChannelAPI>;
|
||||
}
|
||||
|
||||
export default LokiPublicChatFactoryAPI;
|
@ -1,32 +1,41 @@
|
||||
import { Message, MessageParams } from './Message';
|
||||
import { AttachmentType } from '../../../types/Attachment';
|
||||
import { QuotedAttachmentType } from '../../../components/conversation/Quote';
|
||||
import { AttachmentPointer, Preview, Quote } from './content';
|
||||
|
||||
interface OpenGroupMessageParams extends MessageParams {
|
||||
interface OpenGroup {
|
||||
server: string;
|
||||
attachments?: Array<AttachmentType>;
|
||||
channel: number;
|
||||
conversationId: string;
|
||||
}
|
||||
|
||||
interface OpenGroupMessageParams extends MessageParams {
|
||||
group: OpenGroup;
|
||||
attachments: Array<AttachmentPointer>;
|
||||
preview: Array<Preview>;
|
||||
body?: string;
|
||||
quote?: QuotedAttachmentType;
|
||||
quote?: Quote;
|
||||
}
|
||||
|
||||
export class OpenGroupMessage extends Message {
|
||||
public readonly server: string;
|
||||
public readonly group: OpenGroup;
|
||||
public readonly body?: string;
|
||||
public readonly attachments?: Array<AttachmentType>;
|
||||
public readonly quote?: QuotedAttachmentType;
|
||||
public readonly attachments: Array<AttachmentPointer>;
|
||||
public readonly quote?: Quote;
|
||||
public readonly preview: Array<Preview>;
|
||||
|
||||
constructor({
|
||||
timestamp,
|
||||
server,
|
||||
group,
|
||||
attachments,
|
||||
body,
|
||||
quote,
|
||||
identifier,
|
||||
preview,
|
||||
}: OpenGroupMessageParams) {
|
||||
super({ timestamp, identifier });
|
||||
this.server = server;
|
||||
this.group = group;
|
||||
this.body = body;
|
||||
this.attachments = attachments;
|
||||
this.quote = quote;
|
||||
this.preview = preview;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue