|
|
@ -1,9 +1,9 @@
|
|
|
|
import { DataMessage } from '..';
|
|
|
|
|
|
|
|
import { SignalService } from '../../../../protobuf';
|
|
|
|
import { SignalService } from '../../../../protobuf';
|
|
|
|
import { DisappearingMessageType } from '../../../../util/expiringMessages';
|
|
|
|
import { DisappearingMessageType } from '../../../../util/expiringMessages';
|
|
|
|
import { PubKey } from '../../../types';
|
|
|
|
import { PubKey } from '../../../types';
|
|
|
|
import { StringUtils } from '../../../utils';
|
|
|
|
import { StringUtils } from '../../../utils';
|
|
|
|
import { MessageParams } from '../Message';
|
|
|
|
import { MessageParams } from '../Message';
|
|
|
|
|
|
|
|
import { VisibleMessage } from '../visibleMessage/VisibleMessage';
|
|
|
|
|
|
|
|
|
|
|
|
interface ExpirationTimerUpdateMessageParams extends MessageParams {
|
|
|
|
interface ExpirationTimerUpdateMessageParams extends MessageParams {
|
|
|
|
groupId?: string | PubKey;
|
|
|
|
groupId?: string | PubKey;
|
|
|
@ -16,22 +16,23 @@ interface ExpirationTimerUpdateMessageParams extends MessageParams {
|
|
|
|
// Note the old disappearing messages used a data message for the expiration time.
|
|
|
|
// Note the old disappearing messages used a data message for the expiration time.
|
|
|
|
// The new ones use properties on the Content Message
|
|
|
|
// The new ones use properties on the Content Message
|
|
|
|
// We will remove support for the old one 2 weeks after the release
|
|
|
|
// We will remove support for the old one 2 weeks after the release
|
|
|
|
export class ExpirationTimerUpdateMessage extends DataMessage {
|
|
|
|
export class ExpirationTimerUpdateMessage extends VisibleMessage {
|
|
|
|
public readonly groupId?: PubKey;
|
|
|
|
public readonly groupId?: PubKey;
|
|
|
|
public readonly syncTarget?: string;
|
|
|
|
|
|
|
|
public readonly expirationType: DisappearingMessageType | null;
|
|
|
|
|
|
|
|
public readonly expireTimer: number | null;
|
|
|
|
|
|
|
|
public readonly lastDisappearingMessageChangeTimestamp: number | null;
|
|
|
|
public readonly lastDisappearingMessageChangeTimestamp: number | null;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(params: ExpirationTimerUpdateMessageParams) {
|
|
|
|
constructor(params: ExpirationTimerUpdateMessageParams) {
|
|
|
|
super({ timestamp: params.timestamp, identifier: params.identifier });
|
|
|
|
super({
|
|
|
|
this.expirationType = params.expirationType;
|
|
|
|
timestamp: params.timestamp,
|
|
|
|
this.expireTimer = params.expireTimer;
|
|
|
|
identifier: params.identifier,
|
|
|
|
|
|
|
|
expirationType: params.expirationType,
|
|
|
|
|
|
|
|
expireTimer: params.expireTimer || undefined,
|
|
|
|
|
|
|
|
syncTarget: params.syncTarget ? PubKey.cast(params.syncTarget).key : undefined,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.lastDisappearingMessageChangeTimestamp = params.lastDisappearingMessageChangeTimestamp;
|
|
|
|
this.lastDisappearingMessageChangeTimestamp = params.lastDisappearingMessageChangeTimestamp;
|
|
|
|
|
|
|
|
|
|
|
|
const { groupId, syncTarget } = params;
|
|
|
|
const { groupId } = params;
|
|
|
|
this.groupId = groupId ? PubKey.cast(groupId) : undefined;
|
|
|
|
this.groupId = groupId ? PubKey.cast(groupId) : undefined;
|
|
|
|
this.syncTarget = syncTarget ? PubKey.cast(syncTarget).key : undefined;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public contentProto(): SignalService.Content {
|
|
|
|
public contentProto(): SignalService.Content {
|
|
|
@ -47,7 +48,7 @@ export class ExpirationTimerUpdateMessage extends DataMessage {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public dataProto(): SignalService.DataMessage {
|
|
|
|
public dataProto(): SignalService.DataMessage {
|
|
|
|
const data = new SignalService.DataMessage();
|
|
|
|
const data = super.dataProto();
|
|
|
|
|
|
|
|
|
|
|
|
data.flags = SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE;
|
|
|
|
data.flags = SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE;
|
|
|
|
|
|
|
|
|
|
|
@ -64,10 +65,6 @@ export class ExpirationTimerUpdateMessage extends DataMessage {
|
|
|
|
data.group = groupMessage;
|
|
|
|
data.group = groupMessage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.syncTarget) {
|
|
|
|
|
|
|
|
data.syncTarget = this.syncTarget;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO remove 2 weeks after the release
|
|
|
|
// TODO remove 2 weeks after the release
|
|
|
|
if (this.expireTimer) {
|
|
|
|
if (this.expireTimer) {
|
|
|
|
data.expireTimer = this.expireTimer;
|
|
|
|
data.expireTimer = this.expireTimer;
|
|
|
|