mirror of
https://gitlab.com/comunic/comunicwatcher
synced 2024-10-22 22:53:24 +00:00
31 lines
805 B
C++
31 lines
805 B
C++
#include "apirequest.h"
|
|
#include "notificationshelper.h"
|
|
|
|
NotificationsHelper::NotificationsHelper(QObject *parent) : QObject(parent)
|
|
{
|
|
|
|
}
|
|
|
|
void NotificationsHelper::getNewNotificationsNumbers()
|
|
{
|
|
APIRequest *req = new APIRequest("notifications/count_all_news");
|
|
req->exec();
|
|
connect(req, &APIRequest::done, this, &NotificationsHelper::getNotificationsNumberCallback);
|
|
|
|
}
|
|
|
|
void NotificationsHelper::getNotificationsNumberCallback(APIResponse response)
|
|
{
|
|
if(response.isError()) {
|
|
qDebug() << "Could not get the number of unread conversations!";
|
|
return;
|
|
}
|
|
|
|
auto obj = response.getObject();
|
|
NotificationsNumber n;
|
|
n.setNewNotifs(obj.value("notifications").toInt());
|
|
n.setUnreadConversations(obj.value("conversations").toInt());
|
|
|
|
emit onNewNumber(n);
|
|
}
|