Page MenuHomePhabricator

D5749.id19117.diff
No OneTemporary

D5749.id19117.diff

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 === undefined) {
+ 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

Mime Type
text/plain
Expires
Mon, Nov 25, 7:22 AM (21 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578906
Default Alt Text
D5749.id19117.diff (1 KB)

Event Timeline