Page MenuHomePhabricator

D13438.id44472.diff
No OneTemporary

D13438.id44472.diff

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
@@ -8,6 +8,8 @@
traditionalRelationshipActionsList,
type LegacyRelationshipRequest,
legacyFarcasterRelationshipRequestValidator,
+ relationshipActions,
+ type RelationshipRequestUserInfo,
} from 'lib/types/relationship-types.js';
import { tShape, tUserID } from 'lib/utils/validation-utils.js';
@@ -31,8 +33,29 @@
async function legacyUpdateRelationshipsResponder(
viewer: Viewer,
- request: LegacyRelationshipRequest,
+ legacyRequest: LegacyRelationshipRequest,
): Promise<RelationshipErrors> {
+ let requestUserIDs;
+ const viewerID = viewer.userID;
+ if (legacyRequest.action === relationshipActions.FARCASTER_MUTUAL) {
+ requestUserIDs = Object.keys(legacyRequest.userIDsToFID).filter(
+ userID => userID !== viewerID,
+ );
+ } else {
+ requestUserIDs = legacyRequest.userIDs;
+ }
+
+ const requestUserInfos: { [userID: string]: RelationshipRequestUserInfo } =
+ {};
+ for (const userID of requestUserIDs) {
+ requestUserInfos[userID] = {
+ createRobotextInThinThread: true,
+ };
+ }
+ const request = {
+ action: legacyRequest.action,
+ users: requestUserInfos,
+ };
return await updateRelationships(viewer, request);
}
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
@@ -10,7 +10,7 @@
relationshipActions,
undirectedStatus,
directedStatus,
- type LegacyRelationshipRequest,
+ type RelationshipRequest,
} from 'lib/types/relationship-types.js';
import { threadTypes } from 'lib/types/thread-types-enum.js';
import type { NewThreadResponse } from 'lib/types/thread-types.js';
@@ -31,22 +31,13 @@
async function updateRelationships(
viewer: Viewer,
- request: LegacyRelationshipRequest,
+ request: RelationshipRequest,
): Promise<RelationshipErrors> {
if (!viewer.loggedIn) {
throw new ServerError('not_logged_in');
}
- let requestUserIDs;
- const viewerID = viewer.userID;
- if (request.action === relationshipActions.FARCASTER_MUTUAL) {
- requestUserIDs = Object.keys(request.userIDsToFID).filter(
- userID => userID !== viewerID,
- );
- } else {
- requestUserIDs = request.userIDs;
- }
-
+ const requestUserIDs = Object.keys(request.users);
const uniqueUserIDs = [...new Set(requestUserIDs)];
const users = await fetchUserInfos(uniqueUserIDs);
@@ -212,6 +203,7 @@
`;
await dbQuery(query);
} else if (request.action === relationshipActions.FARCASTER_MUTUAL) {
+ const viewerID = viewer.userID;
const { identities: userIdentities } = await findUserIdentities([
...userIDs,
viewerID,
@@ -391,7 +383,7 @@
async function createPersonalThreads(
viewer: Viewer,
- request: LegacyRelationshipRequest,
+ request: RelationshipRequest,
userIDs: $ReadOnlyArray<string>,
) {
invariant(
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
@@ -89,6 +89,14 @@
| LegacyTraditionalRelationshipRequest
| LegacyFarcasterRelationshipRequest;
+export type RelationshipRequestUserInfo = {
+ +createRobotextInThinThread: boolean,
+};
+export type RelationshipRequest = {
+ +action: RelationshipAction,
+ +users: { +[userID: string]: RelationshipRequestUserInfo },
+};
+
export const legacyFarcasterRelationshipRequestValidator: TInterface<LegacyFarcasterRelationshipRequest> =
tShape<LegacyFarcasterRelationshipRequest>({
action: tString('farcaster'),

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 3:33 PM (20 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2535160
Default Alt Text
D13438.id44472.diff (3 KB)

Event Timeline