Software /
code /
verse
File
plugins/blocking.lua @ 414:2a5eff919f4a
libs.hashes: Switch to moteus bgcrypto suite
Because LuaCrypto seems to be unmaintained and bgcrypto has PBKDF2
https://luarocks.org/modules/moteus/bgcrypto-lmd5
https://luarocks.org/modules/moteus/bgcrypto-sha
https://luarocks.org/modules/moteus/bgcrypto-hmac
https://luarocks.org/modules/moteus/bgcrypto-pbkdf2
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 20 May 2018 00:51:58 +0200 |
parent | 250:a5ac643a7fd6 |
line wrap: on
line source
local verse = require "verse"; local xmlns_blocking = "urn:xmpp:blocking"; function verse.plugins.blocking(stream) -- FIXME: Disco stream.blocking = {}; function stream.blocking:block_jid(jid, callback) stream:send_iq(verse.iq{type="set"} :tag("block", { xmlns = xmlns_blocking }) :tag("item", { jid = jid }) , function () return callback and callback(true); end , function () return callback and callback(false); end ); end function stream.blocking:unblock_jid(jid, callback) stream:send_iq(verse.iq{type="set"} :tag("unblock", { xmlns = xmlns_blocking }) :tag("item", { jid = jid }) , function () return callback and callback(true); end , function () return callback and callback(false); end ); end function stream.blocking:unblock_all_jids(callback) stream:send_iq(verse.iq{type="set"} :tag("unblock", { xmlns = xmlns_blocking }) , function () return callback and callback(true); end , function () return callback and callback(false); end ); end function stream.blocking:get_blocked_jids(callback) stream:send_iq(verse.iq{type="get"} :tag("blocklist", { xmlns = xmlns_blocking }) , function (result) local list = result:get_child("blocklist", xmlns_blocking); if not list then return callback and callback(false); end local jids = {}; for item in list:childtags() do jids[#jids+1] = item.attr.jid; end return callback and callback(jids); end , function (result) return callback and callback(false); end ); end end