Migrate schema to service ids

This commit is contained in:
Fedor Indutny 2023-08-16 22:54:39 +02:00 committed by Jamie Kyle
parent 71958f8a01
commit 8b0da36caa
258 changed files with 4795 additions and 2613 deletions

View file

@ -29,6 +29,7 @@ import { SECOND, DurationInSeconds } from '../util/durations';
import type { AnyPaymentEvent } from '../types/Payment';
import { PaymentEventKind } from '../types/Payment';
import { filterAndClean } from '../types/BodyRange';
import { isAciString, normalizeAci } from '../types/ServiceId';
const FLAGS = Proto.DataMessage.Flags;
export const ATTACHMENT_MAX = 32;
@ -129,9 +130,14 @@ export function processQuote(
return undefined;
}
const { authorAci } = quote;
if (!isAciString(authorAci)) {
throw new Error('quote.authorAci is not an ACI string');
}
return {
id: quote.id?.toNumber(),
authorAci: dropNull(quote.authorAci),
authorAci: normalizeAci(authorAci, 'Quote.authorAci'),
text: dropNull(quote.text),
attachments: (quote.attachments ?? []).map(attachment => {
return {
@ -220,10 +226,15 @@ export function processReaction(
return undefined;
}
const { targetAuthorAci } = reaction;
if (!isAciString(targetAuthorAci)) {
throw new Error('reaction.targetAuthorAci is not an ACI string');
}
return {
emoji: dropNull(reaction.emoji),
remove: Boolean(reaction.remove),
targetAuthorAci: dropNull(reaction.targetAuthorAci),
targetAuthorAci: normalizeAci(targetAuthorAci, 'Reaction.targetAuthorAci'),
targetTimestamp: reaction.targetTimestamp?.toNumber(),
};
}