matrix-org / matrix-hookshot

A bridge between Matrix and multiple project management services, such as GitHub, GitLab and JIRA.

Home Page:https://matrix-org.github.io/matrix-hookshot/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Set displayname for bot user with homeserver setting "enable_set_displayname: false"

tuc-ok opened this issue · comments

commented

Is it a configuration failure or a bug?

I want to set "enable_set_displayname: false" in the homeserver's configuration. When I try to create a new webhook I get the following error message because the bot user's display name cannot be set:

2023-06-16T12:27:16.556698424+02:00 ERROR 10:27:16:556 [MatrixHttpClient] (REQ-139) {
2023-06-16T12:27:16.556763834+02:00 errcode: 'M_FORBIDDEN',
2023-06-16T12:27:16.556787107+02:00 error: 'Changing display name is disabled on this server'
2023-06-16T12:27:16.556815351+02:00 }
2023-06-16T12:27:16.558166053+02:00 WARN 10:27:16:556 [Bridge] Failed to handle generic webhook MatrixError: M_FORBIDDEN: Changing display name is disabled on this server
2023-06-16T12:27:16.558231443+02:00 at doHttpRequest (/bin/matrix-hookshot/node_modules/matrix-bot-sdk/lib/http.js:95:15)
2023-06-16T12:27:16.558246972+02:00 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-06-16T12:27:16.558276541+02:00 at async descriptor.value (/bin/matrix-hookshot/node_modules/matrix-bot-sdk/lib/metrics/decorators.js:19:32)
2023-06-16T12:27:16.558290686+02:00 at async descriptor.value (/bin/matrix-hookshot/node_modules/matrix-bot-sdk/lib/metrics/decorators.js:19:32)
2023-06-16T12:27:16.558305885+02:00 at async GenericHookConnection.ensureDisplayname (/bin/matrix-hookshot/Connections/GenericHook.js:187:13)
2023-06-16T12:27:16.558318895+02:00 at async GenericHookConnection.onGenericHook (/bin/matrix-hookshot/Connections/GenericHook.js:307:9)
2023-06-16T12:27:16.558331307+02:00 at async /bin/matrix-hookshot/Bridge.js:402:25
2023-06-16T12:27:16.558343985+02:00 at async Promise.all (index 0)
2023-06-16T12:27:16.558358884+02:00 at async LocalMQ. (/bin/matrix-hookshot/Bridge.js:383:13) {
2023-06-16T12:27:16.558371440+02:00 body: {
2023-06-16T12:27:16.558383698+02:00 errcode: 'M_FORBIDDEN',
2023-06-16T12:27:16.558396354+02:00 error: 'Changing display name is disabled on this server'
2023-06-16T12:27:16.558409011+02:00 },
2023-06-16T12:27:16.558420096+02:00 statusCode: 400,
2023-06-16T12:27:16.558432083+02:00 errcode: 'M_FORBIDDEN',
2023-06-16T12:27:16.558443087+02:00 error: 'Changing display name is disabled on this server',
2023-06-16T12:27:16.558454364+02:00 retryAfterMs: undefined
2023-06-16T12:27:16.558465130+02:00 }

Is it possible to change this behavior?

You can remove https://github.com/matrix-org/matrix-hookshot/blob/main/config.sample.yml#L101 from your config (the whole section) and hookshot should not attempt to set a displayname.

That seemed not to work, that was my config.yml at the first try:

#bot:
#  avatar: mxc://half-shot.uk/2876e89ccade4cb615e210c458e2a7a6883fe17d
#  displayname: Hookshot Bot
bridge:
  bindAddress: 0.0.0.0
  domain: matrix.mydomain.tld
  mediaUrl: https://matrix.mydomain.tld
  port: 9993
  url: http://matrix-synapse:8008
generic:
  allowJsTransformationFunctions: false
  enableHttpGet: false
  enabled: true
  urlPrefix: https://matrix.mydomain.tld/webhook/
  userIdPrefix: _webhooks_
  waitForComplete: false
listeners:
- bindAddress: 0.0.0.0
  port: 9000
  resources:
  - webhooks
logging:
  level: debug
metrics:
  enabled: false
passFile: /data/passkey.pem
permissions:
- actor: "*"
  services:
    - service: "*"
      level: manageConnections

Afterwards I tried it again with userIdPrefix being commented out, is it correct that this is necessary? I guess yes because it worked after the change. The only point is that the webhook connection name is not used anymore. All webhooks are sent with the generic name "Hookshot Bot". Before the change the name was the connection name which has been chosen while to creation of the webhook (!hookshot webhook monitoring-test).

Do I understand that right? :-)