You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { DataMessage } from './DataMessage';
|
|
import { SignalService } from '../../../../../protobuf';
|
|
import { MessageParams } from '../../Message';
|
|
import { ChatMessage } from './ChatMessage';
|
|
|
|
interface ClosedGroupChatMessageParams extends MessageParams {
|
|
groupId: string;
|
|
chatMessage: ChatMessage;
|
|
}
|
|
|
|
export class ClosedGroupChatMessage extends DataMessage {
|
|
private readonly groupId: string;
|
|
private readonly chatMessage: ChatMessage;
|
|
|
|
constructor(params: ClosedGroupChatMessageParams) {
|
|
super({
|
|
timestamp: params.timestamp,
|
|
identifier: params.identifier,
|
|
});
|
|
this.groupId = params.groupId;
|
|
this.chatMessage = params.chatMessage;
|
|
}
|
|
|
|
public ttl(): number {
|
|
return this.getDefaultTTL();
|
|
}
|
|
|
|
protected dataProto(): SignalService.DataMessage {
|
|
const messageProto = this.chatMessage.dataProto();
|
|
const id = new TextEncoder().encode(this.groupId);
|
|
const type = SignalService.GroupContext.Type.DELIVER;
|
|
messageProto.group = new SignalService.GroupContext({id, type});
|
|
|
|
return messageProto;
|
|
}
|
|
}
|