Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32206550
D6795.1765119464.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D6795.1765119464.diff
View Options
diff --git a/keyserver/src/responders/message-responders.js b/keyserver/src/responders/message-responders.js
--- a/keyserver/src/responders/message-responders.js
+++ b/keyserver/src/responders/message-responders.js
@@ -78,7 +78,7 @@
throw new ServerError('invalid_parameters');
}
- const messageData: TextMessageData = {
+ let messageData: TextMessageData = {
type: messageTypes.TEXT,
threadID,
creatorID: viewer.id,
@@ -86,7 +86,7 @@
text,
};
if (localID) {
- messageData.localID = localID;
+ messageData = { ...messageData, localID };
}
const rawMessageInfos = await createMessages(viewer, [messageData]);
diff --git a/lib/shared/message-utils.js b/lib/shared/message-utils.js
--- a/lib/shared/message-utils.js
+++ b/lib/shared/message-utils.js
@@ -263,6 +263,9 @@
time,
media: photoMedia,
}: ImagesMessageData);
+ if (localID) {
+ messageData = { ...messageData, localID };
+ }
} else {
messageData = ({
type: messageTypes.MULTIMEDIA,
@@ -271,9 +274,9 @@
time,
media: input.media,
}: MediaMessageData);
- }
- if (localID) {
- messageData.localID = localID;
+ if (localID) {
+ messageData = { ...messageData, localID };
+ }
}
return messageData;
}
diff --git a/lib/shared/messages/multimedia-message-spec.js b/lib/shared/messages/multimedia-message-spec.js
--- a/lib/shared/messages/multimedia-message-spec.js
+++ b/lib/shared/messages/multimedia-message-spec.js
@@ -92,7 +92,7 @@
`media_infos must be defined`,
);
- const rawMessageInfo: RawImagesMessageInfo | RawMediaMessageInfo =
+ let rawMessageInfo: RawImagesMessageInfo | RawMediaMessageInfo =
messageType === messageTypes.IMAGES
? {
type: messageTypes.IMAGES,
@@ -113,10 +113,16 @@
};
if (clientDBMessageInfo.local_id) {
- rawMessageInfo.localID = clientDBMessageInfo.local_id;
+ rawMessageInfo = {
+ ...rawMessageInfo,
+ localID: clientDBMessageInfo.local_id,
+ };
}
if (clientDBMessageInfo.id !== clientDBMessageInfo.local_id) {
- rawMessageInfo.id = clientDBMessageInfo.id;
+ rawMessageInfo = {
+ ...rawMessageInfo,
+ id: clientDBMessageInfo.id,
+ };
}
return rawMessageInfo;
},
@@ -150,7 +156,7 @@
creator: RelativeUserInfo,
): ?(MediaMessageInfo | ImagesMessageInfo) {
if (rawMessageInfo.type === messageTypes.IMAGES) {
- const messageInfo: ImagesMessageInfo = {
+ let messageInfo: ImagesMessageInfo = {
type: messageTypes.IMAGES,
threadID: rawMessageInfo.threadID,
creator,
@@ -158,14 +164,14 @@
media: rawMessageInfo.media,
};
if (rawMessageInfo.id) {
- messageInfo.id = rawMessageInfo.id;
+ messageInfo = { ...messageInfo, id: rawMessageInfo.id };
}
if (rawMessageInfo.localID) {
- messageInfo.localID = rawMessageInfo.localID;
+ messageInfo = { ...messageInfo, localID: rawMessageInfo.localID };
}
return messageInfo;
} else if (rawMessageInfo.type === messageTypes.MULTIMEDIA) {
- const messageInfo: MediaMessageInfo = {
+ let messageInfo: MediaMessageInfo = {
type: messageTypes.MULTIMEDIA,
threadID: rawMessageInfo.threadID,
creator,
@@ -173,10 +179,10 @@
media: rawMessageInfo.media,
};
if (rawMessageInfo.id) {
- messageInfo.id = rawMessageInfo.id;
+ messageInfo = { ...messageInfo, id: rawMessageInfo.id };
}
if (rawMessageInfo.localID) {
- messageInfo.localID = rawMessageInfo.localID;
+ messageInfo = { ...messageInfo, localID: rawMessageInfo.localID };
}
return messageInfo;
}
diff --git a/lib/shared/messages/text-message-spec.js b/lib/shared/messages/text-message-spec.js
--- a/lib/shared/messages/text-message-spec.js
+++ b/lib/shared/messages/text-message-spec.js
@@ -100,7 +100,7 @@
row: Object,
params: RawMessageInfoFromServerDBRowParams,
): RawTextMessageInfo {
- const rawTextMessageInfo: RawTextMessageInfo = {
+ let rawTextMessageInfo: RawTextMessageInfo = {
type: messageTypes.TEXT,
id: row.id.toString(),
threadID: row.threadID.toString(),
@@ -109,7 +109,7 @@
text: row.content,
};
if (params.localID) {
- rawTextMessageInfo.localID = params.localID;
+ rawTextMessageInfo = { ...rawTextMessageInfo, localID: params.localID };
}
return rawTextMessageInfo;
},
@@ -117,7 +117,7 @@
rawMessageInfoFromClientDB(
clientDBMessageInfo: ClientDBMessageInfo,
): RawTextMessageInfo {
- const rawTextMessageInfo: RawTextMessageInfo = {
+ let rawTextMessageInfo: RawTextMessageInfo = {
type: messageTypes.TEXT,
threadID: clientDBMessageInfo.thread,
time: parseInt(clientDBMessageInfo.time),
@@ -125,10 +125,16 @@
text: clientDBMessageInfo.content ?? '',
};
if (clientDBMessageInfo.local_id) {
- rawTextMessageInfo.localID = clientDBMessageInfo.local_id;
+ rawTextMessageInfo = {
+ ...rawTextMessageInfo,
+ localID: clientDBMessageInfo.local_id,
+ };
}
if (clientDBMessageInfo.id !== clientDBMessageInfo.local_id) {
- rawTextMessageInfo.id = clientDBMessageInfo.id;
+ rawTextMessageInfo = {
+ ...rawTextMessageInfo,
+ id: clientDBMessageInfo.id,
+ };
}
return rawTextMessageInfo;
},
@@ -137,7 +143,7 @@
rawMessageInfo: RawTextMessageInfo,
creator: RelativeUserInfo,
): TextMessageInfo {
- const messageInfo: TextMessageInfo = {
+ let messageInfo: TextMessageInfo = {
type: messageTypes.TEXT,
threadID: rawMessageInfo.threadID,
creator,
@@ -145,10 +151,10 @@
text: rawMessageInfo.text,
};
if (rawMessageInfo.id) {
- messageInfo.id = rawMessageInfo.id;
+ messageInfo = { ...messageInfo, id: rawMessageInfo.id };
}
if (rawMessageInfo.localID) {
- messageInfo.localID = rawMessageInfo.localID;
+ messageInfo = { ...messageInfo, localID: rawMessageInfo.localID };
}
return messageInfo;
},
diff --git a/lib/types/messages/images.js b/lib/types/messages/images.js
--- a/lib/types/messages/images.js
+++ b/lib/types/messages/images.js
@@ -4,25 +4,25 @@
import type { RelativeUserInfo } from '../user-types.js';
export type ImagesMessageData = {
- type: 14,
- localID?: string, // for optimistic creations. included by new clients
- threadID: string,
- creatorID: string,
- time: number,
- media: $ReadOnlyArray<Image>,
+ +type: 14,
+ +localID?: string, // for optimistic creations. included by new clients
+ +threadID: string,
+ +creatorID: string,
+ +time: number,
+ +media: $ReadOnlyArray<Image>,
};
export type RawImagesMessageInfo = {
...ImagesMessageData,
- id?: string, // null if local copy without ID yet
+ +id?: string, // null if local copy without ID yet
};
export type ImagesMessageInfo = {
- type: 14,
- id?: string, // null if local copy without ID yet
- localID?: string, // for optimistic creations
- threadID: string,
- creator: RelativeUserInfo,
- time: number, // millisecond timestamp
- media: $ReadOnlyArray<Image>,
+ +type: 14,
+ +id?: string, // null if local copy without ID yet
+ +localID?: string, // for optimistic creations
+ +threadID: string,
+ +creator: RelativeUserInfo,
+ +time: number, // millisecond timestamp
+ +media: $ReadOnlyArray<Image>,
};
diff --git a/lib/types/messages/media.js b/lib/types/messages/media.js
--- a/lib/types/messages/media.js
+++ b/lib/types/messages/media.js
@@ -4,27 +4,27 @@
import type { RelativeUserInfo } from '../user-types.js';
export type MediaMessageData = {
- type: 15,
- localID?: string, // for optimistic creations. included by new clients
- threadID: string,
- creatorID: string,
- time: number,
- media: $ReadOnlyArray<Media>,
+ +type: 15,
+ +localID?: string, // for optimistic creations. included by new clients
+ +threadID: string,
+ +creatorID: string,
+ +time: number,
+ +media: $ReadOnlyArray<Media>,
};
export type RawMediaMessageInfo = {
...MediaMessageData,
- id?: string, // null if local copy without ID yet
+ +id?: string, // null if local copy without ID yet
};
export type MediaMessageInfo = {
- type: 15,
- id?: string, // null if local copy without ID yet
- localID?: string, // for optimistic creations
- threadID: string,
- creator: RelativeUserInfo,
- time: number, // millisecond timestamp
- media: $ReadOnlyArray<Media>,
+ +type: 15,
+ +id?: string, // null if local copy without ID yet
+ +localID?: string, // for optimistic creations
+ +threadID: string,
+ +creator: RelativeUserInfo,
+ +time: number, // millisecond timestamp
+ +media: $ReadOnlyArray<Media>,
};
export type MediaMessageServerDBContent =
diff --git a/lib/types/messages/text.js b/lib/types/messages/text.js
--- a/lib/types/messages/text.js
+++ b/lib/types/messages/text.js
@@ -3,25 +3,25 @@
import type { RelativeUserInfo } from '../user-types.js';
export type TextMessageData = {
- type: 0,
- localID?: string, // for optimistic creations. included by new clients
- threadID: string,
- creatorID: string,
- time: number,
- text: string,
+ +type: 0,
+ +localID?: string, // for optimistic creations. included by new clients
+ +threadID: string,
+ +creatorID: string,
+ +time: number,
+ +text: string,
};
export type RawTextMessageInfo = {
...TextMessageData,
- id?: string, // null if local copy without ID yet
+ +id?: string, // null if local copy without ID yet
};
export type TextMessageInfo = {
- type: 0,
- id?: string, // null if local copy without ID yet
- localID?: string, // for optimistic creations
- threadID: string,
- creator: RelativeUserInfo,
- time: number, // millisecond timestamp
- text: string,
+ +type: 0,
+ +id?: string, // null if local copy without ID yet
+ +localID?: string, // for optimistic creations
+ +threadID: string,
+ +creator: RelativeUserInfo,
+ +time: number, // millisecond timestamp
+ +text: string,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 2:57 PM (15 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5844650
Default Alt Text
D6795.1765119464.diff (9 KB)
Attached To
Mode
D6795: [lib] Make text and media message types read-only
Attached
Detach File
Event Timeline
Log In to Comment