Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3377072
D11436.id38681.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
12 KB
Referenced Files
None
Subscribers
None
D11436.id38681.diff
View Options
diff --git a/lib/shared/message-utils.test.js b/lib/shared/message-utils.test.js
--- a/lib/shared/message-utils.test.js
+++ b/lib/shared/message-utils.test.js
@@ -25,13 +25,13 @@
import type { RawImagesMessageInfo } from '../types/messages/images.js';
import type { RawJoinThreadMessageInfo } from '../types/messages/join-thread.js';
import type { RawLeaveThreadMessageInfo } from '../types/messages/leave-thread.js';
+import type { RawLegacyUpdateRelationshipMessageInfo } from '../types/messages/legacy-update-relationship.js';
import type { RawMediaMessageInfo } from '../types/messages/media.js';
import type { RawReactionMessageInfo } from '../types/messages/reaction.js';
import type { RawRemoveMembersMessageInfo } from '../types/messages/remove-members.js';
import type { RawRestoreEntryMessageInfo } from '../types/messages/restore-entry.js';
import type { RawTextMessageInfo } from '../types/messages/text.js';
import type { RawTogglePinMessageInfo } from '../types/messages/toggle-pin.js';
-import type { RawUpdateRelationshipMessageInfo } from '../types/messages/update-relationship.js';
import { threadTypes } from '../types/thread-types-enum.js';
const textMessageInfo: RawTextMessageInfo = {
@@ -154,7 +154,7 @@
text: 'This is a restored calendar entry',
id: '1',
};
-const updateRelationshipMessageInfo: RawUpdateRelationshipMessageInfo = {
+const updateRelationshipMessageInfo: RawLegacyUpdateRelationshipMessageInfo = {
type: messageTypes.LEGACY_UPDATE_RELATIONSHIP,
threadID: '10000',
creatorID: '123',
diff --git a/lib/shared/messages/update-relationship-message-spec.js b/lib/shared/messages/update-relationship-message-spec.js
--- a/lib/shared/messages/update-relationship-message-spec.js
+++ b/lib/shared/messages/update-relationship-message-spec.js
@@ -14,25 +14,27 @@
MessageInfo,
} from '../../types/message-types.js';
import {
- type RawUpdateRelationshipMessageInfo,
- rawUpdateRelationshipMessageInfoValidator,
- type UpdateRelationshipMessageData,
- type UpdateRelationshipMessageInfo,
-} from '../../types/messages/update-relationship.js';
+ type RawLegacyUpdateRelationshipMessageInfo,
+ rawLegacyUpdateRelationshipMessageInfoValidator,
+ type LegacyUpdateRelationshipMessageData,
+ type LegacyUpdateRelationshipMessageInfo,
+} from '../../types/messages/legacy-update-relationship.js';
import type { ThreadInfo } from '../../types/minimally-encoded-thread-permissions-types.js';
import type { NotifTexts } from '../../types/notif-types.js';
import type { RelativeUserInfo } from '../../types/user-types.js';
import { type EntityText, ET } from '../../utils/entity-text.js';
type UpdateRelationshipMessageSpec = MessageSpec<
- UpdateRelationshipMessageData,
- RawUpdateRelationshipMessageInfo,
- UpdateRelationshipMessageInfo,
+ LegacyUpdateRelationshipMessageData,
+ RawLegacyUpdateRelationshipMessageInfo,
+ LegacyUpdateRelationshipMessageInfo,
> & {
// We need to explicitly type this as non-optional so that
// it can be referenced from messageContentForClientDB below
+messageContentForServerDB: (
- data: UpdateRelationshipMessageData | RawUpdateRelationshipMessageInfo,
+ data:
+ | LegacyUpdateRelationshipMessageData
+ | RawLegacyUpdateRelationshipMessageInfo,
) => string,
...
};
@@ -40,7 +42,9 @@
export const updateRelationshipMessageSpec: UpdateRelationshipMessageSpec =
Object.freeze({
messageContentForServerDB(
- data: UpdateRelationshipMessageData | RawUpdateRelationshipMessageInfo,
+ data:
+ | LegacyUpdateRelationshipMessageData
+ | RawLegacyUpdateRelationshipMessageInfo,
): string {
return JSON.stringify({
operation: data.operation,
@@ -48,13 +52,15 @@
});
},
- messageContentForClientDB(data: RawUpdateRelationshipMessageInfo): string {
+ messageContentForClientDB(
+ data: RawLegacyUpdateRelationshipMessageInfo,
+ ): string {
return updateRelationshipMessageSpec.messageContentForServerDB(data);
},
rawMessageInfoFromServerDBRow(
row: Object,
- ): RawUpdateRelationshipMessageInfo {
+ ): RawLegacyUpdateRelationshipMessageInfo {
const content = JSON.parse(row.content);
return {
type: messageTypes.LEGACY_UPDATE_RELATIONSHIP,
@@ -69,14 +75,14 @@
rawMessageInfoFromClientDB(
clientDBMessageInfo: ClientDBMessageInfo,
- ): RawUpdateRelationshipMessageInfo {
+ ): RawLegacyUpdateRelationshipMessageInfo {
invariant(
clientDBMessageInfo.content !== undefined &&
clientDBMessageInfo.content !== null,
'content must be defined for UpdateRelationship',
);
const content = JSON.parse(clientDBMessageInfo.content);
- const rawUpdateRelationshipMessageInfo: RawUpdateRelationshipMessageInfo =
+ const rawUpdateRelationshipMessageInfo: RawLegacyUpdateRelationshipMessageInfo =
{
type: messageTypes.LEGACY_UPDATE_RELATIONSHIP,
id: clientDBMessageInfo.id,
@@ -90,10 +96,10 @@
},
createMessageInfo(
- rawMessageInfo: RawUpdateRelationshipMessageInfo,
+ rawMessageInfo: RawLegacyUpdateRelationshipMessageInfo,
creator: RelativeUserInfo,
params: CreateMessageInfoParams,
- ): ?UpdateRelationshipMessageInfo {
+ ): ?LegacyUpdateRelationshipMessageInfo {
const target = params.createRelativeUserInfos([
rawMessageInfo.targetID,
])[0];
@@ -112,16 +118,16 @@
},
rawMessageInfoFromMessageData(
- messageData: UpdateRelationshipMessageData,
+ messageData: LegacyUpdateRelationshipMessageData,
id: ?string,
- ): RawUpdateRelationshipMessageInfo {
+ ): RawLegacyUpdateRelationshipMessageInfo {
invariant(id, 'RawUpdateRelationshipMessageInfo needs id');
return { ...messageData, id };
},
// ESLint doesn't recognize that invariant always throws
// eslint-disable-next-line consistent-return
- robotext(messageInfo: UpdateRelationshipMessageInfo): EntityText {
+ robotext(messageInfo: LegacyUpdateRelationshipMessageInfo): EntityText {
const creator = ET.user({ userInfo: messageInfo.creator });
if (messageInfo.operation === 'request_sent') {
const target = ET.user({ userInfo: messageInfo.target });
@@ -141,8 +147,8 @@
},
unshimMessageInfo(
- unwrapped: RawUpdateRelationshipMessageInfo,
- ): RawUpdateRelationshipMessageInfo {
+ unwrapped: RawLegacyUpdateRelationshipMessageInfo,
+ ): RawLegacyUpdateRelationshipMessageInfo {
return unwrapped;
},
@@ -173,5 +179,5 @@
canBePinned: false,
- validator: rawUpdateRelationshipMessageInfoValidator,
+ validator: rawLegacyUpdateRelationshipMessageInfoValidator,
});
diff --git a/lib/types/message-types.js b/lib/types/message-types.js
--- a/lib/types/message-types.js
+++ b/lib/types/message-types.js
@@ -88,6 +88,12 @@
type RawLeaveThreadMessageInfo,
rawLeaveThreadMessageInfoValidator,
} from './messages/leave-thread.js';
+import {
+ type RawLegacyUpdateRelationshipMessageInfo,
+ rawLegacyUpdateRelationshipMessageInfoValidator,
+ type LegacyUpdateRelationshipMessageData,
+ type LegacyUpdateRelationshipMessageInfo,
+} from './messages/legacy-update-relationship.js';
import {
type MediaMessageData,
type MediaMessageInfo,
@@ -130,12 +136,6 @@
rawUnsupportedMessageInfoValidator,
type UnsupportedMessageInfo,
} from './messages/unsupported.js';
-import {
- type RawUpdateRelationshipMessageInfo,
- rawUpdateRelationshipMessageInfoValidator,
- type UpdateRelationshipMessageData,
- type UpdateRelationshipMessageInfo,
-} from './messages/update-relationship.js';
import { type RelativeUserInfo, type UserInfos } from './user-types.js';
import type { CallSingleKeyserverEndpointResultInfoInterface } from '../utils/call-single-keyserver-endpoint.js';
import { values } from '../utils/objects.js';
@@ -215,7 +215,7 @@
| RawRestoreEntryMessageInfo
| RawImagesMessageInfo
| RawMediaMessageInfo
- | RawUpdateRelationshipMessageInfo
+ | RawLegacyUpdateRelationshipMessageInfo
| RawCreateSidebarMessageInfo
| RawUnsupportedMessageInfo;
@@ -243,7 +243,7 @@
| RestoreEntryMessageData
| ImagesMessageData
| MediaMessageData
- | UpdateRelationshipMessageData
+ | LegacyUpdateRelationshipMessageData
| SidebarSourceMessageData
| CreateSidebarMessageData
| ReactionMessageData
@@ -279,7 +279,7 @@
| RawEditEntryMessageInfo
| RawDeleteEntryMessageInfo
| RawRestoreEntryMessageInfo
- | RawUpdateRelationshipMessageInfo
+ | RawLegacyUpdateRelationshipMessageInfo
| RawCreateSidebarMessageInfo
| RawUnsupportedMessageInfo
| RawTogglePinMessageInfo;
@@ -296,7 +296,7 @@
rawEditEntryMessageInfoValidator,
rawDeleteEntryMessageInfoValidator,
rawRestoreEntryMessageInfoValidator,
- rawUpdateRelationshipMessageInfoValidator,
+ rawLegacyUpdateRelationshipMessageInfoValidator,
rawCreateSidebarMessageInfoValidator,
rawUnsupportedMessageInfoValidator,
rawTogglePinMessageInfoValidator,
@@ -370,7 +370,7 @@
| DeleteEntryMessageInfo
| RestoreEntryMessageInfo
| UnsupportedMessageInfo
- | UpdateRelationshipMessageInfo
+ | LegacyUpdateRelationshipMessageInfo
| CreateSidebarMessageInfo
| TogglePinMessageInfo;
export type PreviewableMessageInfo =
@@ -394,7 +394,7 @@
| RestoreEntryMessageInfo
| ImagesMessageInfo
| MediaMessageInfo
- | UpdateRelationshipMessageInfo
+ | LegacyUpdateRelationshipMessageInfo
| CreateSidebarMessageInfo
| UnsupportedMessageInfo;
diff --git a/lib/types/messages/update-relationship.js b/lib/types/messages/legacy-update-relationship.js
rename from lib/types/messages/update-relationship.js
rename to lib/types/messages/legacy-update-relationship.js
--- a/lib/types/messages/update-relationship.js
+++ b/lib/types/messages/legacy-update-relationship.js
@@ -6,7 +6,7 @@
import { messageTypes } from '../message-types-enum.js';
import type { RelativeUserInfo } from '../user-types.js';
-export type UpdateRelationshipMessageData = {
+export type LegacyUpdateRelationshipMessageData = {
+type: 16,
+threadID: string,
+creatorID: string,
@@ -15,13 +15,13 @@
+operation: 'request_sent' | 'request_accepted',
};
-export type RawUpdateRelationshipMessageInfo = {
- ...UpdateRelationshipMessageData,
+export type RawLegacyUpdateRelationshipMessageInfo = {
+ ...LegacyUpdateRelationshipMessageData,
id: string,
};
-export const rawUpdateRelationshipMessageInfoValidator: TInterface<RawUpdateRelationshipMessageInfo> =
- tShape<RawUpdateRelationshipMessageInfo>({
+export const rawLegacyUpdateRelationshipMessageInfoValidator: TInterface<RawLegacyUpdateRelationshipMessageInfo> =
+ tShape<RawLegacyUpdateRelationshipMessageInfo>({
type: tNumber(messageTypes.LEGACY_UPDATE_RELATIONSHIP),
threadID: tID,
creatorID: t.String,
@@ -31,7 +31,7 @@
id: tID,
});
-export type UpdateRelationshipMessageInfo = {
+export type LegacyUpdateRelationshipMessageInfo = {
+type: 16,
+id: string,
+threadID: string,
diff --git a/lib/utils/message-ops-utils.test.js b/lib/utils/message-ops-utils.test.js
--- a/lib/utils/message-ops-utils.test.js
+++ b/lib/utils/message-ops-utils.test.js
@@ -20,10 +20,10 @@
import type { RawImagesMessageInfo } from '../types/messages/images.js';
import type { RawJoinThreadMessageInfo } from '../types/messages/join-thread.js';
import type { RawLeaveThreadMessageInfo } from '../types/messages/leave-thread.js';
+import type { RawLegacyUpdateRelationshipMessageInfo } from '../types/messages/legacy-update-relationship.js';
import type { RawRemoveMembersMessageInfo } from '../types/messages/remove-members.js';
import type { RawRestoreEntryMessageInfo } from '../types/messages/restore-entry.js';
import type { RawTextMessageInfo } from '../types/messages/text.js';
-import type { RawUpdateRelationshipMessageInfo } from '../types/messages/update-relationship.js';
test('TEXT: rawMessageInfo -> clientDBMessageInfo -> rawMessageInfo', () => {
const rawTextMessageInfo: RawTextMessageInfo = {
@@ -319,15 +319,16 @@
});
test('LEGACY_UPDATE_RELATIONSHIP: rawMessageInfo -> clientDBMessageInfo -> rawMessageInfo', () => {
- const rawUpdateRelationshipMessageInfo: RawUpdateRelationshipMessageInfo = {
- type: 16,
- id: '85651',
- threadID: '85630',
- time: 1638235869690,
- creatorID: '83809',
- targetID: '85435',
- operation: 'request_accepted',
- };
+ const rawUpdateRelationshipMessageInfo: RawLegacyUpdateRelationshipMessageInfo =
+ {
+ type: 16,
+ id: '85651',
+ threadID: '85630',
+ time: 1638235869690,
+ creatorID: '83809',
+ targetID: '85435',
+ operation: 'request_accepted',
+ };
expect(
translateClientDBMessageInfoToRawMessageInfo(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 3:35 AM (22 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2592650
Default Alt Text
D11436.id38681.diff (12 KB)
Attached To
Mode
D11436: [lib] Add "Legacy" to types in `update-relationship`
Attached
Detach File
Event Timeline
Log In to Comment