mirror of
https://github.com/lux-tel/session-desktop.git
synced 2026-10-30 20:33:24 +00:00
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { SignalService } from '../../../protobuf';
|
|
import { ExpirableMessageNoProfile, ExpirableMessageWithProfile } from './ExpirableMessage';
|
|
|
|
export abstract class DataMessageNoProfile extends ExpirableMessageNoProfile {
|
|
public override contentProto(): SignalService.Content {
|
|
const content = super.makeDisappearingContentProto();
|
|
content.dataMessage = this.dataProto();
|
|
|
|
return content;
|
|
}
|
|
|
|
public abstract dataProto(): SignalService.DataMessage;
|
|
|
|
protected makeDataProtoNoProfile(): SignalService.DataMessage {
|
|
const dataMessage = new SignalService.DataMessage({});
|
|
|
|
return dataMessage;
|
|
}
|
|
}
|
|
|
|
export abstract class DataMessageWithProfile extends ExpirableMessageWithProfile {
|
|
public override contentProto(): SignalService.Content {
|
|
const content = super.makeDisappearingContentProto();
|
|
content.dataMessage = this.dataProto();
|
|
|
|
return content;
|
|
}
|
|
|
|
public abstract dataProto(): SignalService.DataMessage;
|
|
|
|
protected makeDataProtoWithProfile(): SignalService.DataMessage {
|
|
const dataMessage = new SignalService.DataMessage({});
|
|
const { profile, profileKey } = this.lokiProfileProto();
|
|
|
|
if (profile && profileKey) {
|
|
dataMessage.profile = profile;
|
|
dataMessage.profileKey = profileKey;
|
|
} else if (profile?.displayName) {
|
|
dataMessage.profile = profile;
|
|
}
|
|
|
|
return dataMessage;
|
|
}
|
|
}
|