Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact names are not syncing #565

Open
NathanC opened this issue Nov 3, 2022 · 18 comments
Open

Contact names are not syncing #565

NathanC opened this issue Nov 3, 2022 · 18 comments
Labels
bug Something isn't working

Comments

@NathanC
Copy link

NathanC commented Nov 3, 2022

I just set up the bridge. If I list all my contacts, it shows the picture + full name + number. However, the display name for the user is just the number followed by (WA).

Is it possible to get the display name to be the contact name + (WA)? If so, how?

@NathanC NathanC added the bug Something isn't working label Nov 3, 2022
@maltee1
Copy link

maltee1 commented Nov 3, 2022

Have you checked displayname_template in the config?

@up-andrey
Copy link

do you have any news?

@up-andrey
Copy link

Have you checked displayname_template in the config?

I have configiration like this: displayname_template: "{{if .BusinessName}}{{.BusinessName}}{{else if .PushName}}{{.PushName}}{{else}}{{.JID}}{{end}} (WA)"
But contacts appear only when someone texts me on Whatsapp.
What wrong?
(bridge ver. 0.8.0)

@Roang-zero1
Copy link

I have used spantaleev/matrix-docker-ansible-deploy to setup the bridge.
In their template they have this configuration Line config.yaml#L95.
I also enabled backfilling support and when the contacts were synced after login most of them were just <international number> (WA)

@mr8tom
Copy link

mr8tom commented Oct 23, 2023

I have the same problem. Used the Ansible but none of the configs seem to work. I added "|" before "bridge:" and tried many different display_template versions but none worked.
Sometimes I get an error in the script because of typo but I don't know what to change.

matrix_mautrix_whatsapp_configuration_extension_yaml:` |
bridge:
    delivery_receipts: true
    history_sync:
      backfill: true
    user_avatar_sync: true
    archive_tag: m.lowpriority
# displayname_template: "{{or .FullName .PushName .JID}} -W"
#  displayname_template: "{{ '{{.FullName}} ' }}"
    # The following variables are also available, but will cause problems on multi-user instances:
    # {{ '{{.FullName}}' }}  - full name from contact list
    # {{ '{{.FirstName}}' }} - first name from contact list
 #   displayname_template: "{{ '{{if .BusinessName}}{{.BusinessName}}{{else if .PushName}}{{.PushName}}{{else}}{{.JID}}{{end}} (WA)' }}"
    # Should the bridge create a space for each logged-in user and add bridged rooms to it?
    displayname_template: "{{ '{{if .FullName}}{{.FullName}}{{else if .PushName}}{{.PushName}}{{else}}{{.JID}}{{end}} (WA)' }}"
  #  displayname_template: "{{ '{{if .BusinessName}}{{.BusinessName}}{{else if .PushName}}{{.PushName}}{{else}}{{.JID}}{{end}} (WA)' }}"
 #   displayname_template: "{{.Short}}"
 #   displayname_template: "{{if .Notify}}{{.Notify}}{{else}}{{.Jid}}{{end}} (WA)"
 #   displayname_template: "{{if .PushName}}{{.PushName}}{{else if .BusinessName}}{{.BusinessName}}{{else}}{{.JID}}{{end}} (WA)" 

I have used spantaleev/matrix-docker-ansible-deploy to setup the bridge. In their template they have this configuration Line config.yaml#L95. I also enabled backfilling support and when the contacts were synced after login most of them were just <international number> (WA)
`

@saru-man
Copy link

saru-man commented Oct 23, 2023

I simply used

displayname_template: "{{or .FullName .BusinessName .PushName .JID}} (WA)"

and it works like a charm.

@mr8tom
Copy link

mr8tom commented Oct 23, 2023

I simply used

displayname_template: "{{or .FullName .BusinessName .PushName .JID}} (WA)"

and it works like a charm.

Thank you for your suggestion. I tried it, when I run the Ansible script it says

msg: |-
    The task includes an option with an undefined variable. The
 error was: {{ matrix_mautrix_whatsapp_configuration_yaml | fro
m_yaml | combine(matrix_mautrix_whatsapp_configuration_extensio
n, recursive=True) }}: {{ matrix_mautrix_whatsapp_configuration
_extension_yaml | from_yaml if matrix_mautrix_whatsapp_configur
ation_extension_yaml | from_yaml is mapping else {} }}: bridge:
      delivery_receipts: true
      history_sync:
        backfill: true
      user_avatar_sync: true
      archive_tag: m.lowpriority
      displayname_template: "{{or .FullName .BusinessName .Push
Name .JID}} (WA)"
    : 'or' is undefined

Then I only used .FullName:
displayname_template: "{{.FullName}} -W"
and got this Error message:

ERROR! We were unable to read either as JSON nor YAML, these ar
e the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
  did not find expected key

The error appears to be in '/work/inventory/host_vars/matrix.8t
om.de/vars.yml': line 53, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

#  displayname_template: "{{or .FullName .PushName .JID}} -W"
    displayname_template: "{{.FullName}} -W"
    ^ here
