Skip to content

Commit

Permalink
chats: post message example & changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
angelo-v committed Sep 10, 2024
1 parent e3918f0 commit 1ff3c10
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chats/rdflib/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions chats/rdflib/examples/post-message.mjs
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 1ff3c10

Please sign in to comment.