diff --git a/chats/rdflib/CHANGELOG.md b/chats/rdflib/CHANGELOG.md index ee629d5..7f7b989 100644 --- a/chats/rdflib/CHANGELOG.md +++ b/chats/rdflib/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this module will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +- [postMessage](https://solid-contrib.github.io/data-modules/chats-rdflib-api/interfaces/ChatsModule.html#postMessage) + ## 0.4.0 - [readChat](https://solid-contrib.github.io/data-modules/chats-rdflib-api/interfaces/ChatsModule.html#readChat) diff --git a/chats/rdflib/examples/post-message.mjs b/chats/rdflib/examples/post-message.mjs new file mode 100644 index 0000000..fc614f8 --- /dev/null +++ b/chats/rdflib/examples/post-message.mjs @@ -0,0 +1,22 @@ +import ChatsModule from "../dist/index.js"; +import { Fetcher, graph, UpdateManager } from "rdflib"; +import { faker } from "@faker-js/faker"; + +const store = graph(); +const fetcher = new Fetcher(store); +const updater = new UpdateManager(store); + +const module = new ChatsModule({ store, fetcher, updater }); + +const chatUri = "http://localhost:3000/alice/public/chats/lobby/index.ttl#this"; + +await module.postMessage({ + chatUri, + text: `${faker.word.noun()} ${faker.word.verb()} ${faker.word.adverb()}`, + authorWebId: "https://localhost:3000/alice/profile/card#me" +}); + +const chat = await module.readChat(chatUri); + +console.log(chat.name); +console.table(chat.latestMessages); \ No newline at end of file