Changeset View
Changeset View
Standalone View
Standalone View
src/core/rocketchatbackend.cpp
Show First 20 Lines • Show All 181 Lines • ▼ Show 20 Line(s) | 181 | for (auto it = dispatcher.cbegin(); it != dispatcher.cend(); ++it) { | |||
---|---|---|---|---|---|
182 | it.key()->addMessages(it.value()); | 182 | it.key()->addMessages(it.value()); | ||
183 | } | 183 | } | ||
184 | } | 184 | } | ||
185 | 185 | | |||
186 | void RocketChatBackend::parseOwnInfoDown(const QJsonObject &replyObject) | 186 | void RocketChatBackend::parseOwnInfoDown(const QJsonObject &replyObject) | ||
187 | { | 187 | { | ||
188 | //Move code in rocketchataccount directly ? | 188 | //Move code in rocketchataccount directly ? | ||
189 | //qDebug() << "replyJson " << replyJson; | 189 | //qDebug() << "replyJson " << replyJson; | ||
190 | User *user = new User; | 190 | User user; | ||
191 | user->setUserId(replyObject.value(QLatin1String("_id")).toString()); | 191 | user.setUserId(replyObject.value(QLatin1String("_id")).toString()); | ||
192 | user->setUserName(replyObject.value(QLatin1String("username")).toString()); | 192 | user.setUserName(replyObject.value(QLatin1String("username")).toString()); | ||
193 | user->setStatus(replyObject.value(QLatin1String("status")).toString()); | 193 | user.setStatus(replyObject.value(QLatin1String("status")).toString()); | ||
194 | if (user->isValid()) { | 194 | if (user.isValid()) { | ||
195 | mRocketChatAccount->usersModel()->addUser(user); | 195 | mRocketChatAccount->usersModel()->addUser(user); | ||
196 | } else { | 196 | } else { | ||
197 | qCWarning(RUQOLA_LOG) << " Error during parsing user" << replyObject; | 197 | qCWarning(RUQOLA_LOG) << " Error during parsing user" << replyObject; | ||
198 | } | 198 | } | ||
199 | } | 199 | } | ||
200 | 200 | | |||
201 | void RocketChatBackend::slotLoginStatusChanged() | 201 | void RocketChatBackend::slotLoginStatusChanged() | ||
202 | { | 202 | { | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 257 | { | |||
262 | } else if (collection == QLatin1String("users")) { | 262 | } else if (collection == QLatin1String("users")) { | ||
263 | const QJsonObject fields = object.value(QLatin1String("fields")).toObject(); | 263 | const QJsonObject fields = object.value(QLatin1String("fields")).toObject(); | ||
264 | const QString username = fields.value(QLatin1String("username")).toString(); | 264 | const QString username = fields.value(QLatin1String("username")).toString(); | ||
265 | if (username == mRocketChatAccount->settings()->userName()) { | 265 | if (username == mRocketChatAccount->settings()->userName()) { | ||
266 | mRocketChatAccount->settings()->setUserId(object[QStringLiteral("id")].toString()); | 266 | mRocketChatAccount->settings()->setUserId(object[QStringLiteral("id")].toString()); | ||
267 | qCDebug(RUQOLA_LOG) << "User id set to " << mRocketChatAccount->settings()->userId(); | 267 | qCDebug(RUQOLA_LOG) << "User id set to " << mRocketChatAccount->settings()->userId(); | ||
268 | } else { | 268 | } else { | ||
269 | //TODO add current user ? me ? | 269 | //TODO add current user ? me ? | ||
270 | User *user = new User; | 270 | User user; | ||
271 | user->parseUser(object); | 271 | user.parseUser(object); | ||
272 | if (mRocketChatAccount->ruqolaLogger()) { | 272 | if (mRocketChatAccount->ruqolaLogger()) { | ||
273 | QJsonDocument d; | 273 | QJsonDocument d; | ||
274 | d.setObject(object); | 274 | d.setObject(object); | ||
275 | mRocketChatAccount->ruqolaLogger()->dataReceived(QByteArrayLiteral("users: Add User:") + d.toJson()); | 275 | mRocketChatAccount->ruqolaLogger()->dataReceived(QByteArrayLiteral("users: Add User:") + d.toJson()); | ||
276 | } else { | 276 | } else { | ||
277 | qCDebug(RUQOLA_LOG) << "USER ADDED VALUE" << object; | 277 | qCDebug(RUQOLA_LOG) << "USER ADDED VALUE" << object; | ||
278 | } | 278 | } | ||
279 | mRocketChatAccount->usersModel()->addUser(user); | 279 | mRocketChatAccount->usersModel()->addUser(user); | ||
▲ Show 20 Lines • Show All 448 Lines • Show Last 20 Lines |