Skip to content

Commit

Permalink
Use authenticated document loader
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Jan 11, 2025
1 parent dbd412f commit 269710e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/message-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,13 @@ export async function createMessage<T extends MessageClass, TContextData>(
else if (raw.content == null) {
throw new TypeError(`The raw.content is required.`);
}
const actor = await raw.getAttribution(session.context);
const documentLoader = await session.context.getDocumentLoader(session.bot);
const options = {
contextLoader: session.context.contextLoader,
documentLoader,
suppressError: true,
};
const actor = await raw.getAttribution(options);
if (actor == null) {
throw new TypeError(`The raw.attributionId is required.`);
}
Expand All @@ -299,21 +305,21 @@ export async function createMessage<T extends MessageClass, TContextData>(
const mentions: Actor[] = [];
const mentionedActorIds = new Set<string>();
const hashtags: Hashtag[] = [];
for await (const tag of raw.getTags(session.context)) {
for await (const tag of raw.getTags(options)) {
if (tag instanceof Mention && tag.href != null) {
const obj = await session.context.lookupObject(tag.href);
const obj = await session.context.lookupObject(tag.href, options);
if (isActor(obj)) mentions.push(obj);
mentionedActorIds.add(tag.href.href);
} else if (tag instanceof Hashtag) {
hashtags.push(tag);
}
}
const attachments: Document[] = [];
for await (const attachment of raw.getAttachments(session.context)) {
for await (const attachment of raw.getAttachments(options)) {
if (attachment instanceof Document) attachments.push(attachment);
}
if (replyTarget == null) {
const rt = await raw.getReplyTarget(session.context);
const rt = await raw.getReplyTarget(options);
if (
rt instanceof Article || rt instanceof ChatMessage ||
rt instanceof Note || rt instanceof Question
Expand Down

0 comments on commit 269710e

Please sign in to comment.