class XMPP::Bookmarks

Overview

Bookmarks is a high-level client for XEP-0048 - Bookmark Conformance and XEP-0402 - PEP Native Bookmarks.

A user's saved chat rooms (and URLs) are published to the well-known PEP node "storage:bookmarks" so all of the user's resources (and authorized contacts) share them. The PEP approach is the modern replacement for storing bookmarks in private XML storage (XEP-0049).

bookmarks = XMPP::Bookmarks.new(client) mine = XMPP::Stanza::Bookmarks.new room = XMPP::Stanza::BookmarkConference.new room.name = "Design"; room.jid = "[email protected]" room.autojoin = true mine.conferences << room bookmarks.publish(mine)

Incoming notifications are read from messages like any other extension:

client.on("message") do |s, p| if bookmarks = XMPP::Bookmarks.from_message(p.as(XMPP::Stanza::Message)) # bookmarks.conferences ... end end

See: https://xmpp.org/extensions/xep-0048.html and https://xmpp.org/extensions/xep-0402.html

Defined in:

xmpp/bookmarks.cr

Constant Summary

PEP_NODE = "storage:bookmarks"

The PEP node used for bookmarks (XEP-0402).

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(client : Client) #

[View source]

Class Method Detail

def self.from_message(message : Stanza::Message) : Stanza::Bookmarks | Nil #

from_message extracts the bookmarks from a PEP notification message, or nil when the message does not carry a bookmarks notification.


[View source]

Instance Method Detail

def publish(bookmarks : Stanza::Bookmarks) #

publish publishes the bookmarks to the client's own PEP node.


[View source]
def subscribe(jid : String) #

subscribe subscribes the client to another user's bookmarks node.


[View source]
def unsubscribe(jid : String) #

unsubscribe removes the client's subscription to a user's bookmarks node.


[View source]