From 8cca8a324e352fa62481b171682add880877b633 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Sun, 1 Aug 2021 18:35:53 -0500 Subject: [PATCH] (jabber) Throttle own VCard updates; move avatar-cache to /tmp/ --- protocols/xmpp/JabberHandler.cpp | 14 +++++++++++--- protocols/xmpp/JabberHandler.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/protocols/xmpp/JabberHandler.cpp b/protocols/xmpp/JabberHandler.cpp index ab19452..31ab6d6 100644 --- a/protocols/xmpp/JabberHandler.cpp +++ b/protocols/xmpp/JabberHandler.cpp @@ -61,7 +61,8 @@ JabberHandler::JabberHandler() : fClient(NULL), fVCardManager(NULL), - fSession(NULL) + fSession(NULL), + fLastOwnVCard(0) { fAvatars = new BList(); } @@ -1021,10 +1022,9 @@ JabberHandler::_SetupAvatarCache() BPath path; - if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) + if (find_directory(B_SYSTEM_TEMP_DIRECTORY, &path) != B_OK) return B_ERROR; - path.Append("Cardie/Cache/Accounts"); path.Append(GetName()); if (create_directory(path.Path(), 0755) != B_OK) @@ -1928,6 +1928,14 @@ JabberHandler::handleVCard(const gloox::JID& jid, const gloox::VCard* card) if (!card) return; + // Throttles updates to your own VCard― ime some servers spam for no reason + if (jid.bare() == fJid.bare()) { + bigtime_t last = fLastOwnVCard; + fLastOwnVCard = time(NULL); + if (fLastOwnVCard - last < 60) + return; + } + gloox::VCard::Name name = card->name(); gloox::VCard::Photo photo = card->photo(); BString nick(card->nickname().c_str()); diff --git a/protocols/xmpp/JabberHandler.h b/protocols/xmpp/JabberHandler.h index 918b3d0..c575665 100644 --- a/protocols/xmpp/JabberHandler.h +++ b/protocols/xmpp/JabberHandler.h @@ -126,6 +126,7 @@ private: BPath fAvatarCachePath; BMessage fAvatarCache; BList* fAvatars; + bigtime_t fLastOwnVCard; // Last time VCard updated void _SendMessage(BMessage* msg); void _MessageSent(const char* id, const char* subject,