This commit is contained in:
Rory&
2025-11-26 17:20:57 +01:00
parent de4a1ed58b
commit ce3a46ed2c
+15 -9
View File
@@ -17,7 +17,7 @@
*/
import { route } from "@spacebar/api";
import { Snowflake, User, Message, Member, Channel, Permissions, timePromise, NewUrlUserSignatureData, Stopwatch } from "@spacebar/util";
import { Snowflake, User, Message, Member, Channel, Permissions, timePromise, NewUrlUserSignatureData, Stopwatch, Attachment } from "@spacebar/util";
import { Request, Response, Router } from "express";
import { In } from "typeorm";
@@ -182,14 +182,20 @@ router.get(
"referenced_message.attachments",
],
})
).map((m) =>
m.withSignedAttachments(
new NewUrlUserSignatureData({
ip: req.ip,
userAgent: req.headers["user-agent"] as string,
}),
).toJSON(),
);
).map((m) => {
return {
...m.toJSON(),
attachments: m.attachments?.map((attachment: Attachment) =>
Attachment.prototype.signUrls.call(
attachment,
new NewUrlUserSignatureData({
ip: req.ip,
userAgent: req.headers["user-agent"] as string,
}),
),
),
};
});
console.log(`[Inbox/mentions] User ${user.id} fetched full message data for ${finalMessages.length} messages in ${sw.elapsed().totalMilliseconds}ms`);