mirror of
https://git.mills.io/saltyim/saltyim.git
synced 2024-06-28 09:41:02 +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
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:a62394c2c5c40a75da9d7b5530b028743acbd259363ec7bbe250abf0d81abb7e
|
oid sha256:40a5d5fb6ae0e907152d3ea7b09140d1438199f767ddaa66ccbf77c821cdc40f
|
||||||
size 28470308
|
size 28471679
|
||||||
|
@ -68,6 +68,7 @@ type Addr struct {
|
|||||||
discoveredDomain string
|
discoveredDomain string
|
||||||
avatar string
|
avatar string
|
||||||
capabilities Capabilities
|
capabilities Capabilities
|
||||||
|
checkedAvatar bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsZero returns true if the address is empty
|
// IsZero returns true if the address is empty
|
||||||
@ -211,14 +212,15 @@ func (a *Addr) Refresh() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Addr) Avatar() string {
|
func (a *Addr) Avatar() string {
|
||||||
if a.avatar != "" {
|
if a.checkedAvatar {
|
||||||
return a.avatar
|
return a.avatar
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("Looking up SRV record for _avatars._tcp.%s", a.Domain)
|
log.Debugf("Looking up SRV record for _avatars._tcp.%s", a.Domain)
|
||||||
if target, err := resolver.LookupSRV("avatars", "tcp", a.Domain); err == nil {
|
if target, err := resolver.LookupSRV("avatars", "tcp", a.Domain); err == nil {
|
||||||
a.avatar = fmt.Sprintf("https://%s/avatar/%s", target, a.Hash())
|
a.avatar = fmt.Sprintf("https://%s/avatar/%s", target, a.Hash())
|
||||||
} else { log.Info(target, err) }
|
}
|
||||||
|
a.checkedAvatar = true
|
||||||
|
|
||||||
return a.avatar
|
return a.avatar
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user