Update displayname template

This commit is contained in:
Tulir Asokan 2021-09-01 15:49:19 +03:00
parent 3bef9ebfc0
commit 46dcd11527
4 changed files with 10 additions and 11 deletions

View file

@ -178,7 +178,7 @@ func (bc BridgeConfig) FormatDisplayname(contact whatsapp.Contact) (string, int8
bc.displaynameTemplate.Execute(&buf, contact) bc.displaynameTemplate.Execute(&buf, contact)
var quality int8 var quality int8
switch { switch {
case len(contact.Notify) > 0: case len(contact.Notify) > 0 || len(contact.VName) > 0:
quality = 3 quality = 3
case len(contact.Name) > 0 || len(contact.Short) > 0: case len(contact.Name) > 0 || len(contact.Short) > 0:
quality = 2 quality = 2

View file

@ -74,13 +74,12 @@ bridge:
username_template: whatsapp_{{.}} username_template: whatsapp_{{.}}
# Displayname template for WhatsApp users. # Displayname template for WhatsApp users.
# {{.Notify}} - nickname set by the WhatsApp user # {{.Notify}} - nickname set by the WhatsApp user
# {{.Jid}} - phone number (international format) # {{.VName}} - validated WhatsApp business name
# {{.JID}} - phone number (international format)
# The following variables are also available, but will cause problems on multi-user instances: # The following variables are also available, but will cause problems on multi-user instances:
# {{.Name}} - display name from contact list # {{.Name}} - display name from contact list
# {{.Short}} - short display name from contact list # {{.Short}} - short display name from contact list
# To use multiple if's, you need to use: {{else if .Name}}, for example: displayname_template: "{{if .Notify}}{{.Notify}}{{else if .VName}}{{.VName}}{{else}}{{.JID}}{{end}} (WA)"
# "{{if .Notify}}{{.Notify}}{{else if .Name}}{{.Name}}{{else}}{{.Jid}}{{end}} (WA)"
displayname_template: "{{if .Notify}}{{.Notify}}{{else}}{{.Jid}}{{end}} (WA)"
# Localpart template for per-user room grouping community IDs. # Localpart template for per-user room grouping community IDs.
# On startup, the bridge will try to create these communities, add all of the specific user's # On startup, the bridge will try to create these communities, add all of the specific user's
# portals to the community, and invite the Matrix user to it. # portals to the community, and invite the Matrix user to it.

4
go.mod
View file

@ -12,7 +12,7 @@ require (
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0
maunium.net/go/mauflag v1.0.0 maunium.net/go/mauflag v1.0.0
maunium.net/go/maulogger/v2 v2.3.0 maunium.net/go/maulogger/v2 v2.3.0
maunium.net/go/mautrix v0.9.21 maunium.net/go/mautrix v0.9.23
) )
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.5.10 replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.5.11

8
go.sum
View file

@ -138,8 +138,8 @@ github.com/tidwall/pretty v1.0.2 h1:Z7S3cePv9Jwm1KwS0513MRaoUe3S01WPbLNV40pwWZU=
github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tidwall/sjson v1.1.5 h1:wsUceI/XDyZk3J1FUvuuYlK62zJv2HO2Pzb8A5EWdUE= github.com/tidwall/sjson v1.1.5 h1:wsUceI/XDyZk3J1FUvuuYlK62zJv2HO2Pzb8A5EWdUE=
github.com/tidwall/sjson v1.1.5/go.mod h1:VuJzsZnTowhSxWdOgsAnb886i4AjEyTkk7tNtsL7EYE= github.com/tidwall/sjson v1.1.5/go.mod h1:VuJzsZnTowhSxWdOgsAnb886i4AjEyTkk7tNtsL7EYE=
github.com/tulir/go-whatsapp v0.5.10 h1:mcN9GuSZ4kLg9RyNfPOhBasapkPFA8nA4wFLEwA4AfE= github.com/tulir/go-whatsapp v0.5.11 h1:e1EVhygdJ/YEdAIF9a6I4fIcW1l3qQcQs+h5loJVgRA=
github.com/tulir/go-whatsapp v0.5.10/go.mod h1:7J3IIL3bEQiBJGtiZst1N4PgXHlWIartdVQLe6lcx9A= github.com/tulir/go-whatsapp v0.5.11/go.mod h1:7J3IIL3bEQiBJGtiZst1N4PgXHlWIartdVQLe6lcx9A=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@ -217,5 +217,5 @@ maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfk
maunium.net/go/maulogger/v2 v2.2.4/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A= maunium.net/go/maulogger/v2 v2.2.4/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
maunium.net/go/maulogger/v2 v2.3.0 h1:TMCcO65fLk6+pJXo7sl38tzjzW0KBFgc6JWJMBJp4GE= maunium.net/go/maulogger/v2 v2.3.0 h1:TMCcO65fLk6+pJXo7sl38tzjzW0KBFgc6JWJMBJp4GE=
maunium.net/go/maulogger/v2 v2.3.0/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A= maunium.net/go/maulogger/v2 v2.3.0/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
maunium.net/go/mautrix v0.9.21 h1:Cga/x4eUMzxH8d14l7pgZuZH3REhdNJmxbp/to48TdE= maunium.net/go/mautrix v0.9.23 h1:CoRCCVHSs0R2NjRcrFDUBlOrhvVixaj1PSE7jR8ghMs=
maunium.net/go/mautrix v0.9.21/go.mod h1:7IzKfWvpQtN+W2Lzxc0rLvIxFM3ryKX6Ys3S/ZoWbg8= maunium.net/go/mautrix v0.9.23/go.mod h1:7IzKfWvpQtN+W2Lzxc0rLvIxFM3ryKX6Ys3S/ZoWbg8=