Introduce Service Id Types
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
414c0a58d3
commit
366b875fd2
269 changed files with 5832 additions and 5550 deletions
|
@ -4,7 +4,9 @@
|
|||
import type { MessageAttributesType } from '../model-types.d';
|
||||
import type { MessageModel } from '../models/messages';
|
||||
import type { SignalService as Proto } from '../protobuf';
|
||||
import type { AciString } from '../types/ServiceId';
|
||||
import * as log from '../logging/log';
|
||||
import { normalizeAci } from '../types/ServiceId';
|
||||
import { filter } from './iterables';
|
||||
import { getContactId } from '../messages/helpers';
|
||||
import { getTimestampFromLong } from './timestampLongUtils';
|
||||
|
@ -17,12 +19,14 @@ export async function findStoryMessages(
|
|||
return [];
|
||||
}
|
||||
|
||||
const { authorUuid, sentTimestamp } = storyContext;
|
||||
const { authorAci: rawAuthorAci, sentTimestamp } = storyContext;
|
||||
|
||||
if (!authorUuid || !sentTimestamp) {
|
||||
if (!rawAuthorAci || !sentTimestamp) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const authorAci = normalizeAci(rawAuthorAci, 'findStoryMessage');
|
||||
|
||||
const sentAt = getTimestampFromLong(sentTimestamp);
|
||||
const ourConversationId =
|
||||
window.ConversationController.getOurConversationIdOrThrow();
|
||||
|
@ -34,7 +38,7 @@ export async function findStoryMessages(
|
|||
item.attributes,
|
||||
conversationId,
|
||||
ourConversationId,
|
||||
authorUuid,
|
||||
authorAci,
|
||||
sentAt
|
||||
)
|
||||
),
|
||||
|
@ -47,7 +51,7 @@ export async function findStoryMessages(
|
|||
log.info('findStoryMessages: db lookup needed', sentAt);
|
||||
const messages = await window.Signal.Data.getMessagesBySentAt(sentAt);
|
||||
const found = messages.filter(item =>
|
||||
isStoryAMatch(item, conversationId, ourConversationId, authorUuid, sentAt)
|
||||
isStoryAMatch(item, conversationId, ourConversationId, authorAci, sentAt)
|
||||
);
|
||||
|
||||
if (found.length === 0) {
|
||||
|
@ -65,7 +69,7 @@ function isStoryAMatch(
|
|||
message: MessageAttributesType | null | undefined,
|
||||
conversationId: string,
|
||||
ourConversationId: string,
|
||||
authorUuid: string,
|
||||
authorAci: AciString,
|
||||
sentTimestamp: number
|
||||
): message is MessageAttributesType {
|
||||
if (!message) {
|
||||
|
@ -74,7 +78,7 @@ function isStoryAMatch(
|
|||
|
||||
const authorConversation = window.ConversationController.lookupOrCreate({
|
||||
e164: undefined,
|
||||
uuid: authorUuid,
|
||||
uuid: authorAci,
|
||||
reason: 'isStoryAMatch',
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue