aboutsummaryrefslogtreecommitdiff
path: root/lib/user.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-02 18:24:09 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-04 21:34:54 +0900
commitc9ace4f4037577846085fa6805a2918c5a2e745b (patch)
treee2714a724bd5c2ad7b0976ce2d48e5d192d20d8a /lib/user.cpp
parentb52f3998a454a18ad46d1f276052965b96cd2ca9 (diff)
downloadlibquotient-c9ace4f4037577846085fa6805a2918c5a2e745b.tar.gz
libquotient-c9ace4f4037577846085fa6805a2918c5a2e745b.zip
Support ignoring users
Closes #215.
Diffstat (limited to 'lib/user.cpp')
-rw-r--r--lib/user.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/user.cpp b/lib/user.cpp
index 025d669c..f6611309 100644
--- a/lib/user.cpp
+++ b/lib/user.cpp
@@ -199,6 +199,12 @@ User::User(QString userId, Connection* connection)
setObjectName(userId);
}
+Connection* User::connection() const
+{
+ Q_ASSERT(d->connection);
+ return d->connection;
+}
+
User::~User() = default;
QString User::id() const
@@ -260,7 +266,7 @@ void User::updateAvatarUrl(const QUrl& newUrl, const QUrl& oldUrl,
void User::rename(const QString& newName)
{
- auto job = d->connection->callApi<SetDisplayNameJob>(id(), newName);
+ auto job = connection()->callApi<SetDisplayNameJob>(id(), newName);
connect(job, &BaseJob::success, this, [=] { updateName(newName); });
}
@@ -283,20 +289,29 @@ void User::rename(const QString& newName, const Room* r)
bool User::setAvatar(const QString& fileName)
{
- return avatarObject().upload(d->connection, fileName,
+ return avatarObject().upload(connection(), fileName,
std::bind(&Private::setAvatarOnServer, d.data(), _1, this));
}
bool User::setAvatar(QIODevice* source)
{
- return avatarObject().upload(d->connection, source,
+ return avatarObject().upload(connection(), source,
std::bind(&Private::setAvatarOnServer, d.data(), _1, this));
}
void User::requestDirectChat()
{
- Q_ASSERT(d->connection);
- d->connection->requestDirectChat(d->userId);
+ connection()->requestDirectChat(d->userId);
+}
+
+void User::ignore()
+{
+ connection()->addToIgnoredUsers(this);
+}
+
+void User::unmarkIgnore()
+{
+ connection()->removeFromIgnoredUsers(this);
}
void User::Private::setAvatarOnServer(QString contentUri, User* q)