mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
feat(api): ✨ Add new admin emoji API
This commit is contained in:
parent
b979daa39a
commit
8fedd1a07d
20 changed files with 954 additions and 167 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { proxyUrl } from "@response";
|
||||
import { sanitizedHtmlStrip } from "@sanitization";
|
||||
import {
|
||||
type InferInsertModel,
|
||||
|
|
@ -442,7 +443,17 @@ export class Note {
|
|||
(mention) => mention.instanceId === null,
|
||||
);
|
||||
|
||||
let replacedContent = data.content;
|
||||
// Rewrite all src tags to go through proxy
|
||||
let replacedContent = new HTMLRewriter()
|
||||
.on("[src]", {
|
||||
element(element) {
|
||||
element.setAttribute(
|
||||
"src",
|
||||
proxyUrl(element.getAttribute("src") ?? "") ?? "",
|
||||
);
|
||||
},
|
||||
})
|
||||
.transform(data.content);
|
||||
|
||||
for (const mention of mentionedLocalUsers) {
|
||||
replacedContent = replacedContent.replace(
|
||||
|
|
|
|||
|
|
@ -407,6 +407,27 @@ export class User {
|
|||
return isLocal ? username : `${username}@${baseUrl}`;
|
||||
}
|
||||
|
||||
async update(data: Partial<typeof Users.$inferSelect>) {
|
||||
const updated = (
|
||||
await db
|
||||
.update(Users)
|
||||
.set({
|
||||
...data,
|
||||
updatedAt: new Date().toISOString(),
|
||||
})
|
||||
.where(eq(Users.id, this.id))
|
||||
.returning()
|
||||
)[0];
|
||||
|
||||
const newUser = await User.fromId(updated.id);
|
||||
|
||||
if (!newUser) throw new Error("User not found after update");
|
||||
|
||||
this.user = newUser.getUser();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
toAPI(isOwnAccount = false): APIAccount {
|
||||
const user = this.getUser();
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue