0

I am trying to subscribe a test user to a test room using the Ejabberd API. I am sure I just misconfigured something but I can't seem to find the issue. I am running Ejabberd 16.09 and trying to use mod_http_api

My configuration is the following:

hosts:
  - "localhost"
  - "my.personal.host"

listen:
  -
    port: 5285
    module: ejabberd_http
    request_handlers:
      "/api": mod_http_api

acl:
  admin:
     user:
       - "@localhost"

modules:
  mod_muc:
    mam: true
    default_room_options:
      allow_subscription: true
    access:
      - allow
    access_admin:
      - allow: admin
    access_create: muc_create
    access_persistent: muc_create
  mod_muc_admin: {}
  mod_http_api:
    admin_ip_access: admin_ip_access_rule

api_permissions:
  "API used from localhost allows all calls":
    - who:
      - ip: "127.0.0.1/8"
    - what:
      - "*"
      - "!stop"
      - "!start"

access:
  admin_ip_access_rule:
    admin:
      - create_room
      - register
      - subscribe_room

I did successfully create a user test1 and a room testroom1 through the api. I then try to subscribe the user to that rum by a POST with curl:

curl -X POST -H "Cache-Control: no-cache" -d '{"user":"test1@my.personal.host/something","nick":"test1","room":"testroom1@my.persoal.host","nodes":"urn:xmpp:mucsub:nodes:messages"}' "http://localhost:5285/api/subscribe_room"

And yet I get this response:

"Subscriptions are not allowed"

So what am I doing wrong?

Jeffrey
  • 189
  • 1
  • 8

1 Answers1

0

Ohh, I found so many problems in your setup with just a quick look:

  1. From what I know, mod_muc doesn't have an option called 'mam'
  2. In the call, the room attribute has a spelling error when it says persoal.
  3. Also, the room JID can't be "testroom1@my.persoal.host", it may be something like "testroom1@conference.my.personal.host"

Try creating the room with a user, then check it is configured correctly (has subscriptions allowed), then try to subscribe with another account. It worked for me with this call:

$ ejabberdctl subscribe_room test2@my.personal.host Test2 testroom1@conference.my.personal.host urn:xmpp:mucsub:nodes:messages

Badlop
  • 3,840
  • 1
  • 8
  • 9
  • Wow that's embarrassing. Guess all that playing around with different configs got me blind to those mistakes. Regarding 1.: Maybe I've picked that up wrong from the documentation. I thought I remembered it somewhere stating that I had to specifically activate mam for rooms so that subscribed users retrieve messages sent in the room when they were offline together with all the others when doing the mam request. Regarding 2.: that's no actual host I am using. So I wasn't paying attention if I changed it correctly I guess – Jeffrey Feb 14 '19 at 15:02
  • Regarding 3.: THAT I didn't know. I know it is used in a similar manner in the example but I thought it is a thing you CAN do not a thing you have to. – Jeffrey Feb 14 '19 at 15:04
  • Ok I tested it and it works now (3) was the issue. thanks a lot – Jeffrey Feb 14 '19 at 15:07