Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RoomMessageEvent Edit Helpers #831

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Quotient/events/roommessageevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ std::unique_ptr<Base> RoomMessageEvent::content() const
return {};
}

void RoomMessageEvent::setPlainBody(const QString& newPlainBody)
{
editJson()[ContentKey] =
assembleContentJson(newPlainBody, rawMsgtype(), content(), relatesTo());
}

void RoomMessageEvent::setMsgType(MsgType newMsgType)
{
editJson()[ContentKey] =
assembleContentJson(plainBody(), msgTypeToJson(newMsgType), content(), relatesTo());
}

void RoomMessageEvent::setContent(std::unique_ptr<Base> content)
{
editJson()[ContentKey] =
Expand Down
6 changes: 6 additions & 0 deletions Quotient/events/roommessageevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ class QUOTIENT_API RoomMessageEvent : public RoomEvent {
//! \return an event content object if the event has content, nullptr otherwise.
std::unique_ptr<EventContent::Base> content() const;

//! Update the message JSON with the given plain body
void setPlainBody(const QString& newPlainBody);

//! Update the message JSON with the given message type
void setMsgType(MsgType newMsgType);

//! Update the message JSON with the given content
void setContent(std::unique_ptr<EventContent::Base> content);

Expand Down
Loading