--- /dev/null
+/**
+ * Creates a new comment.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
+
+type Response = {
+ commentID: number;
+};
+
+export async function createComment(
+ objectTypeId: number,
+ objectId: number,
+ message: string,
+ guestToken: string = "",
+): Promise<ApiResult<Response>> {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments`);
+
+ const payload = {
+ objectTypeID: objectTypeId,
+ objectID: objectId,
+ message,
+ guestToken,
+ };
+
+ let response: Response;
+ try {
+ response = (await prepareRequest(url).post(payload).fetchAsJson()) as Response;
+ } catch (e) {
+ return apiResultFromError(e);
+ }
+
+ return apiResultFromValue(response);
+}
--- /dev/null
+/**
+ * Deletes a comment.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
+
+export async function deleteComment(commentId: number): Promise<ApiResult<[]>> {
+ try {
+ await prepareRequest(`${window.WSC_API_URL}index.php?api/rpc/core/comments/${commentId}`).delete().fetchAsJson();
+ } catch (e) {
+ return apiResultFromError(e);
+ }
+
+ return apiResultFromValue([]);
+}
--- /dev/null
+/**
+ * Gets the html code for the editing of a comment.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
+
+type Response = {
+ template: string;
+};
+
+export async function editComment(commentId: number): Promise<ApiResult<Response>> {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments/${commentId}/edit`);
+
+ let response: Response;
+ try {
+ response = (await prepareRequest(url).get().fetchAsJson()) as Response;
+ } catch (e) {
+ return apiResultFromError(e);
+ }
+
+ return apiResultFromValue(response);
+}
--- /dev/null
+/**
+ * Enables a comment.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
+
+export async function enableComment(commentId: number): Promise<ApiResult<[]>> {
+ try {
+ await prepareRequest(`${window.WSC_API_URL}index.php?api/rpc/core/comments/${commentId}/enable`)
+ .post()
+ .fetchAsJson();
+ } catch (e) {
+ return apiResultFromError(e);
+ }
+
+ return apiResultFromValue([]);
+}
--- /dev/null
+/**
+ * Gets the html code for the rendering of a comment.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
+
+type Response = {
+ template: string;
+ response: string | undefined;
+};
+
+export async function renderComment(
+ commentId: number,
+ responseId: number | undefined = undefined,
+ messageOnly: boolean = false,
+ objectTypeId: number | undefined = undefined,
+): Promise<ApiResult<Response>> {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments/${commentId}/render`);
+ url.searchParams.set("messageOnly", messageOnly.toString());
+ if (responseId !== undefined) {
+ url.searchParams.set("responseID", responseId.toString());
+ }
+ if (objectTypeId !== undefined) {
+ url.searchParams.set("objectTypeID", objectTypeId.toString());
+ }
+
+ let response: Response;
+ try {
+ response = (await prepareRequest(url).get().fetchAsJson()) as Response;
+ } catch (e) {
+ return apiResultFromError(e);
+ }
+
+ return apiResultFromValue(response);
+}
--- /dev/null
+/**
+ * Gets the html code for the rendering of comments.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
+
+type Response = {
+ template: string;
+ lastCommentTime: number;
+};
+
+export async function renderComments(
+ objectTypeId: number,
+ objectId: number,
+ lastCommentTime: number = 0,
+): Promise<ApiResult<Response>> {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments/render`);
+ url.searchParams.set("objectTypeID", objectTypeId.toString());
+ url.searchParams.set("objectID", objectId.toString());
+ url.searchParams.set("lastCommentTime", lastCommentTime.toString());
+
+ let response: Response;
+ try {
+ response = (await prepareRequest(url).get().fetchAsJson()) as Response;
+ } catch (e) {
+ return apiResultFromError(e);
+ }
+
+ return apiResultFromValue(response);
+}
--- /dev/null
+/**
+ * Creates a new comment response.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../../Result";
+
+type Response = {
+ responseID: number;
+};
+
+export async function createResponse(
+ commentId: number,
+ message: string,
+ guestToken: string = "",
+): Promise<ApiResult<Response>> {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments/responses`);
+
+ const payload = {
+ commentID: commentId,
+ message,
+ guestToken,
+ };
+
+ let response: Response;
+ try {
+ response = (await prepareRequest(url).post(payload).fetchAsJson()) as Response;
+ } catch (e) {
+ return apiResultFromError(e);
+ }
+
+ return apiResultFromValue(response);
+}
--- /dev/null
+/**
+ * Deletes a comment response.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../../Result";
+
+export async function deleteResponse(responseId: number): Promise<ApiResult<[]>> {
+ try {
+ await prepareRequest(`${window.WSC_API_URL}index.php?api/rpc/core/comments/responses/${responseId}`)
+ .delete()
+ .fetchAsJson();
+ } catch (e) {
+ return apiResultFromError(e);
+ }
+
+ return apiResultFromValue([]);
+}
--- /dev/null
+/**
+ * Gets the html code for the editing of a comment response.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../../Result";
+
+type Response = {
+ template: string;
+};
+
+export async function editResponse(responseId: number): Promise<ApiResult<Response>> {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments/responses/${responseId}/edit`);
+
+ let response: Response;
+ try {
+ response = (await prepareRequest(url).get().fetchAsJson()) as Response;
+ } catch (e) {
+ return apiResultFromError(e);
+ }
+
+ return apiResultFromValue(response);
+}
--- /dev/null
+/**
+ * Enables a comment response.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../../Result";
+
+export async function enableResponse(responseId: number): Promise<ApiResult<[]>> {
+ try {
+ await prepareRequest(`${window.WSC_API_URL}index.php?api/rpc/core/comments/responses/${responseId}/enable`)
+ .post()
+ .fetchAsJson();
+ } catch (e) {
+ return apiResultFromError(e);
+ }
+
+ return apiResultFromValue([]);
+}
--- /dev/null
+/**
+ * Gets the html code for the rendering of a response.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../../Result";
+
+type Response = {
+ template: string;
+};
+
+export async function renderResponse(
+ responseId: number,
+ messageOnly: boolean = false,
+ objectTypeId: number | undefined = undefined,
+): Promise<ApiResult<Response>> {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments/responses/${responseId}/render`);
+ url.searchParams.set("messageOnly", messageOnly.toString());
+ if (objectTypeId !== undefined) {
+ url.searchParams.set("objectTypeID", objectTypeId.toString());
+ }
+
+ let response: Response;
+ try {
+ response = (await prepareRequest(url).get().fetchAsJson()) as Response;
+ } catch (e) {
+ return apiResultFromError(e);
+ }
+
+ return apiResultFromValue(response);
+}
--- /dev/null
+/**
+ * Gets the html code for the rendering of responses.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../../Result";
+
+type Response = {
+ lastResponseTime: number;
+ lastResponseID: number;
+ template: string;
+};
+
+export async function renderResponses(
+ commentId: number,
+ lastResponseTime: number,
+ lastResponseId: number,
+ loadAllResponses: boolean,
+): Promise<ApiResult<Response>> {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments/responses/render`);
+ url.searchParams.set("commentID", commentId.toString());
+ url.searchParams.set("lastResponseTime", lastResponseTime.toString());
+ url.searchParams.set("lastResponseID", lastResponseId.toString());
+ url.searchParams.set("loadAllResponses", loadAllResponses.toString());
+
+ let response: Response;
+ try {
+ response = (await prepareRequest(url).get().fetchAsJson()) as Response;
+ } catch (e) {
+ return apiResultFromError(e);
+ }
+
+ return apiResultFromValue(response);
+}
--- /dev/null
+/**
+ * Updates a comment response.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../../Result";
+
+export async function updateResponse(responseId: number, message: string): Promise<ApiResult<[]>> {
+ try {
+ await prepareRequest(`${window.WSC_API_URL}index.php?api/rpc/core/comments/responses/${responseId}`)
+ .post({
+ message,
+ })
+ .fetchAsJson();
+ } catch (e) {
+ return apiResultFromError(e);
+ }
+
+ return apiResultFromValue([]);
+}
--- /dev/null
+/**
+ * Updates a comment.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
+
+export async function updateComment(commentId: number, message: string): Promise<ApiResult<[]>> {
+ try {
+ await prepareRequest(`${window.WSC_API_URL}index.php?api/rpc/core/comments/${commentId}`)
+ .post({
+ message,
+ })
+ .fetchAsJson();
+ } catch (e) {
+ return apiResultFromError(e);
+ }
+
+ return apiResultFromValue([]);
+}
--- /dev/null
+/**
+ * Creates a new comment.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../Result"], function (require, exports, Backend_1, Result_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.createComment = void 0;
+ async function createComment(objectTypeId, objectId, message, guestToken = "") {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments`);
+ const payload = {
+ objectTypeID: objectTypeId,
+ objectID: objectId,
+ message,
+ guestToken,
+ };
+ let response;
+ try {
+ response = (await (0, Backend_1.prepareRequest)(url).post(payload).fetchAsJson());
+ }
+ catch (e) {
+ return (0, Result_1.apiResultFromError)(e);
+ }
+ return (0, Result_1.apiResultFromValue)(response);
+ }
+ exports.createComment = createComment;
+});
--- /dev/null
+/**
+ * Deletes a comment.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../Result"], function (require, exports, Backend_1, Result_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.deleteComment = void 0;
+ async function deleteComment(commentId) {
+ try {
+ await (0, Backend_1.prepareRequest)(`${window.WSC_API_URL}index.php?api/rpc/core/comments/${commentId}`).delete().fetchAsJson();
+ }
+ catch (e) {
+ return (0, Result_1.apiResultFromError)(e);
+ }
+ return (0, Result_1.apiResultFromValue)([]);
+ }
+ exports.deleteComment = deleteComment;
+});
--- /dev/null
+/**
+ * Gets the html code for the editing of a comment.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../Result"], function (require, exports, Backend_1, Result_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.editComment = void 0;
+ async function editComment(commentId) {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments/${commentId}/edit`);
+ let response;
+ try {
+ response = (await (0, Backend_1.prepareRequest)(url).get().fetchAsJson());
+ }
+ catch (e) {
+ return (0, Result_1.apiResultFromError)(e);
+ }
+ return (0, Result_1.apiResultFromValue)(response);
+ }
+ exports.editComment = editComment;
+});
--- /dev/null
+/**
+ * Enables a comment.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../Result"], function (require, exports, Backend_1, Result_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.enableComment = void 0;
+ async function enableComment(commentId) {
+ try {
+ await (0, Backend_1.prepareRequest)(`${window.WSC_API_URL}index.php?api/rpc/core/comments/${commentId}/enable`)
+ .post()
+ .fetchAsJson();
+ }
+ catch (e) {
+ return (0, Result_1.apiResultFromError)(e);
+ }
+ return (0, Result_1.apiResultFromValue)([]);
+ }
+ exports.enableComment = enableComment;
+});
--- /dev/null
+/**
+ * Gets the html code for the rendering of a comment.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../Result"], function (require, exports, Backend_1, Result_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.renderComment = void 0;
+ async function renderComment(commentId, responseId = undefined, messageOnly = false, objectTypeId = undefined) {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments/${commentId}/render`);
+ url.searchParams.set("messageOnly", messageOnly.toString());
+ if (responseId !== undefined) {
+ url.searchParams.set("responseID", responseId.toString());
+ }
+ if (objectTypeId !== undefined) {
+ url.searchParams.set("objectTypeID", objectTypeId.toString());
+ }
+ let response;
+ try {
+ response = (await (0, Backend_1.prepareRequest)(url).get().fetchAsJson());
+ }
+ catch (e) {
+ return (0, Result_1.apiResultFromError)(e);
+ }
+ return (0, Result_1.apiResultFromValue)(response);
+ }
+ exports.renderComment = renderComment;
+});
--- /dev/null
+/**
+ * Gets the html code for the rendering of comments.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../Result"], function (require, exports, Backend_1, Result_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.renderComments = void 0;
+ async function renderComments(objectTypeId, objectId, lastCommentTime = 0) {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments/render`);
+ url.searchParams.set("objectTypeID", objectTypeId.toString());
+ url.searchParams.set("objectID", objectId.toString());
+ url.searchParams.set("lastCommentTime", lastCommentTime.toString());
+ let response;
+ try {
+ response = (await (0, Backend_1.prepareRequest)(url).get().fetchAsJson());
+ }
+ catch (e) {
+ return (0, Result_1.apiResultFromError)(e);
+ }
+ return (0, Result_1.apiResultFromValue)(response);
+ }
+ exports.renderComments = renderComments;
+});
--- /dev/null
+/**
+ * Creates a new comment response.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../../Result"], function (require, exports, Backend_1, Result_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.createResponse = void 0;
+ async function createResponse(commentId, message, guestToken = "") {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments/responses`);
+ const payload = {
+ commentID: commentId,
+ message,
+ guestToken,
+ };
+ let response;
+ try {
+ response = (await (0, Backend_1.prepareRequest)(url).post(payload).fetchAsJson());
+ }
+ catch (e) {
+ return (0, Result_1.apiResultFromError)(e);
+ }
+ return (0, Result_1.apiResultFromValue)(response);
+ }
+ exports.createResponse = createResponse;
+});
--- /dev/null
+/**
+ * Deletes a comment response.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../../Result"], function (require, exports, Backend_1, Result_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.deleteResponse = void 0;
+ async function deleteResponse(responseId) {
+ try {
+ await (0, Backend_1.prepareRequest)(`${window.WSC_API_URL}index.php?api/rpc/core/comments/responses/${responseId}`)
+ .delete()
+ .fetchAsJson();
+ }
+ catch (e) {
+ return (0, Result_1.apiResultFromError)(e);
+ }
+ return (0, Result_1.apiResultFromValue)([]);
+ }
+ exports.deleteResponse = deleteResponse;
+});
--- /dev/null
+/**
+ * Gets the html code for the editing of a comment response.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../../Result"], function (require, exports, Backend_1, Result_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.editResponse = void 0;
+ async function editResponse(responseId) {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments/responses/${responseId}/edit`);
+ let response;
+ try {
+ response = (await (0, Backend_1.prepareRequest)(url).get().fetchAsJson());
+ }
+ catch (e) {
+ return (0, Result_1.apiResultFromError)(e);
+ }
+ return (0, Result_1.apiResultFromValue)(response);
+ }
+ exports.editResponse = editResponse;
+});
--- /dev/null
+/**
+ * Enables a comment response.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../../Result"], function (require, exports, Backend_1, Result_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.enableResponse = void 0;
+ async function enableResponse(responseId) {
+ try {
+ await (0, Backend_1.prepareRequest)(`${window.WSC_API_URL}index.php?api/rpc/core/comments/responses/${responseId}/enable`)
+ .post()
+ .fetchAsJson();
+ }
+ catch (e) {
+ return (0, Result_1.apiResultFromError)(e);
+ }
+ return (0, Result_1.apiResultFromValue)([]);
+ }
+ exports.enableResponse = enableResponse;
+});
--- /dev/null
+/**
+ * Gets the html code for the rendering of a response.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../../Result"], function (require, exports, Backend_1, Result_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.renderResponse = void 0;
+ async function renderResponse(responseId, messageOnly = false, objectTypeId = undefined) {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments/responses/${responseId}/render`);
+ url.searchParams.set("messageOnly", messageOnly.toString());
+ if (objectTypeId !== undefined) {
+ url.searchParams.set("objectTypeID", objectTypeId.toString());
+ }
+ let response;
+ try {
+ response = (await (0, Backend_1.prepareRequest)(url).get().fetchAsJson());
+ }
+ catch (e) {
+ return (0, Result_1.apiResultFromError)(e);
+ }
+ return (0, Result_1.apiResultFromValue)(response);
+ }
+ exports.renderResponse = renderResponse;
+});
--- /dev/null
+/**
+ * Gets the html code for the rendering of responses.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../../Result"], function (require, exports, Backend_1, Result_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.renderResponses = void 0;
+ async function renderResponses(commentId, lastResponseTime, lastResponseId, loadAllResponses) {
+ const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/comments/responses/render`);
+ url.searchParams.set("commentID", commentId.toString());
+ url.searchParams.set("lastResponseTime", lastResponseTime.toString());
+ url.searchParams.set("lastResponseID", lastResponseId.toString());
+ url.searchParams.set("loadAllResponses", loadAllResponses.toString());
+ let response;
+ try {
+ response = (await (0, Backend_1.prepareRequest)(url).get().fetchAsJson());
+ }
+ catch (e) {
+ return (0, Result_1.apiResultFromError)(e);
+ }
+ return (0, Result_1.apiResultFromValue)(response);
+ }
+ exports.renderResponses = renderResponses;
+});
--- /dev/null
+/**
+ * Updates a comment response.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../../Result"], function (require, exports, Backend_1, Result_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.updateResponse = void 0;
+ async function updateResponse(responseId, message) {
+ try {
+ await (0, Backend_1.prepareRequest)(`${window.WSC_API_URL}index.php?api/rpc/core/comments/responses/${responseId}`)
+ .post({
+ message,
+ })
+ .fetchAsJson();
+ }
+ catch (e) {
+ return (0, Result_1.apiResultFromError)(e);
+ }
+ return (0, Result_1.apiResultFromValue)([]);
+ }
+ exports.updateResponse = updateResponse;
+});
--- /dev/null
+/**
+ * Updates a comment.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ * @woltlabExcludeBundle tiny
+ */
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../Result"], function (require, exports, Backend_1, Result_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.updateComment = void 0;
+ async function updateComment(commentId, message) {
+ try {
+ await (0, Backend_1.prepareRequest)(`${window.WSC_API_URL}index.php?api/rpc/core/comments/${commentId}`)
+ .post({
+ message,
+ })
+ .fetchAsJson();
+ }
+ catch (e) {
+ return (0, Result_1.apiResultFromError)(e);
+ }
+ return (0, Result_1.apiResultFromValue)([]);
+ }
+ exports.updateComment = updateComment;
+});