Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/updaters/thread-updaters.js
Show All 17 Lines | import { | ||||
type RoleChangeRequest, | type RoleChangeRequest, | ||||
type ChangeThreadSettingsResult, | type ChangeThreadSettingsResult, | ||||
type RemoveMembersRequest, | type RemoveMembersRequest, | ||||
type LeaveThreadRequest, | type LeaveThreadRequest, | ||||
type LeaveThreadResult, | type LeaveThreadResult, | ||||
type UpdateThreadRequest, | type UpdateThreadRequest, | ||||
type ServerThreadJoinRequest, | type ServerThreadJoinRequest, | ||||
type ThreadJoinResult, | type ThreadJoinResult, | ||||
type ToggleMessagePinRequest, | |||||
threadPermissions, | threadPermissions, | ||||
threadTypes, | threadTypes, | ||||
} from 'lib/types/thread-types.js'; | } from 'lib/types/thread-types.js'; | ||||
import { updateTypes } from 'lib/types/update-types.js'; | import { updateTypes } from 'lib/types/update-types.js'; | ||||
import { ServerError } from 'lib/utils/errors.js'; | import { ServerError } from 'lib/utils/errors.js'; | ||||
import { promiseAll } from 'lib/utils/promises.js'; | import { promiseAll } from 'lib/utils/promises.js'; | ||||
import { firstLine } from 'lib/utils/string-utils.js'; | import { firstLine } from 'lib/utils/string-utils.js'; | ||||
▲ Show 20 Lines • Show All 802 Lines • ▼ Show 20 Lines | updateDatas.push({ | ||||
threadID: threadID, | threadID: threadID, | ||||
targetSession: viewer.session, | targetSession: viewer.session, | ||||
}); | }); | ||||
} | } | ||||
await createUpdates(updateDatas); | await createUpdates(updateDatas); | ||||
} | } | ||||
async function toggleMessagePinForThread( | |||||
viewer: Viewer, | |||||
request: ToggleMessagePinRequest, | |||||
): Promise<void> { | |||||
tomek: How do we plan to inform other clients about message being pinned? Shouldn't we send some kind… | |||||
rohanAuthorUnsubmitted Done Inline ActionsYeah I plan to handle that in https://linear.app/comm/issue/ENG-3190/include-robotext-for-the-chat-when-a-message-is-pinned-and-unpinned rohan: Yeah I plan to handle that in https://linear.app/comm/issue/ENG-3190/include-robotext-for-the… | |||||
tomekUnsubmitted Not Done Inline ActionsA robotext message is only one part of this. But we have to make sure that clients get the info that a message is pinned so that they can display it as pinned. Do we plan to introduce a new update type? Or is the plan different? tomek: A robotext message is only one part of this. But we have to make sure that clients get the info… | |||||
rohanAuthorUnsubmitted Done Inline ActionsBetween our conversation on D6924 and here, I've created a task to handle this to not block review here. https://linear.app/comm/issue/ENG-3392/alert-the-client-of-a-message-pin-unpin rohan: Between our conversation on D6924 and here, I've created a task to handle this to not block… | |||||
const { messageID, threadID, isPinned } = request; | |||||
const hasPermission = await checkThreadPermission( | |||||
viewer, | |||||
threadID, | |||||
threadPermissions.MANAGE_PINS, | |||||
); | |||||
// Verify that the viewer has the proper credentials to manage pins | |||||
if (!hasPermission) { | |||||
throw new ServerError('invalid_credentials'); | |||||
} | |||||
// Toggle the pin status: if the message is pinned, unpin it, and vice versa | |||||
let togglePinQuery; | |||||
if (isPinned) { | |||||
togglePinQuery = SQL` | |||||
DELETE FROM pinned_messages | |||||
WHERE messageID = ${messageID} AND thread = ${threadID} | |||||
`; | |||||
} else { | |||||
togglePinQuery = SQL` | |||||
INSERT INTO pinned_messages (messageID, thread, pin_time) | |||||
VALUES (${messageID}, ${threadID}, ${Date.now()}) | |||||
`; | |||||
} | |||||
await dbQuery(togglePinQuery); | |||||
} | |||||
export { | export { | ||||
updateRole, | updateRole, | ||||
removeMembers, | removeMembers, | ||||
leaveThread, | leaveThread, | ||||
updateThread, | updateThread, | ||||
joinThread, | joinThread, | ||||
updateThreadMembers, | updateThreadMembers, | ||||
toggleMessagePinForThread, | |||||
}; | }; |
How do we plan to inform other clients about message being pinned? Shouldn't we send some kind of update?