Skip to content

Commit 89ae59b

Browse files
Mishignsarrazin
andauthored
[Assisntats reports] Minor fixes (#827)
* [Assisntats reports] Minor fixes * Update src/routes/settings/assistants/[assistantId]/+page.server.ts Co-authored-by: Nathan Sarrazin <sarrazin.nathan@gmail.com> --------- Co-authored-by: Nathan Sarrazin <sarrazin.nathan@gmail.com>
1 parent db943f9 commit 89ae59b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/routes/settings/assistants/[assistantId]/+page.server.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { base } from "$app/paths";
66
import { PUBLIC_ORIGIN, PUBLIC_SHARE_PREFIX } from "$env/static/public";
77
import { WEBHOOK_URL_REPORT_ASSISTANT } from "$env/static/private";
88
import { z } from "zod";
9+
import type { Assistant } from "$lib/types/Assistant";
910
async function assistantOnlyIfAuthor(locals: App.Locals, assistantId?: string) {
1011
const assistant = await collections.assistants.findOne({ _id: new ObjectId(assistantId) });
1112

@@ -88,18 +89,22 @@ export const actions: Actions = {
8889
const prefixUrl = PUBLIC_SHARE_PREFIX || `${PUBLIC_ORIGIN || url.origin}${base}`;
8990
const assistantUrl = `${prefixUrl}/assistant/${params.assistantId}`;
9091

91-
const assistant = await collections.assistants.findOne(
92+
const assistant = await collections.assistants.findOne<Pick<Assistant, "name">>(
9293
{ _id: new ObjectId(params.assistantId) },
9394
{ projection: { name: 1 } }
9495
);
9596

97+
const username = locals.user?.username;
98+
9699
const res = await fetch(WEBHOOK_URL_REPORT_ASSISTANT, {
97100
method: "POST",
98101
headers: {
99102
"Content-type": "application/json",
100103
},
101104
body: JSON.stringify({
102-
text: `Assistant <${assistantUrl}|${assistant?.name}> reported by <http://hf.co/${locals.user?.username}|${locals.user?.username}>. The following reason was given \n\n> ${result.data}`,
105+
text: `Assistant <${assistantUrl}|${assistant?.name}> reported by ${
106+
username ? `<http://hf.co/${username}|${username}>` : "non-logged in user"
107+
}.\n\n> ${result.data}`,
103108
}),
104109
});
105110

0 commit comments

Comments
 (0)