PromucFlow_constructor/app/client/src/api/CommentsAPI.tsx
Nayan 6efe78479f
[Enhancement] Add link to unsubscribe from email notification for a comment thread (#5769)
* -added API to and template for unsubscribe  comment thread

* -changed public API url to make it sepratate from client public pages
-included the unsubscribe link to email body

* -made unsubscribe email notification API to private

* -added unsubscribe page

* -removed unused code

* Update app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Comments/UnsubscribeEmail_spec.js

Co-authored-by: Arpit Mohan <mohanarpit@users.noreply.github.com>

* Update app/client/src/pages/common/UnsubscribeEmail.tsx

Co-authored-by: Arpit Mohan <mohanarpit@users.noreply.github.com>

* Update app/client/src/pages/common/UnsubscribeEmail.tsx

Co-authored-by: Arpit Mohan <mohanarpit@users.noreply.github.com>

* Update app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/BaseAppsmithRepositoryImpl.java

Co-authored-by: Arpit Mohan <mohanarpit@users.noreply.github.com>

* -updated text as per lint error

* -updated text as per lint error

* -moved unsubscribe screen texts to messages.ts

Co-authored-by: Arpit Mohan <mohanarpit@users.noreply.github.com>
2021-07-20 00:14:38 +06:00

87 lines
2.4 KiB
TypeScript

import { AxiosPromise } from "axios";
import Api from "./Api";
import { ApiResponse } from "./ApiResponses";
import {
CreateCommentThreadRequest,
CreateCommentRequest,
} from "entities/Comments/CommentsInterfaces";
class CommentsApi extends Api {
static baseURL = "v1/comments";
static getThreadsAPI = `${CommentsApi.baseURL}/threads`;
static getCommentsAPI = CommentsApi.baseURL;
static getReactionsAPI = (commentId: string) =>
`${CommentsApi.getCommentsAPI}/${commentId}/reactions`;
static createNewThread(
request: CreateCommentThreadRequest,
): AxiosPromise<ApiResponse> {
return Api.post(CommentsApi.getThreadsAPI, request);
}
static createNewThreadComment(
request: CreateCommentRequest,
threadId: string,
): AxiosPromise<ApiResponse> {
return Api.post(CommentsApi.getCommentsAPI, request, {
threadId,
});
}
static fetchAppCommentThreads(
applicationId: string,
): AxiosPromise<ApiResponse> {
return Api.get(CommentsApi.getThreadsAPI, { applicationId });
}
static updateCommentThread(
updateCommentThreadRequest: Partial<CreateCommentThreadRequest>,
threadId: string,
): AxiosPromise<ApiResponse> {
return Api.put(
`${CommentsApi.getThreadsAPI}/${threadId}`,
updateCommentThreadRequest,
);
}
static updateComment(
updateCommentRequest: Partial<CreateCommentRequest>,
commentId: string,
): AxiosPromise<ApiResponse> {
return Api.put(
`${CommentsApi.getCommentsAPI}/${commentId}`,
updateCommentRequest,
);
}
static deleteComment(commentId: string): AxiosPromise<ApiResponse> {
return Api.delete(`${CommentsApi.getCommentsAPI}/${commentId}`);
}
static deleteCommentThread(threadId: string): AxiosPromise<ApiResponse> {
return Api.delete(`${CommentsApi.getThreadsAPI}/${threadId}`);
}
static unsubscribeCommentThread(threadId: string): AxiosPromise<ApiResponse> {
return Api.post(`${CommentsApi.getThreadsAPI}/${threadId}/unsubscribe`);
}
static addCommentReaction(
commentId: string,
request: { emoji: string },
): AxiosPromise<ApiResponse> {
return Api.post(CommentsApi.getReactionsAPI(commentId), request);
}
static removeCommentReaction(
commentId: string,
request: { emoji: string },
): AxiosPromise<ApiResponse> {
return Api.delete(CommentsApi.getReactionsAPI(commentId), null, {
data: request,
});
}
}
export default CommentsApi;