Skip to content

Commit

Permalink
Fix Gift Badge expiration
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Nonnenberg <scott@signal.org>
  • Loading branch information
automated-signal and scottnonnenberg-signal committed Jun 22, 2022
1 parent aa3368d commit b4c67be
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ts/textsecure/processDataMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import type {
import { WarnOnlyError } from './Errors';
import { GiftBadgeStates } from '../components/conversation/Message';
import { APPLICATION_OCTET_STREAM, stringToMIMEType } from '../types/MIME';
import { SECOND } from '../util/durations';

const FLAGS = Proto.DataMessage.Flags;
export const ATTACHMENT_MAX = 32;
Expand Down Expand Up @@ -242,7 +243,6 @@ export function processDelete(
}

export function processGiftBadge(
timestamp: number,
giftBadge: Proto.DataMessage.IGiftBadge | null | undefined
): ProcessedGiftBadge | undefined {
if (
Expand All @@ -258,7 +258,7 @@ export function processGiftBadge(
);

return {
expiration: timestamp + Number(receipt.getReceiptExpirationTime()),
expiration: Number(receipt.getReceiptExpirationTime()) * SECOND,
id: undefined,
level: Number(receipt.getReceiptLevel()),
receiptCredentialPresentation: Bytes.toBase64(
Expand Down Expand Up @@ -317,7 +317,7 @@ export async function processDataMessage(
bodyRanges: message.bodyRanges ?? [],
groupCallUpdate: dropNull(message.groupCallUpdate),
storyContext: dropNull(message.storyContext),
giftBadge: processGiftBadge(timestamp, message.giftBadge),
giftBadge: processGiftBadge(message.giftBadge),
};

const isEndSession = Boolean(result.flags & FLAGS.END_SESSION);
Expand Down

0 comments on commit b4c67be

Please sign in to comment.