Skip to content

Commit 1ff3c10

Browse files
committed
chats: post message example & changelog
1 parent e3918f0 commit 1ff3c10

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

chats/rdflib/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this module will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
66
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## Unreleased
9+
10+
- [postMessage](https://solid-contrib.github.io/data-modules/chats-rdflib-api/interfaces/ChatsModule.html#postMessage)
11+
812
## 0.4.0
913

1014
- [readChat](https://solid-contrib.github.io/data-modules/chats-rdflib-api/interfaces/ChatsModule.html#readChat)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import ChatsModule from "../dist/index.js";
2+
import { Fetcher, graph, UpdateManager } from "rdflib";
3+
import { faker } from "@faker-js/faker";
4+
5+
const store = graph();
6+
const fetcher = new Fetcher(store);
7+
const updater = new UpdateManager(store);
8+
9+
const module = new ChatsModule({ store, fetcher, updater });
10+
11+
const chatUri = "http://localhost:3000/alice/public/chats/lobby/index.ttl#this";
12+
13+
await module.postMessage({
14+
chatUri,
15+
text: `${faker.word.noun()} ${faker.word.verb()} ${faker.word.adverb()}`,
16+
authorWebId: "https://localhost:3000/alice/profile/card#me"
17+
});
18+
19+
const chat = await module.readChat(chatUri);
20+
21+
console.log(chat.name);
22+
console.table(chat.latestMessages);

0 commit comments

Comments
 (0)