aboutsummaryrefslogtreecommitdiff
path: root/lib/eventitem.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-12-26 19:36:00 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-01-05 21:01:32 +0900
commitf6740316dfcdb287b019b4258df2213c31965d42 (patch)
treedb9bec725d6f578f4efd591992c6ed7e5942c6a9 /lib/eventitem.cpp
parent77830a97e524a4bd27d8cbcd3830cbe450a5755a (diff)
downloadlibquotient-f6740316dfcdb287b019b4258df2213c31965d42.tar.gz
libquotient-f6740316dfcdb287b019b4258df2213c31965d42.zip
PendingEventItem: add FileUploaded status and setFileUploaded helper function
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);
+}