Ability to change room avatar.
This commit is contained in:
@@ -8,8 +8,10 @@
|
||||
#include "events/roommessageevent.h"
|
||||
|
||||
#include "csapi/account-data.h"
|
||||
#include "csapi/content-repo.h"
|
||||
#include "csapi/joining.h"
|
||||
#include "csapi/logout.h"
|
||||
#include "csapi/profile.h"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
@@ -310,3 +312,12 @@ int Controller::dpi() {
|
||||
void Controller::setDpi(int dpi) {
|
||||
SettingsGroup("Interface").setValue("dpi", dpi);
|
||||
}
|
||||
|
||||
void Controller::changeAvatar(Connection* conn, QUrl localFile) {
|
||||
auto job = conn->uploadFile(localFile.toLocalFile());
|
||||
if (isJobRunning(job)) {
|
||||
connect(job, &BaseJob::success, this, [this, conn, job] {
|
||||
conn->callApi<SetAvatarUrlJob>(conn->userId(), job->contentUri());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ class Controller : public QObject {
|
||||
void createRoom(Connection* c, const QString& name, const QString& topic);
|
||||
void createDirectChat(Connection* c, const QString& userID);
|
||||
void playAudio(QUrl localFile);
|
||||
void changeAvatar(Connection* conn, QUrl localFile);
|
||||
};
|
||||
|
||||
#endif // CONTROLLER_H
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "csapi/account-data.h"
|
||||
#include "csapi/content-repo.h"
|
||||
#include "csapi/leaving.h"
|
||||
#include "csapi/room_state.h"
|
||||
#include "csapi/rooms.h"
|
||||
#include "csapi/typing.h"
|
||||
#include "events/accountdataevents.h"
|
||||
#include "events/typingevent.h"
|
||||
@@ -304,3 +306,13 @@ QString SpectralRoom::backgroundMediaId() {
|
||||
auto url = backgroundUrl();
|
||||
return url.authority() + url.path();
|
||||
}
|
||||
|
||||
void SpectralRoom::changeAvatar(QUrl localFile) {
|
||||
auto job = connection()->uploadFile(localFile.toLocalFile());
|
||||
if (isJobRunning(job)) {
|
||||
connect(job, &BaseJob::success, this, [this, job] {
|
||||
connection()->callApi<SetRoomStateJob>(
|
||||
id(), "m.room.avatar", QJsonObject{{"url", job->contentUri()}});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,6 +305,7 @@ class SpectralRoom : public Room {
|
||||
QString eventId,
|
||||
QString replyContent,
|
||||
QString sendContent);
|
||||
void changeAvatar(QUrl localFile);
|
||||
};
|
||||
|
||||
#endif // SpectralRoom_H
|
||||
|
||||
Reference in New Issue
Block a user