Skip to content

Commit

Permalink
feat(legacy): mark rejected moderations
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Jan 24, 2024
1 parent 153791b commit 226343b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/legacy/moderations/03.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ function MarkModerationProcessed({ moderation }: { moderation: Moderation }) {
<form
class="m-auto my-12 w-fit"
hx-patch={
app_hc.legacy.moderations[":id"].processed.$url({
app_hc.legacy.moderations[":id"].rejected.$url({
param: { id: moderation.id.toString() },
}).pathname
}
Expand Down
11 changes: 8 additions & 3 deletions src/legacy/moderations/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import env from ":common/env";
import type { Htmx_Header } from ":common/htmx";
import { Entity_Schema } from ":common/schema";
import type { Session_Context } from ":common/session";
import { moncomptepro_pg, schema } from ":database:moncomptepro";
import { moncomptepro_pg_database } from ":database:moncomptepro/middleware";
import { send_moderation_processed_email } from ":legacy/services/mcp_admin_api";
import { send_zammad_mail } from ":legacy/services/zammad_api";
import { userinfo_to_username } from ":ui/layout/main";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import { Hono } from "hono";
Expand All @@ -21,7 +23,7 @@ import { MODERATION_EVENTS } from "./event";

//

const moderation_router = new Hono()
const moderation_router = new Hono<Session_Context>()
.basePath("/:id")
.route("/comment", moderation_comment_router)
.get(
Expand Down Expand Up @@ -52,8 +54,11 @@ const moderation_router = new Hono()
[RESPONSE_TEXTAREA_ID]: z.string().trim(),
}),
),
async ({ text, req, notFound }) => {
async ({ text, req, notFound, redirect, var: { session } }) => {
const { id: moderation_id } = req.valid("param");
const userinfo = session.get("userinfo");
if (!userinfo) return redirect("/");
const username = userinfo_to_username(userinfo);
const {
[EMAIL_SUBJECT_INPUT_ID]: subject,
[RESPONSE_TEXTAREA_ID]: body,
Expand All @@ -71,7 +76,7 @@ const moderation_router = new Hono()
if (!moderation.ticket_id) return notFound();

await send_zammad_mail({
body: body.replace(/\n/g, "<br />"),
body: body.concat(`\n${username}`).replace(/\n/g, "<br />"),
subject,
ticket_id: moderation.ticket_id,
state: "closed",
Expand Down

0 comments on commit 226343b

Please sign in to comment.