Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3514419
D13439.id44513.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D13439.id44513.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
@@ -57,6 +57,9 @@
const updateIDs = [];
if (request.action === relationshipActions.FRIEND) {
+ const usersToCreateRobotextFor = userIDs.filter(
+ userID => request.users[userID].createRobotextInThinThread,
+ );
// 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
@@ -65,7 +68,7 @@
const threadIDPerUser = await createPersonalThreads(
viewer,
request,
- userIDs,
+ usersToCreateRobotextFor,
);
const { userRelationshipOperations, errors: friendRequestErrors } =
await fetchFriendRequestRelationshipOperations(viewer, userIDs);
@@ -91,25 +94,29 @@
const [user1, user2] = ids;
const status = undirectedStatus.FRIEND;
undirectedInsertRows.push({ user1, user2, status });
- messageDatas.push({
- type: messageTypes.LEGACY_UPDATE_RELATIONSHIP,
- threadID: threadIDPerUser[userID],
- creatorID: viewer.userID,
- targetID: userID,
- time: now,
- operation: 'request_accepted',
- });
+ if (request.users[userID].createRobotextInThinThread) {
+ messageDatas.push({
+ type: messageTypes.LEGACY_UPDATE_RELATIONSHIP,
+ threadID: threadIDPerUser[userID],
+ creatorID: viewer.userID,
+ targetID: userID,
+ time: now,
+ operation: 'request_accepted',
+ });
+ }
} else if (operation === 'pending_friend') {
const status = directedStatus.PENDING_FRIEND;
directedInsertRows.push([viewer.userID, userID, status]);
- messageDatas.push({
- type: messageTypes.LEGACY_UPDATE_RELATIONSHIP,
- threadID: threadIDPerUser[userID],
- creatorID: viewer.userID,
- targetID: userID,
- time: now,
- operation: 'request_sent',
- });
+ if (request.users[userID].createRobotextInThinThread) {
+ messageDatas.push({
+ type: messageTypes.LEGACY_UPDATE_RELATIONSHIP,
+ threadID: threadIDPerUser[userID],
+ creatorID: viewer.userID,
+ targetID: userID,
+ time: now,
+ operation: 'request_sent',
+ });
+ }
} else if (operation === 'know_of') {
const [user1, user2] = ids;
const status = undirectedStatus.KNOW_OF;
@@ -224,7 +231,12 @@
userIDsToFIDs.set(userID, fid);
}
}
- const userIDsWithFID = [...userIDsToFIDs.keys()];
+ const usersToCreateRobotextFor = [...userIDsToFIDs.entries()].filter(
+ ([userID]) => request.users[userID].createRobotextInThinThread,
+ );
+ const userIDsToCreateRobotextFor = usersToCreateRobotextFor.map(
+ ([userID]) => userID,
+ );
// We have to create personal threads before setting the relationship
// status. By doing that we make sure that failed thread creation is
@@ -234,10 +246,10 @@
const threadIDPerUser = await createPersonalThreads(
viewer,
request,
- userIDsWithFID,
+ userIDsToCreateRobotextFor,
);
- const insertRows = userIDsWithFID.map(otherUserID => {
+ const insertRows = [...userIDsToFIDs.keys()].map(otherUserID => {
const [user1, user2] = sortUserIDs(viewer.userID, otherUserID);
return { user1, user2, status: undirectedStatus.FRIEND };
});
@@ -245,7 +257,7 @@
await createUpdates(updateDatas);
const now = Date.now();
- const messageDatas = [...userIDsToFIDs.entries()].map(
+ const messageDatas = usersToCreateRobotextFor.map(
([otherUserID, otherUserFID]) => ({
type: messageTypes.UPDATE_RELATIONSHIP,
threadID: threadIDPerUser[otherUserID],
@@ -394,6 +406,10 @@
request.action,
);
+ if (userIDs.length === 0) {
+ return {};
+ }
+
const threadIDPerUser: { [string]: string } = {};
const personalThreadsQuery = SQL`
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 4:52 AM (18 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2693584
Default Alt Text
D13439.id44513.diff (4 KB)
Attached To
Mode
D13439: [keyserver] Only create robotext for relationship actions if createRobotextInThinThread is true
Attached
Detach File
Event Timeline
Log In to Comment