Skip to content

Commit 17174e5

Browse files
committed
style: modernize ServerNotificationHandler::slotNotificationsReceived.
Signed-off-by: Camila Ayres <[email protected]>
1 parent 95ea8a0 commit 17174e5

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/gui/tray/notificationhandler.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
9898

9999
const auto notifies = json.object().value("ocs"_L1).toObject().value("data"_L1).toArray();
100100

101-
auto *ai = qvariant_cast<AccountState *>(sender()->property(propertyAccountStateC));
101+
auto accountState = qvariant_cast<AccountState *>(sender()->property(propertyAccountStateC));
102102

103103
ActivityList list;
104104
ActivityList callList;
105105

106-
for (const auto element : notifies) {
107-
auto json = element.toObject();
108-
auto a = Activity::fromActivityJson(json, ai->account());
106+
for (const auto &element : notifies) {
107+
const auto json = element.toObject();
108+
auto activity = Activity::fromActivityJson(json, accountState->account());
109109

110110
a._type = Activity::NotificationType;
111111
a._id = json.value("notification_id"_L1).toInteger();
@@ -136,17 +136,18 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
136136
const auto objectId = json.value("object_id"_L1).toString();
137137
const auto objectIdData = objectId.split(u'/');
138138

139-
ActivityLink al;
140-
al._label = tr("Reply");
141-
al._verb = "REPLY";
142-
al._primary = true;
139+
ActivityLink link;
140+
link._label = tr("Reply");
141+
link._verb = "REPLY";
142+
link._primary = true;
143143

144-
a._talkNotificationData.conversationToken = objectIdData.first();
144+
activity._talkNotificationData.conversationToken = objectIdData.first();
145145

146-
if (a._objectType == "chat" && objectIdData.size() > 1) {
147-
a._talkNotificationData.messageId = objectIdData.last();
146+
if (activity._objectType == "chat" && objectIdData.size() > 1) {
147+
activity._talkNotificationData.messageId = objectIdData.last();
148148
} else {
149-
qCInfo(lcServerNotification) << "Replying directly to Talk conversation" << a._talkNotificationData.conversationToken << "will not be possible because the notification doesn't contain the message ID.";
149+
qCInfo(lcServerNotification) << "Replying directly to Talk conversation" << activity._talkNotificationData.conversationToken
150+
<< "will not be possible because the notification doesn't contain the message ID.";
150151
}
151152

152153
if (a._subjectRichParameters.contains("user"_L1)) {
@@ -164,7 +165,7 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
164165
callList.append(a);
165166
}
166167

167-
a._links.insert(al._primary? 0 : a._links.size(), al);
168+
activity._links.insert(link._primary? 0 : activity._links.size(), link);
168169
}
169170

170171
QUrl link(json.value("link"_L1).toString());
@@ -173,13 +174,13 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
173174
link.setScheme(ai->account()->url().scheme());
174175
link.setHost(ai->account()->url().host());
175176
}
176-
if (link.port() == -1) {
177-
link.setPort(ai->account()->url().port());
177+
if (url.port() == -1) {
178+
url.setPort(accountState->account()->url().port());
178179
}
179180
}
180-
a._link = link;
181+
activity._link = url;
181182

182-
list.append(a);
183+
list.append(activity);
183184
}
184185
emit newNotificationList(list);
185186
emit newIncomingCallsList(callList);

0 commit comments

Comments
 (0)