ejabberd API 邀请到 MUC 房间

ejabberd API invite to MUC room

我正在开发 ejabberd API 以邀请用户加入 MUC 房间。我已经为 API.

设置了 OAuth

我已经用 get_room_occupants 测试了 oauth,它工作正常。

现在,我正在尝试访问 /api/send_direct_invitation,但根据日志,我无权访问此 api

我已经用命令行生成了oauth ejabberdctl oauth_issue_token admin@host 31540000 "ejabberd:admin"

我需要传递任何额外的权限吗

Ejabberd 版本: 17.11 安装于: ubuntu 16.04 配置的数据库: mysql

这是一个ejabberd.yml文件

api_permissions:
  "console commands":
    from:
      - ejabberd_ctl
    who: all
    what: "*"
  "admin access":
    who:
      - access:
          - allow:
            - user: admin@host
      - oauth:
        - scope: "ejabberd:admin"
        - access:
          - allow:
            - user: admin@host
    what:
      - "*"
      - "!stop"
      - "!start"
  "public commands":
    who:
      - ip: "127.0.0.1/8"
    what:
      - "status"
      - "connected_users_number"
commands_admin_access:
  - allow:
    - user: "admin@host"
commands:
  add_commands:
    - status
    - registered_users
    - register
    - unregister
    - get_roster
    - connected_users
    - send_stanza_c2s
    - send_stanza
    - join_cluster
    - send_direct_invitation
oauth_expire: 3600
oauth_access: all

我通过命令行尝试了 运行 并遇到了这个错误

命令:ejabberdctl send_direct_invitation naviteam1519 conference.xxx.yyy.com "" "You need this room!" KESH2FABDE@xxx.yyy.com

错误:

Problem 'error {bad_jid,<<"KESH2FABDE@xxx.yyy.com">>}' occurred executing the command.
Stacktrace: [{jid,decode,1,[{file,"src/jid.erl"},{line,138}]},
         {mod_muc_admin,'-get_users_to_invite/2-fun-1-',2,
                        [{file,"src/mod_muc_admin.erl"},{line,840}]},
         {lists,filtermap,2,[{file,"lists.erl"},{line,1317}]},
         {mod_muc_admin,send_direct_invitation,5,
                        [{file,"src/mod_muc_admin.erl"},{line,826}]},
         {ejabberd_ctl,call_command,4,
                       [{file,"src/ejabberd_ctl.erl"},{line,352}]},
         {ejabberd_ctl,try_call_command,4,
                       [{file,"src/ejabberd_ctl.erl"},{line,321}]},
         {ejabberd_ctl,process2,4,
                       [{file,"src/ejabberd_ctl.erl"},{line,271}]},
         {ejabberd_ctl,process,2,
                       [{file,"src/ejabberd_ctl.erl"},{line,249}]}]

您没有向我们展示您的 ejabberdctl send_direct_invitation 命令和日志。

我敢打赌你的命令格式不正确:

来自 send_direct_invitation api 它应该是这样的:

POST /api/send_direct_invitation
{
  "name": "room1",
  "service": "muc.example.com",
  "password": "",
  "reason": "Check this out!",
  "users": "user2@localhost:user3@example.com"
}

那么示例如下所示:

ejabberdctl send_direct_invitation aRoom conference.localhost "" "You need this room!" msg_test1@localhost

至于你的 ejabbered.yml 文件。你确定你有: admin@host 用户?那不应该给你 admin@localhost 吗?

编辑

根据评论:OP 缺少 mod-client-state 配置 mod-client-state配置:

示例配置:

modules:
  ...
  mod_client_state:
    queue_chat_states: true
    queue_pep: false
    queue_presence: true
  ...