Skip to content

Commit

Permalink
chats: assume a single leaf document with messages
Browse files Browse the repository at this point in the history
  • Loading branch information
angelo-v committed Sep 2, 2024
1 parent 841402d commit 7b2e910
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions chats/rdflib/src/module/ChatsModuleRdfLib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class ChatsModuleRdfLib implements ChatsModule {
const latestDay = await this.fetchLatestSubContainer(latestMonth);
if (!latestDay) return [];

const messagesDocument = await this.fetchLatestDocument(latestDay);
const messagesDocument = await this.fetchMessagesDocument(latestDay);

return new MessagesDocumentQuery(
chatNode,
Expand All @@ -82,15 +82,15 @@ export class ChatsModuleRdfLib implements ChatsModule {
return new DateContainerQuery(container, this.store).queryLatest();
}

private async fetchLatestDocument(container: NamedNode) {
private async fetchMessagesDocument(container: NamedNode) {
await this.support.fetchNode(container);

const contents = new ContainerQuery(container, this.store).queryContents();
const files = contents.filter(
(it) =>
!this.store.holds(it, rdf("type"), ldp("Container"), container.doc()),
);
const anyDocument = files[0]; // TODO actually get latest
const anyDocument = files[0]; // this assumes there is one and only one leaf document containing the chat messages (typically chat.ttl)
await this.support.fetchNode(anyDocument);
return anyDocument;
}
Expand Down

0 comments on commit 7b2e910

Please sign in to comment.