Deliver messages to all logged in resources of one user

1,560 views
Skip to first unread message

first last

unread,
Jul 25, 2011, 6:17:10 AM7/25/11
to Prosody IM Users
Hello!
Might someone please tell me if it possible to configure prosody in
the way that every logged in instance of an account (resource) gets
notified of new messages?
I'm online with my cellphone and computer at the same time, but when I
leave the house and forget to log off on my computer, I cannot read
messages until I log out and log in again with my mobile phone.
Is it possible? Somehow?
Many thanks!

Waqas Hussain

unread,
Jul 25, 2011, 8:24:48 AM7/25/11
to prosod...@googlegroups.com

Hi

Please try this three line plugin. Save it in a file named
"mod_message_forced_broadcast.lua" in the Prosody modules directory.
Load it in your config as "message_forced_broadcast". It forces all
messages meant for a specific resource to be broadcasted to all
resources.

If your mobile and PC clients have different presence priority
settings, then you might also want to use the
"ignore_presence_priority=true" config option.

The plugin:

-- mod_message_forced_broadcast.lua

prosody.events.add_handler('server-started', function()
next(modulemanager.unload.hooks:get(module.host,'message')['message/full']).full_sessions
= {}
end);

first last

unread,
Jul 25, 2011, 8:51:16 AM7/25/11
to prosod...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Prosody IM Users" group.
To post to this group, send an email to prosod...@googlegroups.com.
To unsubscribe from this group, send email to prosody-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/prosody-users?hl=en-GB.


That did the trick. Thank you very much! 

Matthew Wild

unread,
May 9, 2013, 5:05:17 AM5/9/13
to Prosody IM Users Group
Hi Jan,

On 9 May 2013 01:25, Jan Beerden <j...@janbeerden.be> wrote:
> Hello
>
> We have tried your plugin and it works just fine when we don't use muc.
> After enabling this plugin I get kicked out of muc as soon as I say
> something in it.
>
> Any thougts/suggestions?

Yes, try this version: http://prosody.im/files/mod_message_forced_broadcast.lua

Regards,
Matthew

Adam N.

unread,
Jul 14, 2013, 7:10:38 PM7/14/13
to prosod...@googlegroups.com
Is it possible to broadcast the outgoing message to all connected clients?  

Matthew Wild

unread,
Jul 14, 2013, 7:19:08 PM7/14/13
to Prosody IM Users Group
On 15 July 2013 00:10, Adam N. <adam.niescier...@gmail.com> wrote:
> Is it possible to broadcast the outgoing message to all connected clients?

Yes, but this requires client support. Take a look at mod_carbons for
this: https://code.google.com/p/prosody-modules/wiki/mod_carbons

It is a much nicer standards-compliant alternative to the hacky
plugins posted in the older messages of this 2 year-old thread.
Clients are still working on implementing it, but three example
clients I know of that already support it are: Gajim (desktop), Poezio
(console), Yaxim (Android). We should probably maintain a list on that
wiki page!

Hope this helps,
Matthew

Kim Alvefur

unread,
Jul 14, 2013, 7:58:48 PM7/14/13
to prosod...@googlegroups.com
On 2013-07-15 01:19, Matthew Wild wrote:
> We should probably maintain a list on that wiki page!

Added, along with a better description of the feature.

--
Kim "Zash" Alvefur

signature.asc

Adam N.

unread,
Jul 15, 2013, 3:37:05 PM7/15/13
to prosod...@googlegroups.com
 is there a way to broadcast outgoing  message to client not carbon aware?

Matthew Wild

unread,
Jul 15, 2013, 3:55:04 PM7/15/13
to Prosody IM Users Group
On 15 July 2013 20:37, Adam N. <adam.niescier...@gmail.com> wrote:
> is there a way to broadcast outgoing message to client not carbon aware?

No, not really. Prosody could send it, but from what address? To what
address? Whatever you do, the client will always think it is an
incoming message.

Carbons is what provides the marker so that clients can know "this is
an outgoing message" and display it correctly.

Regards,
Matthew

akademik nedelchev

unread,
Dec 29, 2014, 1:10:13 AM12/29/14
to prosod...@googlegroups.com, 31n3...@googlemail.com
Hi. Im running prosody on openwrt - tried to load the module but i got the following error.

root@Harrogath:/tmp# prosody
lua: ...lib/prosody/modules/mod_message_forced_broadcast.lua:27: attempt to index field 'hooks' (a nil value)
stack traceback:
        ...lib/prosody/modules/mod_message_forced_broadcast.lua:27: in function '?'
        /usr/lib/prosody/util/events.lua:67: in function 'fire_event'
        /usr/bin/prosody:401: in main chunk
        [C]: ?


here is my prosodyctl about output.

Prosody 0.9.4

# Prosody directories
Data directory:         /etc/prosody/data
Plugin directory:       /usr/lib/prosody/modules/
Config directory:       /etc/prosody
Source directory:       /usr/lib/prosody

# Lua environment
Lua version:                    Lua 5.1

Lua module search paths:
  /usr/lib/prosody/?.lua
  /usr/share/lua/?.lua
  /usr/share/lua/?/init.lua
  /usr/lib/lua/?.lua
  /usr/lib/lua/?/init.lua

Lua C module search paths:
  /usr/lib/prosody/?.so
  /usr/lib/lua/?.so
  /usr/lib/lua/loadall.so

LuaRocks:               Not installed

# Lua module versions
lfs:            LuaFileSystem 1.6.2
lxp:            LuaExpat 1.3.0
pposix:         0.3.6
socket:         LuaSocket 3.0-rc1
ssl:            0.4

root@Harrogath:/tmp# prosodyctl about
Prosody 0.9.4

# Prosody directories
Data directory:         /etc/prosody/data
Plugin directory:       /usr/lib/prosody/modules/
Config directory:       /etc/prosody
Source directory:       /usr/lib/prosody

# Lua environment
Lua version:                    Lua 5.1

Lua module search paths:
  /usr/lib/prosody/?.lua
  /usr/share/lua/?.lua
  /usr/share/lua/?/init.lua
  /usr/lib/lua/?.lua
  /usr/lib/lua/?/init.lua

Lua C module search paths:
  /usr/lib/prosody/?.so
  /usr/lib/lua/?.so
  /usr/lib/lua/loadall.so

LuaRocks:               Not installed

# Lua module versions
lfs:            LuaFileSystem 1.6.2
lxp:            LuaExpat 1.3.0
pposix:         0.3.6
socket:         LuaSocket 3.0-rc1
ssl:            0.4


Any help will be appreciated. Happy holidays!

Vermus Rus

unread,
Aug 15, 2015, 9:36:17 AM8/15/15
to Prosody IM Users

Kevin Long

unread,
Aug 31, 2015, 6:54:46 PM8/31/15
to Prosody IM Users

Ditto ..  Prosody 0.9.3 on Ubuntu will not start with this plugin enabled-- nothing in the debug log. Just won't start until I  removed the plugin.

Christopher Zamplas

unread,
Jan 21, 2017, 4:00:13 PM1/21/17
to Prosody IM Users
For posterity, in prosody 9.x you can get the functionality of this plugin to work by modifying mod_message and replacing the message/full function with the function from this patch. 

local jid_bare = require "util.jid".bare;

module:hook("message/full", function(data)
        local origin, stanza = data.origin, data.stanza;
        local type = stanza.attr.type;
        if type == "chat" or type == "headline" then -- Broadcast instead
                return process_to_bare(jid_bare(stanza.attr.to), origin, stanza);
        end
end, 0.9);

Some lua scope issues prevent the mod from working as it's own module, even if you switch the hook to module:global_hook() like it says to in the comments; I cba to actually learn lua/prosody enough to fix that.  This also completely breaks MUCs in prosody 0.9, so if you use those you may want to figure out how to merge this function into mod_message in a way that doesn't break MUCs.


Reply all
Reply to author
Forward
0 new messages