Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3359230
D5749.id19118.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
D5749.id19118.diff
View Options
diff --git a/keyserver/src/responders/message-responders.js b/keyserver/src/responders/message-responders.js
--- a/keyserver/src/responders/message-responders.js
+++ b/keyserver/src/responders/message-responders.js
@@ -9,10 +9,12 @@
messageTypes,
type SendTextMessageRequest,
type SendMultimediaMessageRequest,
+ type SendReactionMessageRequest,
type FetchMessageInfosResponse,
type FetchMessageInfosRequest,
defaultNumberPerThread,
type SendMessageResponse,
+ type ReactionMessageData,
} from 'lib/types/message-types';
import type { TextMessageData } from 'lib/types/messages/text';
import { threadPermissions } from 'lib/types/thread-types';
@@ -179,8 +181,52 @@
return { newMessageInfo };
}
+const sendReactionMessageRequestInputValidator = tShape({
+ threadID: t.String,
+ targetMessageID: t.String,
+ reaction: t.String,
+ unsettingReaction: t.Boolean,
+});
+async function reactionMessageCreationResponder(
+ viewer: Viewer,
+ input: any,
+): Promise<SendMessageResponse> {
+ const request: SendReactionMessageRequest = input;
+ await validateInput(viewer, sendReactionMessageRequestInputValidator, input);
+
+ const { threadID, targetMessageID, reaction, unsettingReaction } = request;
+
+ if (!targetMessageID || !reaction || !unsettingReaction) {
+ throw new ServerError('invalid_parameters');
+ }
+
+ const hasPermission = await checkThreadPermission(
+ viewer,
+ threadID,
+ threadPermissions.VOICED,
+ );
+ if (!hasPermission) {
+ throw new ServerError('invalid_parameters');
+ }
+
+ const messageData: ReactionMessageData = {
+ type: messageTypes.REACTION,
+ threadID,
+ creatorID: viewer.id,
+ time: Date.now(),
+ targetMessageID,
+ reaction,
+ unsettingReaction,
+ };
+
+ const rawMessageInfos = await createMessages(viewer, [messageData]);
+
+ return { newMessageInfo: rawMessageInfos[0] };
+}
+
export {
textMessageCreationResponder,
messageFetchResponder,
multimediaMessageCreationResponder,
+ reactionMessageCreationResponder,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 7:59 AM (21 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578982
Default Alt Text
D5749.id19118.diff (2 KB)
Attached To
Mode
D5749: [keyserver] introduced reactionMessageCreationResponder function to message responders
Attached
Detach File
Event Timeline
Log In to Comment