Page MenuHomePhabricator

D9325.id31549.diff
No OneTemporary

D9325.id31549.diff

diff --git a/lib/shared/messages/add-members-message-spec.js b/lib/shared/messages/add-members-message-spec.js
--- a/lib/shared/messages/add-members-message-spec.js
+++ b/lib/shared/messages/add-members-message-spec.js
@@ -9,9 +9,10 @@
} from './message-spec.js';
import { joinResult } from './utils.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type AddMembersMessageData,
@@ -166,5 +167,9 @@
return rawMessageInfo.addedUserIDs;
},
+ canBeSidebarSource(rawMessageInfo: RawAddMembersMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawAddMembersMessageInfoValidator,
});
diff --git a/lib/shared/messages/change-role-message-spec.js b/lib/shared/messages/change-role-message-spec.js
--- a/lib/shared/messages/change-role-message-spec.js
+++ b/lib/shared/messages/change-role-message-spec.js
@@ -12,9 +12,10 @@
import { joinResult } from './utils.js';
import type { PlatformDetails } from '../../types/device-types.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type ChangeRoleMessageData,
@@ -236,5 +237,9 @@
generatesNotifs: async () => pushTypes.NOTIF,
+ canBeSidebarSource(rawMessageInfo: RawChangeRoleMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawChangeRoleMessageInfoValidator,
});
diff --git a/lib/shared/messages/change-settings-message-spec.js b/lib/shared/messages/change-settings-message-spec.js
--- a/lib/shared/messages/change-settings-message-spec.js
+++ b/lib/shared/messages/change-settings-message-spec.js
@@ -10,9 +10,10 @@
} from './message-spec.js';
import { joinResult } from './utils.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type ChangeSettingsMessageData,
@@ -182,5 +183,9 @@
generatesNotifs: async () => pushTypes.NOTIF,
+ canBeSidebarSource(rawMessageInfo: RawChangeSettingsMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawChangeSettingsMessageInfoValidator,
});
diff --git a/lib/shared/messages/create-entry-message-spec.js b/lib/shared/messages/create-entry-message-spec.js
--- a/lib/shared/messages/create-entry-message-spec.js
+++ b/lib/shared/messages/create-entry-message-spec.js
@@ -5,9 +5,10 @@
import { pushTypes, type MessageSpec } from './message-spec.js';
import { joinResult } from './utils.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type CreateEntryMessageData,
@@ -121,5 +122,9 @@
generatesNotifs: async () => pushTypes.NOTIF,
+ canBeSidebarSource(rawMessageInfo: RawCreateEntryMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawCreateEntryMessageInfoValidator,
});
diff --git a/lib/shared/messages/create-sidebar-message-spec.js b/lib/shared/messages/create-sidebar-message-spec.js
--- a/lib/shared/messages/create-sidebar-message-spec.js
+++ b/lib/shared/messages/create-sidebar-message-spec.js
@@ -12,9 +12,10 @@
import { joinResult } from './utils.js';
import type { PlatformDetails } from '../../types/device-types.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type CreateSidebarMessageData,
@@ -229,5 +230,9 @@
return [parentThreadID];
},
+ canBeSidebarSource(rawMessageInfo: RawCreateSidebarMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawCreateSidebarMessageInfoValidator,
});
diff --git a/lib/shared/messages/create-sub-thread-message-spec.js b/lib/shared/messages/create-sub-thread-message-spec.js
--- a/lib/shared/messages/create-sub-thread-message-spec.js
+++ b/lib/shared/messages/create-sub-thread-message-spec.js
@@ -11,9 +11,10 @@
import { assertSingleMessageInfo } from './utils.js';
import { permissionLookup } from '../../permissions/thread-permissions.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type CreateSubthreadMessageData,
@@ -163,5 +164,9 @@
return [rawMessageInfo.childThreadID];
},
+ canBeSidebarSource(rawMessageInfo: RawCreateSubthreadMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawCreateSubthreadMessageInfoValidator,
});
diff --git a/lib/shared/messages/create-thread-message-spec.js b/lib/shared/messages/create-thread-message-spec.js
--- a/lib/shared/messages/create-thread-message-spec.js
+++ b/lib/shared/messages/create-thread-message-spec.js
@@ -10,9 +10,10 @@
} from './message-spec.js';
import { assertSingleMessageInfo } from './utils.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type CreateThreadMessageData,
@@ -202,5 +203,9 @@
return parentThreadID ? [parentThreadID] : [];
},
+ canBeSidebarSource(rawMessageInfo: RawCreateThreadMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawCreateThreadMessageInfoValidator,
});
diff --git a/lib/shared/messages/delete-entry-message-spec.js b/lib/shared/messages/delete-entry-message-spec.js
--- a/lib/shared/messages/delete-entry-message-spec.js
+++ b/lib/shared/messages/delete-entry-message-spec.js
@@ -5,9 +5,10 @@
import { pushTypes, type MessageSpec } from './message-spec.js';
import { assertSingleMessageInfo } from './utils.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type DeleteEntryMessageData,
@@ -136,5 +137,9 @@
generatesNotifs: async () => pushTypes.NOTIF,
+ canBeSidebarSource(rawMessageInfo: RawDeleteEntryMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawDeleteEntryMessageInfoValidator,
});
diff --git a/lib/shared/messages/edit-entry-message-spec.js b/lib/shared/messages/edit-entry-message-spec.js
--- a/lib/shared/messages/edit-entry-message-spec.js
+++ b/lib/shared/messages/edit-entry-message-spec.js
@@ -5,9 +5,10 @@
import { pushTypes, type MessageSpec } from './message-spec.js';
import { joinResult } from './utils.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type EditEntryMessageData,
@@ -121,5 +122,9 @@
generatesNotifs: async () => pushTypes.NOTIF,
+ canBeSidebarSource(rawMessageInfo: RawEditEntryMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawEditEntryMessageInfoValidator,
});
diff --git a/lib/shared/messages/edit-message-spec.js b/lib/shared/messages/edit-message-spec.js
--- a/lib/shared/messages/edit-message-spec.js
+++ b/lib/shared/messages/edit-message-spec.js
@@ -8,7 +8,10 @@
assertMessageType,
messageTypes,
} from '../../types/message-types-enum.js';
-import { type ClientDBMessageInfo } from '../../types/message-types.js';
+import {
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
+} from '../../types/message-types.js';
import {
type EditMessageData,
type RawEditMessageInfo,
@@ -140,5 +143,9 @@
return unwrapped;
},
+ canBeSidebarSource(messageInfo: RawEditMessageInfo): boolean {
+ return !isInvalidSidebarSource(messageInfo);
+ },
+
validator: rawEditMessageInfoValidator,
});
diff --git a/lib/shared/messages/join-thread-message-spec.js b/lib/shared/messages/join-thread-message-spec.js
--- a/lib/shared/messages/join-thread-message-spec.js
+++ b/lib/shared/messages/join-thread-message-spec.js
@@ -5,9 +5,10 @@
import type { MessageSpec, RobotextParams } from './message-spec.js';
import { joinResult } from './utils.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type JoinThreadMessageData,
@@ -119,5 +120,9 @@
return joinResult(rawMessageInfo.type, rawMessageInfo.threadID);
},
+ canBeSidebarSource(rawMessageInfo: RawJoinThreadMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawJoinThreadMessageInfoValidator,
});
diff --git a/lib/shared/messages/leave-thread-message-spec.js b/lib/shared/messages/leave-thread-message-spec.js
--- a/lib/shared/messages/leave-thread-message-spec.js
+++ b/lib/shared/messages/leave-thread-message-spec.js
@@ -5,9 +5,10 @@
import type { MessageSpec, RobotextParams } from './message-spec.js';
import { joinResult } from './utils.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type LeaveThreadMessageData,
@@ -119,5 +120,9 @@
return joinResult(rawMessageInfo.type, rawMessageInfo.threadID);
},
+ canBeSidebarSource(rawMessageInfo: RawLeaveThreadMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawLeaveThreadMessageInfoValidator,
});
diff --git a/lib/shared/messages/message-spec.js b/lib/shared/messages/message-spec.js
--- a/lib/shared/messages/message-spec.js
+++ b/lib/shared/messages/message-spec.js
@@ -113,6 +113,7 @@
+startsThread?: boolean,
+threadIDs?: (rawMessageInfo: RawInfo) => $ReadOnlyArray<string>,
+includedInRepliesCount?: boolean,
+ +canBeSidebarSource: (rawMessageInfo: RawInfo) => boolean,
+useCreationSideEffectsFunc?: () => CreationSideEffectsFunc<RawInfo>,
+validator: TType<RawInfo>,
};
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
@@ -23,6 +23,7 @@
import {
isMediaMessageType,
rawMultimediaMessageInfoValidator,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import type {
MessageInfo,
@@ -351,6 +352,12 @@
includedInRepliesCount: true,
+ canBeSidebarSource(
+ rawMessageInfo: RawMediaMessageInfo | RawImagesMessageInfo,
+ ): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawMultimediaMessageInfoValidator,
});
diff --git a/lib/shared/messages/reaction-message-spec.js b/lib/shared/messages/reaction-message-spec.js
--- a/lib/shared/messages/reaction-message-spec.js
+++ b/lib/shared/messages/reaction-message-spec.js
@@ -17,6 +17,7 @@
import {
type MessageInfo,
type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type ReactionMessageData,
@@ -218,5 +219,9 @@
return action === 'add_reaction' ? pushTypes.NOTIF : pushTypes.RESCIND;
},
+ canBeSidebarSource(rawMessageInfo: RawReactionMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawReactionMessageInfoValidator,
});
diff --git a/lib/shared/messages/remove-members-message-spec.js b/lib/shared/messages/remove-members-message-spec.js
--- a/lib/shared/messages/remove-members-message-spec.js
+++ b/lib/shared/messages/remove-members-message-spec.js
@@ -9,9 +9,10 @@
} from './message-spec.js';
import { joinResult } from './utils.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type RawRemoveMembersMessageInfo,
@@ -166,5 +167,9 @@
return rawMessageInfo.removedUserIDs;
},
+ canBeSidebarSource(messageInfo: RawRemoveMembersMessageInfo): boolean {
+ return !isInvalidSidebarSource(messageInfo);
+ },
+
validator: rawRemoveMembersMessageInfoValidator,
});
diff --git a/lib/shared/messages/restore-entry-message-spec.js b/lib/shared/messages/restore-entry-message-spec.js
--- a/lib/shared/messages/restore-entry-message-spec.js
+++ b/lib/shared/messages/restore-entry-message-spec.js
@@ -5,9 +5,10 @@
import { pushTypes, type MessageSpec } from './message-spec.js';
import { assertSingleMessageInfo } from './utils.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type RawRestoreEntryMessageInfo,
@@ -136,5 +137,9 @@
generatesNotifs: async () => pushTypes.NOTIF,
+ canBeSidebarSource(rawMessageInfo: RawRestoreEntryMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawRestoreEntryMessageInfoValidator,
});
diff --git a/lib/shared/messages/sidebar-source-message-spec.js b/lib/shared/messages/sidebar-source-message-spec.js
--- a/lib/shared/messages/sidebar-source-message-spec.js
+++ b/lib/shared/messages/sidebar-source-message-spec.js
@@ -181,5 +181,9 @@
startsThread: true,
+ canBeSidebarSource(rawMessageInfo: RawSidebarSourceMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawSidebarSourceMessageInfoValidator,
});
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
@@ -15,9 +15,10 @@
changeThreadSettings,
} from '../../actions/thread-actions.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import {
type RawTextMessageInfo,
@@ -314,5 +315,9 @@
};
},
+ canBeSidebarSource(rawMessageInfo: RawTextMessageInfo): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawTextMessageInfoValidator,
});
diff --git a/lib/shared/messages/toggle-pin-message-spec.js b/lib/shared/messages/toggle-pin-message-spec.js
--- a/lib/shared/messages/toggle-pin-message-spec.js
+++ b/lib/shared/messages/toggle-pin-message-spec.js
@@ -9,7 +9,10 @@
} from './message-spec.js';
import type { PlatformDetails } from '../../types/device-types';
import { messageTypes } from '../../types/message-types-enum.js';
-import type { ClientDBMessageInfo } from '../../types/message-types.js';
+import {
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
+} from '../../types/message-types.js';
import {
type TogglePinMessageData,
type TogglePinMessageInfo,
@@ -155,5 +158,9 @@
return unwrapped;
},
+ canBeSidebarSource(messageInfo: RawTogglePinMessageInfo): boolean {
+ return !isInvalidSidebarSource(messageInfo);
+ },
+
validator: rawTogglePinMessageInfoValidator,
});
diff --git a/lib/shared/messages/unsupported-message-spec.js b/lib/shared/messages/unsupported-message-spec.js
--- a/lib/shared/messages/unsupported-message-spec.js
+++ b/lib/shared/messages/unsupported-message-spec.js
@@ -4,7 +4,10 @@
import { pushTypes, type MessageSpec } from './message-spec.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import { type ClientDBMessageInfo } from '../../types/message-types.js';
+import {
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
+} from '../../types/message-types.js';
import {
type RawUnsupportedMessageInfo,
type UnsupportedMessageInfo,
@@ -74,5 +77,9 @@
generatesNotifs: async () => pushTypes.NOTIF,
+ canBeSidebarSource(messageInfo: RawUnsupportedMessageInfo): boolean {
+ return !isInvalidSidebarSource(messageInfo);
+ },
+
validator: rawUnsupportedMessageInfoValidator,
});
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
@@ -10,9 +10,10 @@
import { assertSingleMessageInfo } from './utils.js';
import type { PlatformDetails } from '../../types/device-types.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type {
- MessageInfo,
- ClientDBMessageInfo,
+import {
+ type MessageInfo,
+ type ClientDBMessageInfo,
+ isInvalidSidebarSource,
} from '../../types/message-types.js';
import type { RawUnsupportedMessageInfo } from '../../types/messages/unsupported.js';
import {
@@ -177,5 +178,11 @@
generatesNotifs: async () => pushTypes.NOTIF,
+ canBeSidebarSource(
+ rawMessageInfo: RawUpdateRelationshipMessageInfo,
+ ): boolean {
+ return !isInvalidSidebarSource(rawMessageInfo);
+ },
+
validator: rawUpdateRelationshipMessageInfoValidator,
});
diff --git a/lib/types/message-types.test.js b/lib/types/message-types.test.js
--- a/lib/types/message-types.test.js
+++ b/lib/types/message-types.test.js
@@ -24,8 +24,9 @@
import type { RawTogglePinMessageInfo } from './messages/toggle-pin.js';
import type { RawUpdateRelationshipMessageInfo } from './messages/update-relationship.js';
import { threadTypes } from './thread-types-enum.js';
+import { messageSpecs } from '../shared/messages/message-specs.js';
-describe('isInvalidSidebarSource', () => {
+describe('isInvalidSidebarSource & canBeSidebarSource', () => {
it('should return false for RawTextMessageInfo', () => {
const textMessageInfo: RawTextMessageInfo = {
type: messageTypes.TEXT,
@@ -36,10 +37,14 @@
text: 'This is a text message',
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.TEXT];
const shouldBeInvalidSidebarSource =
isInvalidSidebarSource(textMessageInfo);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(textMessageInfo);
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawCreateThreadMessageInfo', () => {
@@ -57,11 +62,17 @@
},
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.CREATE_THREAD];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
createThreadMessageInfo,
);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(
+ createThreadMessageInfo,
+ );
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawAddMembersMessageInfo', () => {
@@ -73,11 +84,17 @@
addedUserIDs: ['4', '5'],
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.ADD_MEMBERS];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
addMembersMessageInfo,
);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(
+ addMembersMessageInfo,
+ );
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawCreateSubthreadMessageInfo', () => {
@@ -89,11 +106,17 @@
childThreadID: '10002',
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.CREATE_SUB_THREAD];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
createSubthreadMessageInfo,
);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(
+ createSubthreadMessageInfo,
+ );
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawChangeSettingsMessageInfo', () => {
@@ -106,11 +129,17 @@
value: '#FFFFFF',
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.CHANGE_SETTINGS];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
changeSettingsMessageInfo,
);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(
+ changeSettingsMessageInfo,
+ );
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawRemoveMembersMessageInfo', () => {
@@ -122,11 +151,17 @@
removedUserIDs: ['1', '2', '3'],
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.REMOVE_MEMBERS];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
removeMembersMessageInfo,
);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(
+ removeMembersMessageInfo,
+ );
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawChangeRoleMessageInfo', () => {
@@ -140,11 +175,17 @@
roleName: 'Moderators',
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.CHANGE_ROLE];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
changeRoleMessageinfo,
);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(
+ changeRoleMessageinfo,
+ );
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawLeaveThreadMessageInfo', () => {
@@ -155,11 +196,17 @@
time: 10000,
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.LEAVE_THREAD];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
leaveThreadMessageInfo,
);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(
+ leaveThreadMessageInfo,
+ );
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawJoinThreadMessageInfo', () => {
@@ -170,11 +217,17 @@
time: 10000,
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.JOIN_THREAD];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
joinThreadMessageInfo,
);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(
+ joinThreadMessageInfo,
+ );
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawCreateEntryMessageInfo', () => {
@@ -188,11 +241,17 @@
text: 'This is a calendar entry',
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.CREATE_ENTRY];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
createEntryMessageInfo,
);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(
+ createEntryMessageInfo,
+ );
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawEditEntryMessageInfo', () => {
@@ -206,10 +265,15 @@
text: 'This is an edited calendar entry',
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.EDIT_ENTRY];
const shouldBeInvalidSidebarSource =
isInvalidSidebarSource(editEntryMessageInfo);
+ const canBeSidebarSource =
+ messageSpec.canBeSidebarSource(editEntryMessageInfo);
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawDeleteEntryMessageInfo', () => {
@@ -223,11 +287,17 @@
text: 'This is a deleted calendar entry',
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.DELETE_ENTRY];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
deleteEntryMessageInfo,
);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(
+ deleteEntryMessageInfo,
+ );
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawRestoreEntryMessageInfo', () => {
@@ -241,11 +311,17 @@
text: 'This is a restored calendar entry',
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.RESTORE_ENTRY];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
restoreEntryMessageInfo,
);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(
+ restoreEntryMessageInfo,
+ );
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawUpdateRelationshipMessageInfo', () => {
@@ -258,11 +334,17 @@
operation: 'request_sent',
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.UPDATE_RELATIONSHIP];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
updateRelationshipMessageInfo,
);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(
+ updateRelationshipMessageInfo,
+ );
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawImagesMessageInfo', () => {
@@ -286,10 +368,14 @@
],
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.IMAGES];
const shouldBeInvalidSidebarSource =
isInvalidSidebarSource(imageMessageInfo);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(imageMessageInfo);
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return false for RawMediaMessageInfo', () => {
@@ -313,10 +399,14 @@
],
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.MULTIMEDIA];
const shouldBeInvalidSidebarSource =
isInvalidSidebarSource(mediaMessageInfo);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(mediaMessageInfo);
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return true for RawSidebarSourceMessageInfo', () => {
@@ -336,11 +426,17 @@
},
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.SIDEBAR_SOURCE];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
sidebarSourceMessageInfo,
);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(
+ sidebarSourceMessageInfo,
+ );
+
expect(shouldBeInvalidSidebarSource).toBe(true);
+ expect(canBeSidebarSource).toBe(false);
});
it('should return false for RawCreateSidebarMessageInfo', () => {
@@ -358,11 +454,17 @@
},
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.CREATE_SIDEBAR];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
createSidebarMessageInfo,
);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(
+ createSidebarMessageInfo,
+ );
+
expect(shouldBeInvalidSidebarSource).toBe(false);
+ expect(canBeSidebarSource).toBe(true);
});
it('should return true for RawReactionMessageInfo', () => {
@@ -377,10 +479,15 @@
action: 'add_reaction',
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.REACTION];
const shouldBeInvalidSidebarSource =
isInvalidSidebarSource(reactionMessageInfo);
+ const canBeSidebarSource =
+ messageSpec.canBeSidebarSource(reactionMessageInfo);
+
expect(shouldBeInvalidSidebarSource).toBe(true);
+ expect(canBeSidebarSource).toBe(false);
});
it('should return true for RawEditMessageInfo', () => {
@@ -393,10 +500,14 @@
text: 'This is an edited message',
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.EDIT_MESSAGE];
const shouldBeInvalidSidebarSource =
isInvalidSidebarSource(editMessageInfo);
+ const canBeSidebarSource = messageSpec.canBeSidebarSource(editMessageInfo);
+
expect(shouldBeInvalidSidebarSource).toBe(true);
+ expect(canBeSidebarSource).toBe(false);
});
it('should return true for RawTogglePinMessageInfo', () => {
@@ -410,9 +521,14 @@
time: 10000,
id: '1',
};
+ const messageSpec = messageSpecs[messageTypes.TOGGLE_PIN];
const shouldBeInvalidSidebarSource =
isInvalidSidebarSource(togglePinMessageInfo);
+ const canBeSidebarSource =
+ messageSpec.canBeSidebarSource(togglePinMessageInfo);
+
expect(shouldBeInvalidSidebarSource).toBe(true);
+ expect(canBeSidebarSource).toBe(false);
});
});

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 22, 7:25 AM (1 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690558
Default Alt Text
D9325.id31549.diff (29 KB)

Event Timeline