aboutsummaryrefslogtreecommitdiff
path: root/lib/eventitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/eventitem.cpp')
-rw-r--r--lib/eventitem.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/eventitem.cpp b/lib/eventitem.cpp
index 79ef769c..8ec3fe48 100644
--- a/lib/eventitem.cpp
+++ b/lib/eventitem.cpp
@@ -17,3 +17,29 @@
*/
#include "eventitem.h"
+
+#include "events/roommessageevent.h"
+#include "events/roomavatarevent.h"
+
+using namespace QMatrixClient;
+
+void PendingEventItem::setFileUploaded(const QUrl& remoteUrl)
+{
+ // TODO: eventually we might introduce hasFileContent to RoomEvent,
+ // and unify the code below.
+ if (auto* rme = getAs<RoomMessageEvent>())
+ {
+ Q_ASSERT(rme->hasFileContent());
+ rme->editContent([remoteUrl] (EventContent::TypedBase& ec) {
+ ec.fileInfo()->url = remoteUrl;
+ });
+ }
+ if (auto* rae = getAs<RoomAvatarEvent>())
+ {
+ Q_ASSERT(rae->content().fileInfo());
+ rae->editContent([remoteUrl] (EventContent::FileInfo& fi) {
+ fi.url = remoteUrl;
+ });
+ }
+ setStatus(EventStatus::FileUploaded);
+}