Coder Social home page Coder Social logo

Comments (5)

youmad avatar youmad commented on June 9, 2024

@bp91 Actually the mod_admin_extra is not activated by default (at least until #187), so for using shared roster groups you need to additionally set EJABBERD_MOD_ADMIN_EXTRA to true. After merging #187 using of the special directive @all@ will be available in the following format:

DIRECTIVE@VIRTUALHOST:GROUPNAME@VIRTUALHOST

For example:

EJABBERD_GROUP_MEMBERS=@all@@example.com:[email protected]

from docker-ejabberd.

brunopistone avatar brunopistone commented on June 9, 2024

Hi @youmad, I found a parsing error into the script 30_ejabberd_setup_groups.sh, in the methods register_group_member and register_all_group_members:

register_group_member() {
    local user=$1
    local host=$2
    local group=$3
    local grouphost=$4

    echo "Adding ${user} ${host} to roster group ${group}@${grouphost}"
    # Do not exit if user is already a member
    ${EJABBERDCTL} srg_user_add ${user} ${host} ${group} ${grouphost} || true
}

register_all_group_members() {
    # register shared roster group members from environment $EJABBERD_GROUP_MEMBERS
    # Use whitespace to seperate groups.
    #
    # sample:
    # - add two users to groups:
    #   -e "[email protected]:[email protected] [email protected]:[email protected]"

    for member in ${EJABBERD_GROUP_MEMBERS} ; do
        local user=${member%%:*}
        local group=${member#*:}

        if [ $user = @all@ ]
        then
            local username=@all@
            local userhost=${user#*@}
        else
            local username=${user%%@*}
            local userhost=${user#*@}
        fi

        local groupname=${group%%@*}
        local grouphost=${group#*@}


        echo 'user: ' $user
        echo 'group: ' $group
        echo 'username: ' $username
        echo 'userhost: ' $userhost
        echo 'groupname: ' $groupname
        echo 'grouphost: ' $grouphost

        register_group_member ${username} ${userhost} ${groupname} ${grouphost}
    done
}

The problem now is solved, I don't know if you want to insert this in the repo. I can close. Thanks.

from docker-ejabberd.

youmad avatar youmad commented on June 9, 2024

@bp91 similar corrections are present here: https://github.com/rroemhild/docker-ejabberd/pull/187/files#diff-c60c65c4756d6a1b70d29ddcd05e8728

from docker-ejabberd.

brunopistone avatar brunopistone commented on June 9, 2024

Great, in register_all_group_members() should be local username=${user%%@*} instead of local username=${user%@*}. Thanks again

from docker-ejabberd.

youmad avatar youmad commented on June 9, 2024

With ${user%%@*} it doesn't match @all@ directive:

$ cat test.sh 
#!/bin/bash
set -e

register_all_group_members() {
    echo '----------'
    for member in ${EJABBERD_GROUP_MEMBERS} ; do
        local user=${member%%:*}
        local group=${member#*:}

        local username=${user%%@*}
        local userhost=${user##*@}

        local groupname=${group%@*}
        local grouphost=${group##*@}

        echo 'username: ' $username
        echo 'userhost: ' $userhost
        echo 'groupname: ' $groupname
        echo 'grouphost: ' $grouphost
        echo '----------'
    done
}

register_all_group_members
exit 0

$ EJABBERD_GROUP_MEMBERS='[email protected]:[email protected] [email protected]:[email protected] @all@@example.com:[email protected]' ./test.sh 
----------
username:  user
userhost:  xmpp.kx.gd
groupname:  group
grouphost:  xmpp.kx.gd
----------
username:  user2
userhost:  xmpp.kx.gd
groupname:  group
grouphost:  xmpp.kx.gd
----------
username: 
userhost:  example.com
groupname:  group
grouphost:  example.com
----------

with local username=${user%@*} it does:

$ cat test.sh
#!/bin/bash
set -e

register_all_group_members() {
    echo '----------'
    for member in ${EJABBERD_GROUP_MEMBERS} ; do
        local user=${member%%:*}
        local group=${member#*:}

        local username=${user%@*}
        local userhost=${user##*@}

        local groupname=${group%@*}
        local grouphost=${group##*@}

        echo 'username: ' $username
        echo 'userhost: ' $userhost
        echo 'groupname: ' $groupname
        echo 'grouphost: ' $grouphost
        echo '----------'
    done
}

register_all_group_members
exit 0

$ EJABBERD_GROUP_MEMBERS='[email protected]:[email protected] [email protected]:[email protected] @all@@example.com:[email protected]' ./test.sh
----------
username:  user
userhost:  xmpp.kx.gd
groupname:  group
grouphost:  xmpp.kx.gd
----------
username:  user2
userhost:  xmpp.kx.gd
groupname:  group
grouphost:  xmpp.kx.gd
----------
username:  @all@
userhost:  example.com
groupname:  group
grouphost:  example.com
----------

from docker-ejabberd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.