On 7 June 2011 22:23, udd <nikla...@gmail.com> wrote:
> Hello!
>
> First of all, thank you for this great piece of software. It rocks! :)
>
Thanks! :)
> I manage a web site which have a bunch of users divided into different
> groups. I would like to XMPP enable the site (with Prosody). My plan
> is that a user should be able to log in with XMPP and then
> automatically get a contact list with the users they are in the same
> group(s) as. I think I solved that part with the help of mod_groups.
> However, I would also like to create a groupchat for each of these
> groups.
>
> Do you have any recommendations regarding this? Is it possible to do
> this within Prosody in some way? An alternative I have thought about
> is to use an XMPP client library to create a program that is triggered
> when a new user is registered. It would log in as an admin and invite
> the new user to the correct groups, and then log in as the new user
> and accept all invitations. However, it would be a bit cumbersome (and
> there might be problems with it I haven't anticipated).
>
It sounds like you're 90% of the way there with mod_groups and
mod_group_bookmarks. I agree that using a client to manage the rooms
would be a bit cumbersome.
I'm not 100% sure what the last problem is that you're trying to solve
exactly is. You mention clients having to accept invites - there are
no invites used by mod_group_bookmarks. It works by inserting the room
into the user's room bookmarks store on the server. This is fetched at
login by most clients to display a list of rooms to join and/or
automatically join them at startup.
For the actual room management (e.g. if you want to limit access to
people in the group) then I think a slightly modified mod_muc would be
the best approach. It would fetch the members list from
mod_group_bookmarks (so you don't have to define the groups again).
Thoughts?
Regards,
Matthew
Inviting a user to a room is literally just that - sending them a
message suggesting they join, they can ignore it, or accept it and
join.
As a bit of additional cleverness, Prosody detects when you invite
someone to a members-only room who is not on the member list. It
automatically adds them so that if they accept, they can join without
problems.
mod_group_bookmarks replaces just the manual invite part - it gives
the client the list of rooms it can join as bookmarks so that it can
choose join itself, without needing invitations. What
mod_group_bookmarks doesn't do (currently) is the membership thing.
>> For the actual room management (e.g. if you want to limit access to
>> people in the group) then I think a slightly modified mod_muc would be
>> the best approach. It would fetch the members list from
>> mod_group_bookmarks (so you don't have to define the groups again).
>
> This solution sounds really nice. It would allow me to fully define
> the rooms and their members in the mod_group_bookmarks file, which is
> basically what I would like to do. Do you from the top of your head
> have any ideas for the best approach for doing the modifications? I
> have just briefly looked at the code for mod_muc so far.
>
I had a look just now and decided to do it a slightly different (and
much simpler) way. I came up with the following code at the end of
mod_group_bookmarks:
local muc_new_room = module:require("muc").new_room;
prosody.events.add_handler("server-started", function ()
for room, members in pairs(rooms) do
local room_name, room_host = jid.prepped_split(room);
if room_name and hosts[room_host] then
local room_jid = room_name.."@"..room_host;
local muc_module = hosts[room_host].modules.muc;
if muc_module
and not muc_module.rooms[room_jid] then
local room = muc_new_room(room_jid);
for member in pairs(members) do
room._affiliations[member] = "member";
end
muc_module.rooms[room_jid] = room;
end
end
end
end);
But note that this is *completely* untested, I haven't even tried to
run it yet, but it's at least a start. If you can and want to pick
this up from here, feel free. I have a release to get out and some
other stuff to do before I'll have time to test it myself.
If we get this working then I think it would be good to put a config
option around it and add it to mod_group_bookmarks in prosody-modules.
Hope this helps,
Matthew