From 7a5f816c025e778923f3fcf08a38e726a622d73c Mon Sep 17 00:00:00 2001 From: Juan Garcia Date: Mon, 9 Dec 2024 10:19:53 +0100 Subject: [PATCH] Implement missing mutations for publications --- packages/client/src/actions/post.ts | 67 +++++++++++++++++++++++++++++ packages/graphql/src/post.ts | 21 +++++++++ 2 files changed, 88 insertions(+) diff --git a/packages/client/src/actions/post.ts b/packages/client/src/actions/post.ts index 84fcaab30..6b8d941d7 100644 --- a/packages/client/src/actions/post.ts +++ b/packages/client/src/actions/post.ts @@ -7,23 +7,29 @@ import type { DeletePostRequest, DeletePostResult, EditPostRequest, + HideReplyRequest, PostResult, UndoBookmarkPostRequest, UndoReactionRequest, UndoReactionResult, + UnhideReplyRequest, } from '@lens-protocol/graphql'; import { AddReactionMutation, BookmarkPostMutation, DeletePostMutation, EditPostMutation, + HideReplyMutation, PostMutation, + ReportPostMutation, RepostMutation, UndoBookmarkPostMutation, UndoReactionMutation, + UnhideReplyMutation, } from '@lens-protocol/graphql'; import type { ResultAsync } from '@lens-protocol/types'; +import type { ReportPostRequest } from '@lens-protocol/graphql'; import type { SessionClient } from '../clients'; import type { UnauthenticatedError, UnexpectedError } from '../errors'; @@ -189,3 +195,64 @@ export function undoBookmarkPost( ): ResultAsync { return client.mutation(UndoBookmarkPostMutation, { request }); } + +/** + * Hide a reply. + * + * ```ts + * const result = await hideReply(sessionClient, { + * post: post.id, + * }); + * ``` + * + * @param client - The session client. + * @param request - The mutation request. + * @returns void + */ +export function hideReply( + client: SessionClient, + request: HideReplyRequest, +): ResultAsync { + return client.mutation(HideReplyMutation, { request }); +} + +/** + * Unhide a reply. + * + * ```ts + * const result = await unhideReply(sessionClient, { + * post: post.id, + * }); + * ``` + * + * @param client - The session client. + * @param request - The mutation request. + * @returns void + */ +export function unhideReply( + client: SessionClient, + request: UnhideReplyRequest, +): ResultAsync { + return client.mutation(UnhideReplyMutation, { request }); +} + +/** + * Report a post + * + * ```ts + * const result = await reportPost(sessionClient, { + * reason: "SCAM", + * post: post.id, + * }); + * ``` + * + * @param client - The session client. + * @param request - The mutation request. + * @returns void + */ +export function reportPost( + client: SessionClient, + request: ReportPostRequest, +): ResultAsync { + return client.mutation(ReportPostMutation, { request }); +} diff --git a/packages/graphql/src/post.ts b/packages/graphql/src/post.ts index 36d2ebd0f..4fa8e3fb3 100644 --- a/packages/graphql/src/post.ts +++ b/packages/graphql/src/post.ts @@ -240,3 +240,24 @@ export const DeletePostMutation = graphql( [DeletePostResult], ); export type DeletePostRequest = RequestOf; + +export const HideReplyMutation = graphql( + `mutation HideReply($request: HideReplyRequest!) { + value: hideReply(request: $request) + }`, +); +export type HideReplyRequest = RequestOf; + +export const UnhideReplyMutation = graphql( + `mutation UnhideReply($request: UnhideReplyRequest!) { + value: unhideReply(request: $request) + }`, +); +export type UnhideReplyRequest = RequestOf; + +export const ReportPostMutation = graphql( + `mutation ReportPost($request: ReportPostRequest!) { + value: reportPost(request: $request) + }`, +); +export type ReportPostRequest = RequestOf;