Display name in prosody module

Hello, i want to write prosody module to save chat history, i wrote this code:

local chat_history_dir = "/srv/chat/"

module:hook("message/bare", function(event)
               local stanza = event.stanza
               if stanza.name == "message" and tostring(stanza.attr.type) == "groupchat" then
                    file = io.open(chat_history_dir .. stanza.attr.to .. ".txt", "a+")
                    if not file then
                    module:log("info", tostring(stanza))
                    file:write(stanza.attr.from .. " : " .. stanza[1][1] .. "\n")

But in object stanza no information about display name in conference, stanza.attr.from is x9ltjbhogutho65r and similar values.
Is there any way to get display name?

I think you need to get the participant object, since the display name comes from presence.

How can i get this object?

You get the occupant from its jid and then jitsi-meet/mod_speakerstats_component.lua at dffa71666c2ea8695a29dacfe4d760a0abfd5c60 · jitsi/jitsi-meet · GitHub

How can i get occupant from jid and how can i get jid?)

@DmitruMoth in prosody module shared by @damencho you have in each function an object like this :

local room = event.room;
local occupant = event.occupant;

event object in message/bare does not have this fields.

module:hook("message/bare", function(event)
    for k, v in pairs(event) do
        module:log("info", tostring(k) .. ": " .. tostring(v))


info    origin: table: 0x563e355d5270
Jul 06 08:11:01 conference.domain:muc_chat_recording  info    stanza: <message to='test@conference.domain' from='l8x4q2hxbu3kktyg@guest.domain/fsdLl70t' type='groupchat'><body>f</body></message>

Look around the lua code in that folder, from the to='test@conference.domain' you can get the room, and you can get all occupants and find the one you need comparing the occupant jid with from='l8x4q2hxbu3kktyg@guest.domain/fsdLl70t'