Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3735357
D11390.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11390.diff
View Options
diff --git a/keyserver/src/updaters/relationship-updaters.js b/keyserver/src/updaters/relationship-updaters.js
--- a/keyserver/src/updaters/relationship-updaters.js
+++ b/keyserver/src/updaters/relationship-updaters.js
@@ -198,6 +198,19 @@
user1 = ${viewer.userID} AND user2 IN (${userIDs})
`;
await dbQuery(query);
+ } else if (action === relationshipActions.FARCASTER_MUTUAL) {
+ // We have to create personal threads before setting the relationship
+ // status. By doing that we make sure that failed thread creation is
+ // reported to the caller and can be repeated - there should be only
+ // one PERSONAL thread per a pair of users and we can safely call it
+ // repeatedly.
+ await createPersonalThreads(viewer, request);
+ const insertRows = request.userIDs.map(otherUserID => {
+ const [user1, user2] = sortUserIDs(viewer.userID, otherUserID);
+ return { user1, user2, status: undirectedStatus.KNOW_OF };
+ });
+ const updateDatas = await updateChangedUndirectedRelationships(insertRows);
+ await createUpdates(updateDatas);
} else {
invariant(false, `action ${action} is invalid or not supported currently`);
}
@@ -313,9 +326,11 @@
request: RelationshipRequest,
) {
invariant(
- request.action === relationshipActions.FRIEND,
- 'We should only create a PERSONAL threads when sending a FRIEND request, ' +
- `but we tried to do that for ${request.action}`,
+ request.action === relationshipActions.FRIEND ||
+ request.action === relationshipActions.FARCASTER_MUTUAL,
+ 'We should only create a PERSONAL threads when sending FRIEND or ' +
+ 'FARCASTER_MUTUAL requests, but we tried to do that for ' +
+ request.action,
);
const threadIDPerUser: { [string]: 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
@@ -36,6 +36,7 @@
UNFRIEND: 'unfriend',
BLOCK: 'block',
UNBLOCK: 'unblock',
+ FARCASTER_MUTUAL: 'farcaster',
});
export type RelationshipAction = $Values<typeof relationshipActions>;
export const relationshipActionsList: $ReadOnlyArray<RelationshipAction> =
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 10, 4:33 AM (6 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2845126
Default Alt Text
D11390.diff (2 KB)
Attached To
Mode
D11390: [keyserver][lib] Introduce relationshipActions.FARCASTER_MUTUAL
Attached
Detach File
Event Timeline
Log In to Comment