Set nick to chat

Hi everyone, i’m saving me jitsi chat in Amazon but i don’t know who wrote the message, there is a way to set nickname to the chat when start the meet automatically.

I was looking for that feature also. I think has something to do with Prosody

How are you saving?
You can try this lua module

We are using mod_muc_mam – Prosody IM and mariadb storage for easy reading.

Will try your lua module

local userName =  tostring(stanza[2][1]);

This line is trying to extract nick from message, which is not present in message anymore.

I know new versions does not have it. I will correct.

Thats the issue that its not in the Message…

Any idea ?

It was removed from lib-jitsi-meet.

1 Like

May be we can request Jitsi team to put it back ( of course we can also put back ourself) but having it in stable will be better. Or have to find another way to get the name.

I think it should me an option. I get privacy is a concern in public deployment but self hosted would be nice have the option.

I dont know what would take have this added (by us or by jitsi team)

@Tushar_Sharma I have fixed it in new branch.

1 Like

It seems that event.origin.jitsi_meet_context_user returns a nil value when the authentication type is “anonymous”. It works when it’s “token

I’ve tried to obtain participant’s display name in message/bare hook
The session seems to have the display name, but not sure how to obtain it from this table.

local get_room_by_name_and_subdomain = module:require "util".get_room_by_name_and_subdomain;
local jid = require "util.jid";

local full_jid = event.origin.full_jid;
local room = get_room_by_name_and_subdomain(
    event.origin.jitsi_web_query_room,
    event.origin.jitsi_web_query_prefix
);
local username = jid.split(full_jid);
local nick = string.sub(username, 0,8);
local occupant_id = room.jid..'/'..nick;
local occupant = room._occupants[occupant_id];
local session = occupant['sessions'][occupant.jid];

Can you check with module speaker stats.
You can see there how to get nick.

Let me check. AFAICT, the nick being referred to anywhere is actually just first 8 characters of a UUID, and what we really need is the displayName.

Edit: Room seems to have speakerStats, and I think I can try to obtain displayName from it. I’ll explore this.

I have explored speakerStats.

Couldn’t find displayName. Some tables have context_user having a name, but that’s just the name passed in JWT, and not what I’m looking for, specially since guests join without JWT and don’t have this context_user field.

I didn’t realize that I could do operations on the tables I’ve obtained.

I looked at mod_muc_size, and decided to try this, and was able to obtain the name.

for _, pr in occupant:each_session() do
    local displayName = pr:get_child_text("nick", "http://jabber.org/protocol/nick") or "";
    module:log('info', 'DISPLAY NAME: '..displayName);
end

Maybe I can shorten my previous methods by looking at some more operations available.

Edit:

This is currently the shortest I’m contended with, will explore better options later.

local get_room_by_name_and_subdomain = module:require "util".get_room_by_name_and_subdomain;

local room = get_room_by_name_and_subdomain(
    event.origin.jitsi_web_query_room,
    event.origin.jitsi_web_query_prefix
);
local username = event.origin.username;
local nick = string.sub(username, 0,8);
local occupant_id = room.jid..'/'..nick;
local occupant = room._occupants[occupant_id];
local displayName = nick;
for _, pr in occupant:each_session() do
    displayName = pr:get_child_text("nick", "http://jabber.org/protocol/nick") or nick;
end
module:log('info', 'DISPLAY NAME: '..tostring(displayName));

Thanks for looking on this… could you clarify a little bit more how we would implement this using muc_man to store the values in a database… I can see you get the nick and then log it but we need to have it in the message that is stored.

Thanks!

I can see that they are storing the whole stanza to an archive (muc_log) - is this a table?
https://hg.prosody.im/prosody-modules/file/264eab9d501c/mod_mam_muc/mod_mam_muc.lua#l422

Stanza doesn’t contain the nick now, so we can probably add it back by first looking for message sender in self._occupants and then adding the tag similar to line 405.

I’m not sure in what format they are stored in DB, so if this doesn’t work out for you, you can try modifying the body’s text to add the displayName to it.