aboutsummaryrefslogtreecommitdiff
path: root/src/client/QXmppAttentionManager.cpp
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2022-09-05 20:37:05 +0200
committerLinus Jahn <lnj@kaidan.im>2022-09-06 00:46:56 +0200
commit5f813f8a4bbe1e075daad7b3933829044befffb4 (patch)
tree20102aa665b03cfb6dfe0c6ece94938320b6430e /src/client/QXmppAttentionManager.cpp
parent4c60b13e0b8011e4e0b093a690e939f3b23e2436 (diff)
downloadqxmpp-5f813f8a4bbe1e075daad7b3933829044befffb4.tar.gz
Reformat code
Diffstat (limited to 'src/client/QXmppAttentionManager.cpp')
-rw-r--r--src/client/QXmppAttentionManager.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/client/QXmppAttentionManager.cpp b/src/client/QXmppAttentionManager.cpp
index b797911b..461aae65 100644
--- a/src/client/QXmppAttentionManager.cpp
+++ b/src/client/QXmppAttentionManager.cpp
@@ -177,8 +177,9 @@ QString QXmppAttentionManager::requestAttention(const QString &jid, const QStrin
msg.setBody(message);
msg.setAttentionRequested(true);
- if (client()->sendPacket(msg))
+ if (client()->sendPacket(msg)) {
return msg.id();
+ }
return {};
}
@@ -200,14 +201,16 @@ bool QXmppAttentionManager::handleStanza(const QDomElement &)
void QXmppAttentionManager::handleMessageReceived(const QXmppMessage &message)
{
- if (!message.isAttentionRequested() || !message.stamp().isNull())
+ if (!message.isAttentionRequested() || !message.stamp().isNull()) {
return;
+ }
const QString bareJid = QXmppUtils::jidToBareJid(message.from());
// ignore messages from our own bare JID (e.g. carbon or IM-NG message)
- if (bareJid == client()->configuration().jidBare())
+ if (bareJid == client()->configuration().jidBare()) {
return;
+ }
// check rate limit
if (!d->checkRateLimit(bareJid)) {
@@ -242,8 +245,9 @@ bool QXmppAttentionManagerPrivate::checkRateLimit(const QString &bareJid)
previousRequests << PastRequest { bareJid, QDateTime::currentDateTimeUtc() };
// start timer to remove request again
- if (!cleanUpTimer->isActive())
+ if (!cleanUpTimer->isActive()) {
cleanUpTimer->start(allowedAttemptsTimeInterval.msecsSinceStartOfDay());
+ }
// check whether there are too many requests
int count = std::count_if(previousRequests.cbegin(), previousRequests.cend(), [=](const PastRequest &request) {
@@ -264,9 +268,10 @@ void QXmppAttentionManagerPrivate::cleanUp()
int next = allowedAttemptsTimeInterval.msecsSinceStartOfDay() -
previousRequests.first().timestamp.msecsTo(QDateTime::currentDateTimeUtc());
- if (next < 1)
+ if (next < 1) {
cleanUp();
- else
+ } else {
cleanUpTimer->start(next);
+ }
}
}