Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3514390
D13451.id44499.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D13451.id44499.diff
View Options
diff --git a/keyserver/src/responders/relationship-responders.js b/keyserver/src/responders/relationship-responders.js
--- a/keyserver/src/responders/relationship-responders.js
+++ b/keyserver/src/responders/relationship-responders.js
@@ -10,8 +10,9 @@
legacyFarcasterRelationshipRequestValidator,
relationshipActions,
type RelationshipRequestUserInfo,
+ type RelationshipRequestWithRobotext,
+ type RelationshipRequestWithoutRobotext,
type RelationshipRequest,
- relationshipActionsList,
} from 'lib/types/relationship-types.js';
import { tShape, tUserID } from 'lib/utils/validation-utils.js';
@@ -54,23 +55,40 @@
createRobotextInThinThread: true,
};
}
- const request = {
- action: legacyRequest.action,
- users: requestUserInfos,
- };
+ const { action } = legacyRequest;
+ let request: RelationshipRequest;
+ if (action === 'farcaster' || action === 'friend') {
+ request = { action, users: requestUserInfos };
+ } else {
+ request = { action, users: requestUserInfos };
+ }
return await updateRelationships(viewer, request);
}
-export const updateRelationshipInputValidator: TInterface<RelationshipRequest> =
- tShape<RelationshipRequest>({
- action: t.enums.of(relationshipActionsList, 'relationship action'),
- users: t.dict(
- tUserID,
- tShape<RelationshipRequestUserInfo>({
- createRobotextInThinThread: t.Boolean,
- }),
- ),
- });
+export const updateRelationshipInputValidator: TUnion<RelationshipRequest> =
+ t.union([
+ tShape<RelationshipRequestWithRobotext>({
+ action: t.enums.of(['farcaster', 'friend'], 'relationship action'),
+ users: t.dict(
+ tUserID,
+ tShape<RelationshipRequestUserInfo>({
+ createRobotextInThinThread: t.Boolean,
+ }),
+ ),
+ }),
+ tShape<RelationshipRequestWithoutRobotext>({
+ action: t.enums.of(
+ ['unfriend', 'block', 'unblock', 'acknowledge'],
+ 'relationship action',
+ ),
+ users: t.dict(
+ tUserID,
+ tShape<RelationshipRequestUserInfo>({
+ createRobotextInThinThread: t.maybe(t.Boolean),
+ }),
+ ),
+ }),
+ ]);
async function updateRelationshipsResponder(
viewer: Viewer,
diff --git a/lib/hooks/relationship-hooks.js b/lib/hooks/relationship-hooks.js
--- a/lib/hooks/relationship-hooks.js
+++ b/lib/hooks/relationship-hooks.js
@@ -21,6 +21,7 @@
type RelationshipAction,
type RelationshipErrors,
type RelationshipRequestUserInfo,
+ type RelationshipRequest,
relationshipActions,
userRelationshipStatus,
} from '../types/relationship-types.js';
@@ -174,10 +175,14 @@
planForUser.plan === 'send_to_thin_thread',
};
}
- const keyserverResultPromise = updateRelationships({
- action,
- users: usersForKeyserverCall,
- });
+
+ let request: RelationshipRequest;
+ if (action === 'farcaster' || action === 'friend') {
+ request = { action, users: usersForKeyserverCall };
+ } else {
+ request = { action, users: usersForKeyserverCall };
+ }
+ const keyserverResultPromise = updateRelationships(request);
const thickThreadPromises: Array<Promise<void>> = [];
for (const [userID, planForUser] of planForUsers) {
@@ -288,18 +293,22 @@
(action !== relationshipActions.FRIEND &&
action !== relationshipActions.FARCASTER_MUTUAL)
) {
- return await updateRelationships({
- action,
- users: Object.fromEntries(
+ let request: RelationshipRequest;
+ if (action === 'farcaster' || action === 'friend') {
+ const users = Object.fromEntries(
userIDs.map(userID => [
userID,
{
- // this param only matters for FRIEND and FARCASTER_MUTUAL
createRobotextInThinThread: true,
},
]),
- ),
- });
+ );
+ request = { action, users };
+ } else {
+ const users = Object.fromEntries(userIDs.map(userID => [userID, {}]));
+ request = { action, users };
+ }
+ return await updateRelationships(request);
}
const missingDeviceListsUserIDs: Array<string> = [];
diff --git a/lib/types/relationship-types.js b/lib/types/relationship-types.js
--- a/lib/types/relationship-types.js
+++ b/lib/types/relationship-types.js
@@ -92,10 +92,17 @@
export type RelationshipRequestUserInfo = {
+createRobotextInThinThread: boolean,
};
-export type RelationshipRequest = {
- +action: RelationshipAction,
+export type RelationshipRequestWithRobotext = {
+ +action: 'farcaster' | 'friend',
+users: { +[userID: string]: RelationshipRequestUserInfo },
};
+export type RelationshipRequestWithoutRobotext = {
+ +action: 'unfriend' | 'block' | 'unblock' | 'acknowledge',
+ +users: { +[userID: string]: $Partial<RelationshipRequestUserInfo> },
+};
+export type RelationshipRequest =
+ | RelationshipRequestWithRobotext
+ | RelationshipRequestWithoutRobotext;
export const legacyFarcasterRelationshipRequestValidator: TInterface<LegacyFarcasterRelationshipRequest> =
tShape<LegacyFarcasterRelationshipRequest>({
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 4:35 AM (13 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2692867
Default Alt Text
D13451.id44499.diff (5 KB)
Attached To
Mode
D13451: [keyserver][lib] Allow skipping createRobotextInThinThread
Attached
Detach File
Event Timeline
Log In to Comment