1 | // SPDX-FileCopyrightText: 2018 Kitsune Ral <kitsune-ral@users.sf.net> |
---|---|
2 | // SPDX-License-Identifier: LGPL-2.1-or-later |
3 | |
4 | #include "eventitem.h" |
5 | |
6 | #include "events/roomavatarevent.h" |
7 | #include "events/roommessageevent.h" |
8 | |
9 | using namespace Quotient; |
10 | |
11 | void PendingEventItem::setFileUploaded(const FileSourceInfo& uploadedFileData) |
12 | { |
13 | // TODO: eventually we might introduce hasFileContent to RoomEvent, |
14 | // and unify the code below. |
15 | if (auto* rme = getAs<RoomMessageEvent>()) { |
16 | Q_ASSERT(rme->hasFileContent()); |
17 | rme->editContent(visitor: [&uploadedFileData](EventContent::TypedBase& ec) { |
18 | ec.fileInfo()->source = uploadedFileData; |
19 | }); |
20 | } |
21 | if (auto* rae = getAs<RoomAvatarEvent>()) { |
22 | Q_ASSERT(rae->content().fileInfo()); |
23 | rae->editContent(visitor: [&uploadedFileData](EventContent::FileInfo& fi) { |
24 | fi.source = uploadedFileData; |
25 | }); |
26 | } |
27 | setStatus(EventStatus::FileUploaded); |
28 | } |
29 | |
30 | // Not exactly sure why but this helps with the linker not finding |
31 | // Quotient::EventStatus::staticMetaObject when building Quaternion |
32 | #include "moc_eventitem.cpp" // NOLINT(bugprone-suspicious-include) |
33 |