0

I am working on sending message to muc room via API http. I observed that it s possible by get_room_occupants users who has joined muc room.

Now, from ejabberd muc room I have found that team members are there but are not occupants of the team, thats why is shows this error Only occupants are allowed to send messages to the conference though being group members.

Is there any api which can connect me to muc and show me in occupants?

Ejabberd Version : 17.11 Installed on : ubuntu 16.04 Configuered DB : mysql

Ejaberd.yml

api_permissions:
  "console commands":
    from:
      - ejabberd_ctl
    who: all
    what: "*"
  "admin access":
    who: all
    what:
      - "*"
      - "!stop"
      - "!start"
  "public commands":
    who: all
    what:
      - "*"
commands_admin_access:
  - allow:
    - user: "xxx@yy.zz"
commands:
  add_commands:
    - status
    - registered_users
    - register
    - unregister
    - get_roster
    - connected_users
    - send_stanza_c2s
    - send_stanza
    - join_cluster
oauth_expire: 3600
oauth_access: all
Arpit Vaishnav
  • 4,739
  • 6
  • 39
  • 57

1 Answers1

1

An account with admin rights in the MUC service can send messages to any room, no need to be room occupant.

For example, with this configuration:

acl:
  admin:
    user:
      - "user1@localhost"
modules:
  mod_muc:
    access_admin:
      - allow: admin

I can execute this query, providing an account that exist and a room that exists, but that account is not occupant in that room:

$ ejabberdctl send_message groupchat user1@localhost room1@conference.localhost Sub Bodyyy

The occupants in that room receive the message:

<message to='user2@localhost/tka1'
    from='room1@conference.localhost'
    type='groupchat'
    id='1234779465623896577'>
  <body xml:lang='en'>Bodyyy</body>
  <subject xml:lang='en'>Sub</subject>
</message>

Alternatively, you can subscribe an account to a MUC room, and then that account is allowed to send messages to the room without being occupant. For example:

$ ejabberdctl subscribe_room user2@localhost/tka1 User2 room1@conference.localhost urn:xmpp:mucsub:nodes:messages
urn:xmpp:mucsub:nodes:messages

$ ejabberdctl send_message groupchat user2@localhost room1@conference.localhost Sub Bodyyy
Badlop
  • 3,840
  • 1
  • 8
  • 9
  • message is sent successfully, but will it prompt users who are online? Because if I open room again message history is there. Not when connected to room – Arpit Vaishnav Apr 27 '18 at 05:49
  • I am facing issue of "Subscriptions now allowed" issue with db_type: sql default_room_options: - mam: true - allow_subscription: true access_admin: - allow: admin access_create: muc_create access_persistent: muc_create history_size: 100 – Arpit Vaishnav Apr 27 '18 at 10:01
  • See the example configuration in the ejabberd Guide, the default options go without - character, like this: `allow_subscription: true`. And those default options are applied to new rooms, not to the ones already existing. – Badlop Apr 27 '18 at 10:41