Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to specify custom prosody plugin files from the file system? #136

Open
anirbandas18 opened this issue Sep 12, 2024 · 7 comments
Open

Comments

@anirbandas18
Copy link

anirbandas18 commented Sep 12, 2024

Hi,

I want to use this new feature in order to specify my lua script files as custom prosody plugin into the prosody pod during execution of helm apply command using this jitsi-helm chart.

However, I am not sure how to make my actual lua script file which is the custom prosody plugin available to this jitsi-helm chart during helm apply command in order for this jitsi-helm chart to read the file and ultimately make it available it to the underlying prosody image via the stateful set type pod of prosody from this jitsi-helm chart.

Would you be kind enough to throw some light in to the configuration process for specifying this file from the file system to the helm chart when trying to use this feature?

@anirbandas18 anirbandas18 changed the title How to specify custom prosody plugin files? How to specify custom prosody plugin files from the file system? Sep 12, 2024
@spijet
Copy link
Collaborator

spijet commented Oct 8, 2024

Hello @anirbandas18!

In order to use this feature you first need to create a ConfigMap with your plugin files inside. Then you'll need to specify the ConfigMap name and files inside it like so:

prosody:
  extraVolumes:
    - name: prosody-modules
      configMap:
        # v Put your ConfigMap name here v #
        name: my-custom-prosody-plugins-configmap
  extraVolumeMounts:
    # Repeat this section for every plugin file...
    - name: prosody-modules
      subPath: mod_measure_client_presence.lua
      mountPath: /prosody-plugins-custom/mod_measure_client_presence.lua
    # ...or mount the whole ConfigMap like so:
    - name: prosody-modules
      mountPath: /prosody-plugins-custom

@Bananenbrot1
Copy link

Hey, I´m running into a similiar issue. I created a custom ConfigMap with my lua script. I send applied it to the cluster and referenced it in my prosody config like explained above.

When restarting prosody its not loading the module. I tried looking at the logs but nothing is mentioned. Do I need to define it somewhere else in my values.yaml file?

Thanks for all the hard work and the new release :)

@emrahcom
Copy link
Member

Can you see this Lua script inside /prosody-plugins-custom folder in Prosody container?
Can you see the related config in the generated Prosody config in the container?

@Bananenbrot1
Copy link

Yes, inside the container I can see the lua file in the /prosody-plugins-custom folder.

Here is the content:

local LOGLEVEL = "info"

-- Set this parameter in Prosody config if you dont want cascading updates for
-- affiliation. Cascading updates are needed when the authentication is enabled
-- in Jicofo.
local DISABLE_CASCADING_SET = module:get_option_boolean(
    "disable_cascading_set", false
)

local is_admin = require "core.usermanager".is_admin
local is_healthcheck_room = module:require "util".is_healthcheck_room
local timer = require "util.timer"
module:log(LOGLEVEL, "loaded")

local function _is_admin(jid)
    return is_admin(jid, module.host)
end

module:hook("muc-occupant-joined", function (event)
    local room, occupant = event.room, event.occupant

    if is_healthcheck_room(room.jid) or _is_admin(occupant.jid) then
        module:log(LOGLEVEL, "skip affiliation, %s", occupant.jid)
        return
    end

    if not event.origin.auth_token then
        module:log(LOGLEVEL, "skip affiliation, no token")
        return
    end

    local affiliation = "member"
    local context_user = event.origin.jitsi_meet_context_user

    if context_user then
        if context_user["affiliation"] == "owner" then
            affiliation = "owner"
        elseif context_user["affiliation"] == "moderator" then
            affiliation = "owner"
        elseif context_user["affiliation"] == "teacher" then
            affiliation = "owner"
        elseif context_user["moderator"] == "true" then
            affiliation = "owner"
        elseif context_user["moderator"] == true then
            affiliation = "owner"
        end
    end

    local i = 0
    local function setAffiliation()
        room:set_affiliation(true, occupant.bare_jid, affiliation)

        if DISABLE_CASCADING_SET then return end
        if i > 8 then return end

        i = i + 1
        timer.add_task(0.2 * i, setAffiliation)
    end
    setAffiliation()

    module:log(LOGLEVEL, "affiliation: %s", affiliation)
end)

And here are the mounts:

Mounts:                                                                                                                                                                                           config from config (rw)
config/data from prosody-data (rw)
prosody-plugins-custom/mod_token_affiliation.lua from prosody-modules (rw,path="mod_token_affiliation.lua)
var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-lr2zp (ro)

@emrahcom
Copy link
Member

Could you share the generated Prosody config?
Is token_affiliation enabled in this config?

@Bananenbrot1
Copy link

Bananenbrot1 commented Nov 11, 2024

The module does not seem to be enabled when checking my config files. Do I have to specify it in any other location, so that it gets enabled? Since this is a standart module from jitsi-contrib, which is already in the docker container under prosody-plugins-contrib. Would it make sense to somehow reference the jitsi-contrib one?

Here is my config file:

prosody:
  enabled: true
  useExternalProsody: false
  server:
  extraEnvFrom:
    # - secretRef:
    #     name: '{{ include "prosody.fullname" . }}-jibri'
    - secretRef:
        name: '{{ include "prosody.fullname" . }}-jicofo'
    # - secretRef:
    #     name: '{{ include "prosody.fullname" . }}-jigasi'
    - secretRef:
        name: '{{ include "prosody.fullname" . }}-jvb'
    - configMapRef:
        name: '{{ include "prosody.fullname" . }}-common'
  image:
    repository: jitsi/prosody
  
  extraVolumes:
    - name: prosody-modules
      configMap:
        name: prosody-modules
  extraVolumeMounts:
    - name: prosody-modules
      subPath: mod_token_affiliation.lua
      mountPath: /prosody-plugins-custom/mod_token_affiliation.lua

  # service:
  #   ports:
  # If Prosody c2s in needed on private net outside the cluster
  #     xmppc2snodePort: 30522
  custom:
    contInit:
      _10_config: ""
    defaults:
      _prosody_cfg_lua: ""
      _saslauthd_conf: ""
      _jitsi_meet_cfg_lua: ""
    tag: "stable-9111"

@emrahcom
Copy link
Member

You don't need to mount the module file since it is already in the official image but you should set XMPP_MUC_MODULES

See the handbook for details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants