summaryrefslogtreecommitdiffstats
path: root/bridge/xmpp/handler.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/handler.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/handler.go')
-rw-r--r--bridge/xmpp/handler.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/bridge/xmpp/handler.go b/bridge/xmpp/handler.go
new file mode 100644
index 00000000..731998d9
--- /dev/null
+++ b/bridge/xmpp/handler.go
@@ -0,0 +1,34 @@
+package bxmpp
+
+import (
+ "github.com/42wim/matterbridge/bridge/config"
+ "github.com/42wim/matterbridge/bridge/helper"
+ "github.com/matterbridge/go-xmpp"
+)
+
+// handleDownloadAvatar downloads the avatar of userid from channel
+// sends a EVENT_AVATAR_DOWNLOAD message to the gateway if successful.
+// logs an error message if it fails
+func (b *Bxmpp) handleDownloadAvatar(avatar xmpp.AvatarData) {
+ rmsg := config.Message{
+ Username: "system",
+ Text: "avatar",
+ Channel: b.parseChannel(avatar.From),
+ Account: b.Account,
+ UserID: avatar.From,
+ Event: config.EventAvatarDownload,
+ Extra: make(map[string][]interface{}),
+ }
+ if _, ok := b.avatarMap[avatar.From]; !ok {
+ b.Log.Debugf("Avatar.From: %s", avatar.From)
+
+ err := helper.HandleDownloadSize(b.Log, &rmsg, avatar.From+".png", int64(len(avatar.Data)), b.General)
+ if err != nil {
+ b.Log.Error(err)
+ return
+ }
+ helper.HandleDownloadData(b.Log, &rmsg, avatar.From+".png", rmsg.Text, "", &avatar.Data, b.General)
+ b.Log.Debugf("Avatar download complete")
+ b.Remote <- rmsg
+ }
+}