ejabberd icon indicating copy to clipboard operation
ejabberd copied to clipboard

Allow vcards to be set for services

Open edhelas opened this issue 5 years ago • 19 comments

It is currently possible to set a vcard for the general server using the vcard attribute on mod_vcard.

  mod_vcard:
    vcard:
     adr:
       -
         locality: Amsterdam
         ctry: The Netherlands
     url: "https://movim.eu"
     desc: "Movim official XMPP communication services, running on ejabberd"
     fn: Movim Communication Services

I'd like to know if it would be possible to extend that feature by allowing vcards to also be set for the related ejabberd services (pubsub, muc…). This would let clients like Movim, that extensively uses Pubsub, to retrieve some information on those services and display them in the UI. This is also a way to explain differences between different services of the same type (privateconf.server.tld and publicconf.server.tld for example).

edhelas avatar Nov 18 '20 16:11 edhelas

http_upload, muc, proxy65 and pubsub already support the vcard option, just like mod_vcard does.

This was implemented for ejabberd 19.08 in https://github.com/processone/ejabberd/commit/5a976719fb821801fd162cde4516085416ef71e6

badlop avatar Dec 16 '20 10:12 badlop

Wow I didn't knew that. I have to double check if the official documentation is up to date then ! Thanks for the precision :)

edhelas avatar Dec 16 '20 10:12 edhelas

It is indeed useful, but not totally what I needed. This is configured on the module level and not on the host level. This means that two MUC services, or Pubsub services, will return the same Vcard in the end.

edhelas avatar Dec 16 '20 22:12 edhelas

You should be able to use host_config (or append_host_config):

host_config:
  "host1":
    modules:
      mod_pubsub:
        vcard: ...
  "host2":
    modules:
      mod_pubsub:
        vcard: ...

prefiks avatar Dec 17 '20 08:12 prefiks

I can indeed add root hosts there but not subdomain services:

Error: "Invalid value of option host_config: 
Unexpected value: news.movim.eu. Did you mean movim.eu? Possible values are: jappix.com, movim.eu"

edhelas avatar Dec 17 '20 09:12 edhelas

You may be doing something wrong, or I didn't understand your requirements. If I understood correctly your desire, it works for me:

hosts:
  - localhost
  - "example.net"
  - "example.org"

modules:
  # mod_muc:
  ...

append_host_config:
  "example.net":
    modules:
      mod_muc:
        vcard:
         desc: "This is NET conference of example.net"
  "example.org":
    modules:
      mod_muc:
        vcard:
         desc: "This is ORG conference of example.org"
<iq id='103:347163'
	xml:lang='es'
	type='get'
	to='conference.example.org'>
  <vCard xmlns='vcard-temp'/>
</iq>

<iq xml:lang='es'
	to='user1@localhost/tka1'
	from='conference.example.org'
	type='result'
	id='103:347163'>
  <vCard xmlns='vcard-temp'>
    <DESC>This is ORG conference of example.org</DESC>
  </vCard>
</iq>
<iq id='107:877346'
	xml:lang='es'
	type='get'
	to='conference.example.net'>
  <vCard xmlns='vcard-temp'/>
</iq>

<iq xml:lang='es'
	to='user1@localhost/tka1'
	from='conference.example.net'
	type='result'
	id='107:877346'>
  <vCard xmlns='vcard-temp'>
    <DESC>This is NET conference of example.net</DESC>
  </vCard>
</iq>

badlop avatar Dec 23 '20 12:12 badlop

This is indeed what I needed ! Sorry for the misunderstanding :) !

edhelas avatar Jan 06 '21 08:01 edhelas

Ok, i'm reopening the ticket. Sorry about that. The problem is that it's not really per host, but per subdomain. So something like that:

append_host_config:
  "news.example.net":
    modules:
      mod_pubsub:
        vcard:
         desc: "The pubsub news of example.net"
  "comics.example.net":
    modules:
      mod_pubsub:
        vcard:
         desc: "The pubsub comics of example.net"

edhelas avatar Mar 01 '21 19:03 edhelas

With that configuration all works correctly for me: the host news.example.net has a Pubsub service running at pubsub.news.example.net which vcard correctly says "The pubsub news of example.net". And the comics.example.net host has a Pubsub service running at pubsub.comics.example.net which vcard says "The pusub comics og example.net".

What behaviour do you get, and what did you expect?

badlop avatar Mar 01 '21 19:03 badlop

2021-03-02 12:22:59.101 [error] <0.14205.30>@ejabberd_config:reload:116 Configuration reload aborted: Invalid value of option append_host_config: Unexpected value: news.movim.eu. Did you mean movim.eu? Possible values are: jappix.com, movim.eu

I can't actually append config to a subdomain because it needs to be registered as a host. And if I try to add it to hosts I got:

2021-03-02 12:23:46.392 [error] <0.11235.30>@ejabberd_config:reload:116 Configuration reload aborted: Invalid value of option modules->mod_pubsub->hosts->4: Failed to reuse route 'news.movim.eu' because it's already registered on a virtual host

edhelas avatar Mar 02 '21 11:03 edhelas

Tell what ejabberd version are you using, how did you install it, and what configuration do you have set, specially all regarding hosts

badlop avatar Mar 02 '21 11:03 badlop

ejabberd/now 20.12-0 amd64 [installed,local]
  ${msg(ejabberd.desc)}

Using the official ProcessOne DEB

edhelas avatar Mar 02 '21 12:03 edhelas

Ok, that's a very recent version and I don't remember any recent bug related to this. As I was able to configure it, all indicates you messed the configuration, so I'll repeat again:

what configuration do you have set, specially all regarding hosts

badlop avatar Mar 02 '21 12:03 badlop

So after having a quick talk with @weiss , it seems that there was a misunderstanding. I'll try to resume and clarify things.

On my ejabberd instance, I have two hosts defined : movim.eu and jappix.com.

hosts:
  - "movim.eu"
  - "jappix.com"

Under each of those hosts I'm using mod_pubsub with several hosts bellow them.

append_host_config:
  "movim.eu":
    modules:
      mod_pubsub:
        hosts:
          - "alt.@HOST@"
          - "blabla.@HOST@"
...
          - "comments.@HOST@"
   "jappix.eu":
    modules:
      mod_pubsub:
        hosts:
          - "pubsub.@HOST@"
...
          - "comments.@HOST@"

In Movim each of those subdomains (blabla.movim.eu, comments.movim.eu, pubsub.jappix.com…) I'd like to define a custom vcard to be able to display it in the Movim UI. Those subdomains are currently displayed this way in Movim

Capture d’écran_2021-03-02_23-07-33

I'd like to add a proper description, avatar and more (so what can be found in a proper vcard).

So what i'm looking for is basically a way to be able to define a custom vcard, not by host, not by host module, but actually by host module subdomain (so for each of those mod_pubsub hosts for example).

@weiss is telling me that this feature is actually non existent in ejabberd but could be implemented.

edhelas avatar Mar 02 '21 22:03 edhelas

@badlop, @prefiks: What do you think about last @edhelas comment?

Neustradamus avatar Apr 13 '21 13:04 Neustradamus

Let me try to propose another approach.

Possibly, it should be dynamic and not in the configuration file.

I guess, an admin could be able to set a vcard for any service name and it would override the default vcard served for that module.

That vcard would be stored in the database.

mremond avatar Apr 15 '21 14:04 mremond

That sounds good to me :)

edhelas avatar Apr 15 '21 19:04 edhelas