Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3353302
D11438.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D11438.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D11438: [lib] Introduce bare minimum `messageTypes.UPDATE_RELATIONSHIP`
Attached
Detach File
Event Timeline
Log In to Comment