Skip to content

Commit aa6f5e4

Browse files
camilasanbackportbot[bot]
authored andcommitted
style: modernize ServerNotificationHandler::slotNotificationsReceived.
Signed-off-by: Camila Ayres <hello@camilasan.com>
1 parent c01a5ab commit aa6f5e4

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

src/gui/tray/notificationhandler.cpp

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

9797
const auto notifies = json.object().value("ocs").toObject().value("data").toArray();
9898

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

101101
ActivityList list;
102102
ActivityList callList;
103103

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

108108
a._type = Activity::NotificationType;
109109
a._id = json.value("notification_id").toInteger();
@@ -134,17 +134,18 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
134134
const auto objectId = json.value("object_id").toString();
135135
const auto objectIdData = objectId.split("/");
136136

137-
ActivityLink al;
138-
al._label = tr("Reply");
139-
al._verb = "REPLY";
140-
al._primary = true;
137+
ActivityLink link;
138+
link._label = tr("Reply");
139+
link._verb = "REPLY";
140+
link._primary = true;
141141

142-
a._talkNotificationData.conversationToken = objectIdData.first();
142+
activity._talkNotificationData.conversationToken = objectIdData.first();
143143

144-
if (a._objectType == "chat" && objectIdData.size() > 1) {
145-
a._talkNotificationData.messageId = objectIdData.last();
144+
if (activity._objectType == "chat" && objectIdData.size() > 1) {
145+
activity._talkNotificationData.messageId = objectIdData.last();
146146
} else {
147-
qCInfo(lcServerNotification) << "Replying directly to Talk conversation" << a._talkNotificationData.conversationToken << "will not be possible because the notification doesn't contain the message ID.";
147+
qCInfo(lcServerNotification) << "Replying directly to Talk conversation" << activity._talkNotificationData.conversationToken
148+
<< "will not be possible because the notification doesn't contain the message ID.";
148149
}
149150

150151
if (a._subjectRichParameters.contains("user")) {
@@ -162,7 +163,7 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
162163
callList.append(a);
163164
}
164165

165-
a._links.insert(al._primary? 0 : a._links.size(), al);
166+
activity._links.insert(link._primary? 0 : activity._links.size(), link);
166167
}
167168

168169
QUrl link(json.value("link").toString());
@@ -171,13 +172,13 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
171172
link.setScheme(ai->account()->url().scheme());
172173
link.setHost(ai->account()->url().host());
173174
}
174-
if (link.port() == -1) {
175-
link.setPort(ai->account()->url().port());
175+
if (url.port() == -1) {
176+
url.setPort(accountState->account()->url().port());
176177
}
177178
}
178-
a._link = link;
179+
activity._link = url;
179180

180-
list.append(a);
181+
list.append(activity);
181182
}
182183
emit newNotificationList(list);
183184
emit newIncomingCallsList(callList);

0 commit comments

Comments
 (0)