Rebase
This commit is contained in:
parent
2401c211ab
commit
d1ba9fd878
7 changed files with 169 additions and 5 deletions
|
|
@ -224,6 +224,57 @@ UserProfile::refreshDevices()
|
|||
fetchDeviceList(this->userid_);
|
||||
}
|
||||
|
||||
QVector<QString>
|
||||
UserProfile::getIgnoredUsers()
|
||||
{
|
||||
QVector<QString> vec;
|
||||
const std::optional<mtx::events::collections::RoomAccountDataEvents::variant> optEv =
|
||||
cache::client()->getAccountData(mtx::events::EventType::IgnoredUsers);
|
||||
if (optEv) {
|
||||
const auto &ev =
|
||||
std::get<mtx::events::EphemeralEvent<mtx::events::account_data::IgnoredUsers>>(*optEv)
|
||||
.content;
|
||||
for (const mtx::events::account_data::IgnoredUser &user : ev.users) {
|
||||
vec.append(QString::fromStdString(user.id));
|
||||
}
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
void
|
||||
UserProfile::ignoredStatus(const QString &id, const bool ignore)
|
||||
{
|
||||
auto old = this->getIgnoredUsers();
|
||||
if (ignore) {
|
||||
if (old.contains(id)) {
|
||||
emit this->room()->ignoredUser(id, tr("Already ignored"));
|
||||
return;
|
||||
}
|
||||
old.append(id);
|
||||
} else {
|
||||
old.removeOne(id);
|
||||
}
|
||||
|
||||
std::vector<mtx::events::account_data::IgnoredUser> content;
|
||||
for (const QString &item : old) {
|
||||
const mtx::events::account_data::IgnoredUser data{.id = item.toStdString()};
|
||||
content.push_back(data);
|
||||
}
|
||||
|
||||
const mtx::events::account_data::IgnoredUsers payload{.users{content}};
|
||||
|
||||
http::client()->put_account_data(payload, [this, id, ignore](mtx::http::RequestErr e) {
|
||||
if (ignore) {
|
||||
emit this->room()->ignoredUser(
|
||||
id, e ? std::optional(QString::fromStdString(e->matrix_error.error)) : std::nullopt);
|
||||
} else {
|
||||
emit this->unignoredUser(
|
||||
id, e ? QVariant(QString::fromStdString(e->matrix_error.error)) : QVariant());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
UserProfile::fetchDeviceList(const QString &userID)
|
||||
{
|
||||
|
|
@ -345,10 +396,6 @@ UserProfile::banUser()
|
|||
ChatPage::instance()->banUser(roomid_, this->userid_, QLatin1String(""));
|
||||
}
|
||||
|
||||
// void ignoreUser(){
|
||||
|
||||
// }
|
||||
|
||||
void
|
||||
UserProfile::kickUser()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -182,9 +182,10 @@ public:
|
|||
Q_INVOKABLE void unverify(const QString &device = QLatin1String(""));
|
||||
Q_INVOKABLE void fetchDeviceList(const QString &userID);
|
||||
Q_INVOKABLE void refreshDevices();
|
||||
Q_INVOKABLE QVector<QString> getIgnoredUsers();
|
||||
Q_INVOKABLE void banUser();
|
||||
Q_INVOKABLE void signOutDevice(const QString &deviceID);
|
||||
// Q_INVOKABLE void ignoreUser();
|
||||
Q_INVOKABLE void ignoredStatus(const QString &id, const bool ignore);
|
||||
Q_INVOKABLE void kickUser();
|
||||
Q_INVOKABLE void startChat();
|
||||
Q_INVOKABLE void startChat(bool encryptionEnabled);
|
||||
|
|
@ -201,6 +202,7 @@ signals:
|
|||
void displayError(const QString &errorMessage);
|
||||
void globalUsernameRetrieved(const QString &globalUser);
|
||||
void devicesChanged();
|
||||
void unignoredUser(const QString &id, const QVariant &err);
|
||||
|
||||
// internal
|
||||
void verificationStatiChanged();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue