more pk fixes

This commit is contained in:
MathMan05
2026-03-20 16:31:32 +01:00
committed by Rory&
parent 6068dc7ec8
commit 5ff3226555
5 changed files with 11 additions and 12 deletions
@@ -66,6 +66,7 @@ router.post(
},
route({
requestBody: "WebhookExecuteSchema",
stripNulls: true,
query: {
wait: {
type: "boolean",
+1
View File
@@ -773,6 +773,7 @@ export async function postHandleMessage(message: Message) {
const linkMatches = content?.match(LINK_REGEX) || [];
message.clean_data();
const data = { ...message.toJSON() };
console.log(message);
const currentNormalizedUrls = new Set<string>();
for (const link of linkMatches) {
+4 -4
View File
@@ -52,7 +52,7 @@ export interface RouteOptions {
body?: string;
};
};
stripNulls?: stripNulls;
stripNulls?: stripNulls | true;
event?: EVENT | EVENT[];
summary?: string;
description?: string;
@@ -75,7 +75,6 @@ export interface RouteOptions {
// };
}
export function stripNull(obj: object) {
console.log(Object.entries(obj));
for (const [key, value] of Object.entries(obj)) {
if (value instanceof Object || (value && !value.__proto__)) {
stripNull(value);
@@ -137,11 +136,12 @@ export function route(opts: RouteOptions) {
if (validate && !ignoredRequestSchemas.includes(opts.requestBody!)) {
if (opts.stripNulls) {
followNullPath(req.body, opts.stripNulls);
if (opts.stripNulls === true) stripNull(req.body);
else followNullPath(req.body, opts.stripNulls);
}
const valid = validate(req.body);
if (!valid) {
console.log(JSON.stringify(req.body));
//console.log(JSON.stringify(req.body));
const fields: Record<string, { code?: string; message: string }> = {};
validate.errors?.forEach(
(x) =>
+5 -3
View File
@@ -67,9 +67,11 @@ export class Attachment extends BaseClass {
url: getUrlSignature(new NewUrlSignatureData({ ...data, url: this.url }))
.applyToUrl(this.url)
.toString(),
proxy_url: getUrlSignature(new NewUrlSignatureData({ ...data, url: this.proxy_url }))
.applyToUrl(this.proxy_url)
.toString(),
proxy_url: this.proxy_url
? getUrlSignature(new NewUrlSignatureData({ ...data, url: this.proxy_url }))
.applyToUrl(this.proxy_url)
.toString()
: this.proxy_url,
};
}
}
-5
View File
@@ -134,17 +134,14 @@ export class Message extends BaseClass {
mention_everyone?: boolean;
@JoinTable({ name: "message_user_mentions" })
@JsonRemoveEmpty
@ManyToMany(() => User)
mentions: User[];
@JoinTable({ name: "message_role_mentions" })
@JsonRemoveEmpty
@ManyToMany(() => Role)
mention_roles: Role[];
@JoinTable({ name: "message_channel_mentions" })
@JsonRemoveEmpty
@ManyToMany(() => Channel)
mention_channels: Channel[];
@@ -156,11 +153,9 @@ export class Message extends BaseClass {
cascade: true,
orphanedRowAction: "delete",
})
@JsonRemoveEmpty
attachments?: Attachment[];
@Column({ type: "simple-json" })
@JsonRemoveEmpty
embeds: Embed[];
@Column({ type: "simple-json" })