summaryrefslogtreecommitdiffstats
path: root/bridge/xmpp/xmpp.go
diff options
context:
space:
mode:
authorAlexander <papatutuwawa@polynom.me>2020-04-16 22:16:25 +0200
committerGitHub <noreply@github.com>2020-04-16 22:16:25 +0200
commit7183095a28661fc113887a034ae1ff13eb06d0c6 (patch)
tree227b06e79e2de48989eeffe1fad408a630430355 /bridge/xmpp/xmpp.go
parent13c90893c7d3b757eb77541c5ec44489fde5661e (diff)
downloadmatterbridge-msglm-7183095a28661fc113887a034ae1ff13eb06d0c6.tar.gz
matterbridge-msglm-7183095a28661fc113887a034ae1ff13eb06d0c6.tar.bz2
matterbridge-msglm-7183095a28661fc113887a034ae1ff13eb06d0c6.zip
Implement User Avatar spoofing of XMPP users (#1090)
* Implement User Avatar spoofing of XMPP users
Diffstat (limited to 'bridge/xmpp/xmpp.go')
-rw-r--r--bridge/xmpp/xmpp.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go
index b5263017..7122534f 100644
--- a/bridge/xmpp/xmpp.go
+++ b/bridge/xmpp/xmpp.go
@@ -23,12 +23,15 @@ type Bxmpp struct {
xmppMap map[string]string
connected bool
sync.RWMutex
+
+ avatarMap map[string]string
}
func New(cfg *bridge.Config) bridge.Bridger {
return &Bxmpp{
- Config: cfg,
- xmppMap: make(map[string]string),
+ Config: cfg,
+ xmppMap: make(map[string]string),
+ avatarMap: make(map[string]string),
}
}
@@ -69,6 +72,10 @@ func (b *Bxmpp) Send(msg config.Message) (string, error) {
}
b.Log.Debugf("=> Receiving %#v", msg)
+ if msg.Event == config.EventAvatarDownload {
+ return b.cacheAvatar(&msg), nil
+ }
+
// Upload a file (in XMPP case send the upload URL because XMPP has no native upload support).
if msg.Extra != nil {
for _, rmsg := range helper.HandleExtra(&msg, b.General) {
@@ -230,6 +237,12 @@ func (b *Bxmpp) handleXMPP() error {
event = config.EventTopicChange
}
+ avatar := getAvatar(b.avatarMap, v.Remote, b.General)
+ if avatar == "" {
+ b.Log.Debugf("Requesting avatar data")
+ b.xc.AvatarRequestData(v.Remote)
+ }
+
msgID := v.ID
if v.ReplaceID != "" {
msgID = v.ReplaceID
@@ -239,6 +252,7 @@ func (b *Bxmpp) handleXMPP() error {
Text: v.Text,
Channel: b.parseChannel(v.Remote),
Account: b.Account,
+ Avatar: avatar,
UserID: v.Remote,
ID: msgID,
Event: event,
@@ -255,6 +269,8 @@ func (b *Bxmpp) handleXMPP() error {
b.Log.Debugf("<= Message is %#v", rmsg)
b.Remote <- rmsg
}
+ case xmpp.AvatarData:
+ b.handleDownloadAvatar(v)
case xmpp.Presence:
// Do nothing.
}