We could be wrong, but this one looks like it might be an issue
 with
missing quotes. Always quote template expression brackets when
they
start a value. For instance:

    with_items:
      - {{ foo }}

Should be written as:

    with_items:
      - "{{ foo }}"

Then I tried
displayname_template: "{{ '{{.FullName}}' }}" and got also an Error:

ERROR! We were unable to read either as JSON nor YAML, these ar
e the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
  did not find expected key

The error appears to be in '/work/inventory/host_vars/matrix.8t
om.de/vars.yml': line 54, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

#    displayname_template: "{{.FullName}} -W"
    displayname_template: "{{ '{{.FullName}}' }}"
    ^ here`ERROR! We were unable to read either as JSON nor YAML, these ar
e the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
  did not find expected key

The error appears to be in '/work/inventory/host_vars/matrix.8t
om.de/vars.yml': line 54, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

#    displayname_template: "{{.FullName}} -W"
    displayname_template: "{{ '{{.FullName}}' }}"
    ^ here

Seems Syntax related but I have no clue 😓

@avm99963
Copy link

Ansible is treating {{or .FullName .BusinessName .PushName .JID}} as an Ansible (in fact, Jinja) template and trying to process it.

To keep Ansible from processing that (so it is written exactly like that in the configuration file), you might need to enclose it between {% raw %} and {% endraw %} (see an example here).

@mr8tom
Copy link

mr8tom commented Oct 24, 2023

Thank you @avm99963
I issued the problem also at the GitHub Ansible matrix:
spantaleev/matrix-docker-ansible-deploy#2962

With the tips from here and from them I got following solution:

displayname_template: "{{or .FullName .PushName .JID}} (WA)"

needs to enclosed by {% raw %} and {% endraw %} :

displayname_template: {% raw %}{{or .FullName .PushName .JID}} (WA){% endraw %}

@nolith
Copy link

nolith commented Nov 5, 2024

Hello, I am also running matrix-docker-ansible-deploy.

When I enabled the bridge and logged in with the qr code it started backfilling all my chats, most of my DM had a name.

The when it completed the backfill almost the entirety of my contacts was renamed with the phone number, the all show something like this:

Screenshot 2024-11-04 at 19 42 57

After reading this issue I changed my displayname_template to '{{or .FullName .BusinessName .PushName .Phone}} (WA)' (validated looking at the config file in the docker container) but nothing changed.

I have all my contacts with a name in my iPhone, but it does not show up on matrix.

A few of them (maybe 10) have a name that is likely the PushName.

Is changing the displayname_template and restartinfg the bridge enough to refresh the names or should I do something elese, 'cause nothing seems to change the names.

@Its-EGS
Copy link

Its-EGS commented Nov 8, 2024

So is it no longer possible to create your own individual name in the matrix room?

I don't have any contacts stored on my dedicated WhatsApp phone, why should I? New WA contacts are created via the bridge bot with start-chat.
But if someone calls themselves . or something similar, it's rather unattractive.

@nolith
Copy link

nolith commented Nov 8, 2024

I have a working syncing now, but I made several changes simultaneously, so I can't tell which one fixed it.

Here is what I did:

  • unliked the bridge with logout <login ID>
  • removed all the chats from matrix with delete-all-portals
  • I went through my chats in WhatsApp and deleted a lot of them, all the old groups, all folks that I haven't chatted in years
  • limited the backfill to 180 days
  • linked again with login qr

Now it's a few days and my contact names are stable.

@yesbhautik
Copy link

  • delete-all-portals

I am using public server frei.chat. Facing same issue. Contact Name is not showing up, it is very irritating.

@nolith
Copy link

nolith commented Nov 16, 2024

  • delete-all-portals

I am using public server frei.chat. Facing same issue. Contact Name is not showing up, it is very irritating.

I did that to remove the old portals that the bridge left behind. I guess it will re-create them in any case and potentially rename the existing ones.

@akdk7
Copy link

akdk7 commented Nov 26, 2024

Just added ".FullName" to the configuration on frei.chat and a user confirmed the whatsapp rooms are being updated with their contacts name.
@yesbhautik you might wanna try a logout and login. :)

@yesbhautik
Copy link

Just added ".FullName" to the configuration on frei.chat and a user confirmed the whatsapp rooms are being updated with their contacts name. @yesbhautik you might wanna try a logout and login. :)

Amazing working like charm!

@akdk7 If you're core member of frei.chat I would like to contribute by providing resources from my company, also Have few suggestions.

@akdk7
Copy link

akdk7 commented Nov 27, 2024

Just added ".FullName" to the configuration on frei.chat and a user confirmed the whatsapp rooms are being updated with their contacts name. @yesbhautik you might wanna try a logout and login. :)

Amazing working like charm!

@akdk7 If you're core member of frei.chat I would like to contribute by providing resources from my company, also Have few suggestions.

Happy to hear it's working :) If you like you can contact me directly via Matrix.

@yesbhautik
Copy link

Matrix

ID?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests