Made StoryDataType sourceDevice required
This commit is contained in:
parent
e3299b0445
commit
4294429bc2
5 changed files with 28 additions and 2 deletions
|
@ -95,6 +95,25 @@ export function getStoryDataFromMessageAttributes(
|
||||||
attachment = getPropsForAttachment(attachment);
|
attachment = getPropsForAttachment(attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for a story, the message should always include the sourceDevice
|
||||||
|
// but some messages got saved without one in the past (sync-sent)
|
||||||
|
// we default those to some reasonable values that won't break the app
|
||||||
|
let sourceDevice: number;
|
||||||
|
if (message.sourceDevice !== undefined) {
|
||||||
|
sourceDevice = message.sourceDevice;
|
||||||
|
} else {
|
||||||
|
log.error('getStoryDataFromMessageAttributes: undefined sourceDevice');
|
||||||
|
// storage user.getDevice() should always produce a value after registration
|
||||||
|
const ourDeviceId = window.storage.user.getDeviceId() ?? -1;
|
||||||
|
if (message.type === 'outgoing') {
|
||||||
|
sourceDevice = ourDeviceId;
|
||||||
|
} else if (message.type === 'incoming') {
|
||||||
|
sourceDevice = 1;
|
||||||
|
} else {
|
||||||
|
sourceDevice = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
attachment,
|
attachment,
|
||||||
messageId: message.id,
|
messageId: message.id,
|
||||||
|
@ -114,6 +133,7 @@ export function getStoryDataFromMessageAttributes(
|
||||||
'timestamp',
|
'timestamp',
|
||||||
'type',
|
'type',
|
||||||
]),
|
]),
|
||||||
|
sourceDevice,
|
||||||
expireTimer: message.expireTimer,
|
expireTimer: message.expireTimer,
|
||||||
expirationStartTimestamp: dropNull(message.expirationStartTimestamp),
|
expirationStartTimestamp: dropNull(message.expirationStartTimestamp),
|
||||||
};
|
};
|
||||||
|
|
|
@ -74,7 +74,6 @@ export type StoryDataType = {
|
||||||
| 'sendStateByConversationId'
|
| 'sendStateByConversationId'
|
||||||
| 'source'
|
| 'source'
|
||||||
| 'sourceUuid'
|
| 'sourceUuid'
|
||||||
| 'sourceDevice'
|
|
||||||
| 'storyDistributionListId'
|
| 'storyDistributionListId'
|
||||||
| 'timestamp'
|
| 'timestamp'
|
||||||
| 'type'
|
| 'type'
|
||||||
|
@ -82,6 +81,7 @@ export type StoryDataType = {
|
||||||
// don't want the fields to be optional as in MessageAttributesType
|
// don't want the fields to be optional as in MessageAttributesType
|
||||||
expireTimer: DurationInSeconds | undefined;
|
expireTimer: DurationInSeconds | undefined;
|
||||||
expirationStartTimestamp: number | undefined;
|
expirationStartTimestamp: number | undefined;
|
||||||
|
sourceDevice: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SelectedStoryDataType = {
|
export type SelectedStoryDataType = {
|
||||||
|
@ -1378,6 +1378,7 @@ export function reducer(
|
||||||
'sendStateByConversationId',
|
'sendStateByConversationId',
|
||||||
'source',
|
'source',
|
||||||
'sourceUuid',
|
'sourceUuid',
|
||||||
|
'sourceDevice',
|
||||||
'storyDistributionListId',
|
'storyDistributionListId',
|
||||||
'timestamp',
|
'timestamp',
|
||||||
'type',
|
'type',
|
||||||
|
|
|
@ -79,6 +79,7 @@ describe('both/state/ducks/stories', () => {
|
||||||
readStatus: ReadStatus.Unread,
|
readStatus: ReadStatus.Unread,
|
||||||
timestamp: now - timestampDelta,
|
timestamp: now - timestampDelta,
|
||||||
type: 'story',
|
type: 'story',
|
||||||
|
sourceDevice: 1,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,6 +546,7 @@ describe('both/state/ducks/stories', () => {
|
||||||
storyDistributionListId,
|
storyDistributionListId,
|
||||||
timestamp: now - timestampDelta,
|
timestamp: now - timestampDelta,
|
||||||
type: 'story',
|
type: 'story',
|
||||||
|
sourceDevice: 1,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -930,6 +932,7 @@ describe('both/state/ducks/stories', () => {
|
||||||
stories: [
|
stories: [
|
||||||
{
|
{
|
||||||
...messageAttributes,
|
...messageAttributes,
|
||||||
|
sourceDevice: 1,
|
||||||
attachment: messageAttributes.attachments[0],
|
attachment: messageAttributes.attachments[0],
|
||||||
messageId: messageAttributes.id,
|
messageId: messageAttributes.id,
|
||||||
expireTimer: messageAttributes.expireTimer,
|
expireTimer: messageAttributes.expireTimer,
|
||||||
|
@ -984,6 +987,7 @@ describe('both/state/ducks/stories', () => {
|
||||||
stories: [
|
stories: [
|
||||||
{
|
{
|
||||||
...messageAttributes,
|
...messageAttributes,
|
||||||
|
sourceDevice: 1,
|
||||||
attachment: messageAttributes.attachments[0],
|
attachment: messageAttributes.attachments[0],
|
||||||
messageId: messageAttributes.id,
|
messageId: messageAttributes.id,
|
||||||
expireTimer: messageAttributes.expireTimer,
|
expireTimer: messageAttributes.expireTimer,
|
||||||
|
|
|
@ -2138,6 +2138,7 @@ export default class MessageReceiver
|
||||||
destinationUuid: envelope.destinationUuid.toString(),
|
destinationUuid: envelope.destinationUuid.toString(),
|
||||||
timestamp: envelope.timestamp,
|
timestamp: envelope.timestamp,
|
||||||
serverTimestamp: envelope.serverTimestamp,
|
serverTimestamp: envelope.serverTimestamp,
|
||||||
|
device: envelope.sourceDevice,
|
||||||
unidentifiedStatus: Array.from(sentToUuids).map(
|
unidentifiedStatus: Array.from(sentToUuids).map(
|
||||||
destinationUuid => ({
|
destinationUuid => ({
|
||||||
destinationUuid,
|
destinationUuid,
|
||||||
|
|
|
@ -184,7 +184,7 @@ export type SentEventData = Readonly<{
|
||||||
destinationUuid?: string;
|
destinationUuid?: string;
|
||||||
timestamp?: number;
|
timestamp?: number;
|
||||||
serverTimestamp?: number;
|
serverTimestamp?: number;
|
||||||
device?: number;
|
device: number | undefined;
|
||||||
unidentifiedStatus: ProcessedSent['unidentifiedStatus'];
|
unidentifiedStatus: ProcessedSent['unidentifiedStatus'];
|
||||||
message: ProcessedDataMessage;
|
message: ProcessedDataMessage;
|
||||||
isRecipientUpdate: boolean;
|
isRecipientUpdate: boolean;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue