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 @@ -9,6 +9,7 @@ pushTypes, } from './message-spec.js'; import { assertSingleMessageInfo } from './utils.js'; +import type { PlatformDetails } from '../../types/device-types.js'; import { messageTypes } from '../../types/message-types-enum.js'; import type { ClientDBMessageInfo, @@ -20,6 +21,7 @@ type LegacyUpdateRelationshipMessageData, type LegacyUpdateRelationshipMessageInfo, } from '../../types/messages/legacy-update-relationship.js'; +import type { RawUnsupportedMessageInfo } from '../../types/messages/unsupported.js'; import type { RawUpdateRelationshipMessageInfo, UpdateRelationshipMessageData, @@ -30,6 +32,7 @@ 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'; +import { FUTURE_CODE_VERSION, hasMinCodeVersion } from '../version-utils.js'; type UpdateRelationshipMessageSpec = MessageSpec< LegacyUpdateRelationshipMessageData | UpdateRelationshipMessageData, @@ -199,6 +202,48 @@ ); }, + shimUnsupportedMessageInfo( + rawMessageInfo: + | RawUpdateRelationshipMessageInfo + | RawLegacyUpdateRelationshipMessageInfo, + platformDetails: ?PlatformDetails, + ): + | RawLegacyUpdateRelationshipMessageInfo + | RawUpdateRelationshipMessageInfo + | RawUnsupportedMessageInfo { + if (rawMessageInfo.type === messageTypes.LEGACY_UPDATE_RELATIONSHIP) { + return rawMessageInfo; + } else if ( + rawMessageInfo.type === messageTypes.UPDATE_RELATIONSHIP && + hasMinCodeVersion(platformDetails, { + native: FUTURE_CODE_VERSION, + web: FUTURE_CODE_VERSION, + majorDesktop: FUTURE_CODE_VERSION, + }) + ) { + return rawMessageInfo; + } else if ( + rawMessageInfo.type === messageTypes.UPDATE_RELATIONSHIP && + rawMessageInfo.operation !== 'farcaster_mutual' + ) { + return { + ...rawMessageInfo, + type: messageTypes.LEGACY_UPDATE_RELATIONSHIP, + operation: rawMessageInfo.operation, + }; + } else { + return { + type: messageTypes.UNSUPPORTED, + id: rawMessageInfo.id, + threadID: rawMessageInfo.threadID, + creatorID: rawMessageInfo.creatorID, + time: rawMessageInfo.time, + robotext: 'Your connection on Farcaster is on Comm.', + unsupportedMessageInfo: rawMessageInfo, + }; + } + }, + unshimMessageInfo( unwrapped: | RawLegacyUpdateRelationshipMessageInfo