diff --git a/lib/types/dm-ops.js b/lib/types/dm-ops.js --- a/lib/types/dm-ops.js +++ b/lib/types/dm-ops.js @@ -5,6 +5,7 @@ import { clientAvatarValidator, type ClientAvatar } from './avatar-types.js'; import { type Media, mediaValidator } from './media-types.js'; import type { RawMessageInfo } from './message-types.js'; +import type { RelationshipOperation } from './messages/update-relationship.js'; import type { NotificationsCreationData } from './notif-types.js'; import type { OutboundP2PMessage } from './sqlite-types.js'; import { @@ -43,6 +44,7 @@ CREATE_ENTRY: 'create_entry', DELETE_ENTRY: 'delete_entry', EDIT_ENTRY: 'edit_entry', + UPDATE_RELATIONSHIP: 'update_relationship', }); export type DMOperationType = $Values; @@ -385,7 +387,6 @@ +text: string, +messageID: string, }; - export const dmCreateEntryOperationValidator: TInterface = tShape({ type: tString(dmOperationTypes.CREATE_ENTRY), @@ -409,7 +410,6 @@ +prevText: string, +messageID: string, }; - export const dmDeleteEntryOperationValidator: TInterface = tShape({ type: tString(dmOperationTypes.DELETE_ENTRY), @@ -434,7 +434,6 @@ +text: string, +messageID: string, }; - export const dmEditEntryOperationValidator: TInterface = tShape({ type: tString(dmOperationTypes.EDIT_ENTRY), @@ -448,6 +447,28 @@ messageID: t.String, }); +export type DMUpdateRelationshipOperation = { + +type: 'update_relationship', + +threadID: string, + +creatorID: string, + +time: number, + +operation: RelationshipOperation, + +messageID: string, +}; +export const dmUpdateRelationshipOperationValidator: TInterface = + tShape({ + type: tString(dmOperationTypes.UPDATE_RELATIONSHIP), + threadID: t.String, + creatorID: t.String, + time: t.Number, + operation: t.enums.of([ + 'request_sent', + 'request_accepted', + 'farcaster_mutual', + ]), + messageID: t.String, + }); + export type DMOperation = | DMCreateThreadOperation | DMCreateSidebarOperation @@ -465,7 +486,8 @@ | DMChangeThreadReadStatusOperation | DMCreateEntryOperation | DMDeleteEntryOperation - | DMEditEntryOperation; + | DMEditEntryOperation + | DMUpdateRelationshipOperation; export const dmOperationValidator: TUnion = t.union([ dmCreateThreadOperationValidator, dmCreateSidebarOperationValidator, @@ -484,6 +506,7 @@ dmCreateEntryOperationValidator, dmDeleteEntryOperationValidator, dmEditEntryOperationValidator, + dmUpdateRelationshipOperationValidator, ]); export type DMOperationResult = { diff --git a/lib/types/messages/update-relationship.js b/lib/types/messages/update-relationship.js --- a/lib/types/messages/update-relationship.js +++ b/lib/types/messages/update-relationship.js @@ -18,6 +18,10 @@ export type FarcasterRelationshipOperation = 'farcaster_mutual'; +export type RelationshipOperation = + | TraditionalRelationshipOperation + | FarcasterRelationshipOperation; + export type UpdateTraditionalRelationshipMessageData = { +type: 22, +threadID: string,