mirror of
https://git.mills.io/saltyim/saltyim.git
synced 2024-06-24 07:48:19 +00:00
fix: lookup avatar (#110)
Co-authored-by: xuu <me@sour.is> Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/110
This commit is contained in:
parent
53e79b449b
commit
0eb020783e
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a62394c2c5c40a75da9d7b5530b028743acbd259363ec7bbe250abf0d81abb7e
|
||||
size 28470308
|
||||
oid sha256:40a5d5fb6ae0e907152d3ea7b09140d1438199f767ddaa66ccbf77c821cdc40f
|
||||
size 28471679
|
||||
|
@ -68,6 +68,7 @@ type Addr struct {
|
||||
discoveredDomain string
|
||||
avatar string
|
||||
capabilities Capabilities
|
||||
checkedAvatar bool
|
||||
}
|
||||
|
||||
// IsZero returns true if the address is empty
|
||||
@ -211,14 +212,15 @@ func (a *Addr) Refresh() error {
|
||||
}
|
||||
|
||||
func (a *Addr) Avatar() string {
|
||||
if a.avatar != "" {
|
||||
if a.checkedAvatar {
|
||||
return a.avatar
|
||||
}
|
||||
|
||||
log.Debugf("Looking up SRV record for _avatars._tcp.%s", a.Domain)
|
||||
if target, err := resolver.LookupSRV("avatars", "tcp", a.Domain); err == nil {
|
||||
a.avatar = fmt.Sprintf("https://%s/avatar/%s", target, a.Hash())
|
||||
} else { log.Info(target, err) }
|
||||
}
|
||||
a.checkedAvatar = true
|
||||
|
||||
return a.avatar
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user