Page MenuHomePhabricator

D11438.diff
No OneTemporary

D11438.diff

diff --git a/lib/shared/messages/message-specs.js b/lib/shared/messages/message-specs.js
--- a/lib/shared/messages/message-specs.js
+++ b/lib/shared/messages/message-specs.js
@@ -52,4 +52,5 @@
[messageTypes.REACTION]: reactionMessageSpec,
[messageTypes.EDIT_MESSAGE]: editMessageSpec,
[messageTypes.TOGGLE_PIN]: togglePinMessageSpec,
+ [messageTypes.UPDATE_RELATIONSHIP]: updateRelationshipMessageSpec,
});
diff --git a/lib/types/message-types-enum.js b/lib/types/message-types-enum.js
--- a/lib/types/message-types-enum.js
+++ b/lib/types/message-types-enum.js
@@ -34,6 +34,7 @@
REACTION: 19,
EDIT_MESSAGE: 20,
TOGGLE_PIN: 21,
+ UPDATE_RELATIONSHIP: 22,
});
export type MessageType = $Values<typeof messageTypes>;
export function assertMessageType(ourMessageType: number): MessageType {
@@ -59,7 +60,8 @@
ourMessageType === 18 ||
ourMessageType === 19 ||
ourMessageType === 20 ||
- ourMessageType === 21,
+ ourMessageType === 21 ||
+ ourMessageType === 22,
'number is not MessageType enum',
);
return ourMessageType;
diff --git a/lib/types/messages/update-relationship.js b/lib/types/messages/update-relationship.js
new file mode 100644
--- /dev/null
+++ b/lib/types/messages/update-relationship.js
@@ -0,0 +1,46 @@
+// @flow
+
+import t, { type TInterface } from 'tcomb';
+
+import { tID, tNumber, tShape } from '../../utils/validation-utils.js';
+import { messageTypes } from '../message-types-enum.js';
+import type { RelativeUserInfo } from '../user-types.js';
+
+export type UpdateRelationshipMessageData = {
+ +type: 22,
+ +threadID: string,
+ +creatorID: string,
+ +targetID: string,
+ +time: number,
+ +operation: 'request_sent' | 'request_accepted' | 'farcaster_mutual',
+};
+
+export type RawUpdateRelationshipMessageInfo = {
+ ...UpdateRelationshipMessageData,
+ id: string,
+};
+
+export const rawUpdateRelationshipMessageInfoValidator: TInterface<RawUpdateRelationshipMessageInfo> =
+ tShape<RawUpdateRelationshipMessageInfo>({
+ type: tNumber(messageTypes.UPDATE_RELATIONSHIP),
+ threadID: tID,
+ creatorID: t.String,
+ targetID: t.String,
+ time: t.Number,
+ operation: t.enums.of([
+ 'request_sent',
+ 'request_accepted',
+ 'farcaster_mutual',
+ ]),
+ id: tID,
+ });
+
+export type UpdateRelationshipMessageInfo = {
+ +type: 22,
+ +id: string,
+ +threadID: string,
+ +creator: RelativeUserInfo,
+ +target: RelativeUserInfo,
+ +time: number,
+ +operation: 'request_sent' | 'request_accepted' | 'farcaster_mutual',
+};
diff --git a/lib/types/validation.test.js b/lib/types/validation.test.js
--- a/lib/types/validation.test.js
+++ b/lib/types/validation.test.js
@@ -326,7 +326,11 @@
(validatorMessageType === messageTypes.IMAGES &&
message.type === messageTypes.MULTIMEDIA) ||
(validatorMessageType === messageTypes.MULTIMEDIA &&
- message.type === messageTypes.IMAGES)
+ message.type === messageTypes.IMAGES) ||
+ (validatorMessageType === messageTypes.UPDATE_RELATIONSHIP &&
+ message.type === messageTypes.LEGACY_UPDATE_RELATIONSHIP) ||
+ (validatorMessageType === messageTypes.LEGACY_UPDATE_RELATIONSHIP &&
+ message.type === messageTypes.UPDATE_RELATIONSHIP)
)
) {
it(`${validatorMessageTypeName} shouldn't validate ${messageTypeName}`, () => {

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 9:17 AM (21 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2574803
Default Alt Text
D11438.diff (3 KB)

Event Timeline