Skip to content

Commit f58dc65

Browse files
committed
Docs about Message.raw property
1 parent 9b1269c commit f58dc65

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"multikey",
6363
"nodeinfo",
6464
"phensley",
65+
"Pixelfed",
6566
"Tailscale",
6667
"unfollow",
6768
"unfollowed",

docs/concepts/message.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,39 @@ object.
389389

390390
[`Temporal.Instant`]: https://tc39.es/proposal-temporal/docs/instant.html
391391

392+
### Want more?
393+
394+
If you want more data from the message, you can get the raw object of
395+
the message through the `~Message.raw` property. It is an instance of one
396+
of [`Article`], [`ChatMessage`], [`Note`], or [`Question`] class (which are
397+
provided by Fedify). You can get the raw data from the object.
398+
399+
For example, if you want to get the location of the message (Pixelfed et al.
400+
provide the geo location of the message), you can get it through
401+
the `~Message.raw` property:
402+
403+
~~~~ typescript
404+
const location = await message.raw.getLocation();
405+
if (location instanceof Place) {
406+
console.log(location.name);
407+
console.log(location.latitude);
408+
console.log(location.longitude);
409+
}
410+
~~~~
411+
412+
In the above example, the [`Place`] class is declared by Fedify, so you need to
413+
install it and import it:
414+
415+
~~~~ typescript
416+
import { Place } from "@fedify/fedify/vocab";
417+
~~~~
418+
419+
[`Article`]: https://jsr.io/@fedify/fedify/doc/vocab/~/Article
420+
[`ChatMessage`]: https://jsr.io/@fedify/fedify/doc/vocab/~/ChatMessage
421+
[`Note`]: https://jsr.io/@fedify/fedify/doc/vocab/~/Note
422+
[`Question`]: https://jsr.io/@fedify/fedify/doc/vocab/~/Question
423+
[`Place`]: https://jsr.io/@fedify/fedify/doc/vocab/~/Place
424+
392425

393426
Deleting a message
394427
------------------

0 commit comments

Comments
 (0)