libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
Quotient::RoomEvent Class Reference

#include <roomevent.h>

Inheritance diagram for Quotient::RoomEvent:
Collaboration diagram for Quotient::RoomEvent:

Public Member Functions

 ~RoomEvent () override
 
QString displayId () const
 A convenience function to get a display string for an event ID.
 
QString id () const
 The event_id JSON value for the event.
 
QDateTime originTimestamp () const
 
QString roomId () const
 
QString senderId () const
 
bool isRedacted () const
 
const event_ptr_tt< RedactionEvent > & redactedBecause () const
 
QString redactionReason () const
 
QString transactionId () const
 The transaction_id JSON value for the event.
 
bool isStateEvent () const
 
QString stateKey () const
 
void setRoomId (const QString &roomId)
 Fill the pending event object with the room id.
 
void setSender (const QString &senderId)
 Fill the pending event object with the sender id.
 
void setTransactionId (const QString &txnId)
 Fill the pending event object with the transaction id.
 
void addId (const QString &newId)
 Add an event id to locally created events after they are sent.
 
void setOriginalEvent (event_ptr_tt< EncryptedEvent > &&originalEvent)
 
const EncryptedEventoriginalEvent () const
 
const QJsonObject encryptedJson () const
 
bool isReply (bool includeFallbacks=false) const
 Determine whether the event is a reply to another message.
 
QString replyEventId (bool includeFallbacks=false) const
 The ID for the event being replied to.
 
std::optional< EventRelationrelatesTo () const
 The EventRelation for this event.
 
void setRelation (const EventRelation &er)
 Set the event relation data.
 
void clearRelation ()
 Remove the event relation data.
 
QJsonObject relationsToThis () const
 Get relations to this event.
 
bool hasRelationship (EventRelation::typeid_t relationTypeId) const
 Check whether there are other events relating to this.
 
QString replacedEvent () const
 Obtain id of an event replaced by the current one.
 
bool isReplaced () const
 Determine whether the event has been replaced.
 
QString replacedBy () const
 Get the id of the event that replaced this one.
 
bool isThreaded () const
 Determine whether the event is part of a thread.
 
QString threadRootEventId () const
 The event ID for the thread root event.
 
- Public Member Functions inherited from Quotient::Event
virtual const AbstractEventMetaTypemetaType () const
 
 Event (Event &&) noexcept=default
 
Eventoperator= (Event &&)=delete
 
virtual ~Event ()
 
QString matrixType () const
 Exact Matrix type stored in JSON.
 
template<EventClass EventT>
bool is () const
 
template<typename... VisitorTs>
auto switchOnType (VisitorTs &&... visitors) const
 Apply one of the visitors based on the actual event type.
 
const QJsonObjectfullJson () const
 
const QJsonObject contentJson () const
 
template<typename T , typename KeyT >
const T contentPart (KeyT &&key) const
 Get a part of the content object, assuming a given type.
 
const QJsonObject unsignedJson () const
 
template<typename T , typename KeyT >
const T unsignedPart (KeyT &&key) const
 Get a part of the unsigned object, assuming a given type.
 

Protected Member Functions

 RoomEvent (const QJsonObject &json)
 
void dumpTo (QDebug dbg) const override
 
virtual void afterRelationChange ()
 
- Protected Member Functions inherited from Quotient::Event
 Event (const QJsonObject &json)
 
QJsonObjecteditJson ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Quotient::Event
static QJsonObject basicJson (const QString &matrixType, const QJsonObject &content)
 Make a minimal correct Matrix event JSON.
 
- Static Public Attributes inherited from Quotient::Event
static EventMetaType< EventBaseMetaType {}
 

Detailed Description

Definition at line 24 of file roomevent.h.

Constructor & Destructor Documentation

◆ ~RoomEvent()

Quotient::RoomEvent::~RoomEvent ( )
override

◆ RoomEvent()

Quotient::RoomEvent::RoomEvent ( const QJsonObject json)
explicitprotected

Member Function Documentation

◆ addId()

void Quotient::RoomEvent::addId ( const QString newId)

Add an event id to locally created events after they are sent.

When a new event is created locally, it has no id; the homeserver assigns it once the event is sent. This function allows to add the id once the confirmation from the server is received. There should be no id set previously in the event. It's the responsibility of the code calling addId() to notify clients about the change; there's no signal or callback for that in RoomEvent.

◆ afterRelationChange()

virtual void Quotient::RoomEvent::afterRelationChange ( )
inlineprotectedvirtual

Definition at line 175 of file roomevent.h.

◆ clearRelation()

void Quotient::RoomEvent::clearRelation ( )

Remove the event relation data.

Clears any relation from this event to another event.

See also
setRelation

◆ displayId()

QString Quotient::RoomEvent::displayId ( ) const

A convenience function to get a display string for an event ID.

Returns
id() if the event id is not empty, otherwise transactionId(); this is useful to deal with pending and normal events uniformly.
See also
id(), transactionId()

◆ dumpTo()

void Quotient::RoomEvent::dumpTo ( QDebug  dbg) const
overrideprotectedvirtual

Reimplemented from Quotient::Event.

Reimplemented in Quotient::StateEvent.

◆ encryptedJson()

const QJsonObject Quotient::RoomEvent::encryptedJson ( ) const

◆ hasRelationship()

bool Quotient::RoomEvent::hasRelationship ( EventRelation::typeid_t  relationTypeId) const

Check whether there are other events relating to this.

Note
This method uses unsigned/m.relations object that may not have fully accurate data. Use with caution.

◆ id()

QString Quotient::RoomEvent::id ( ) const

The event_id JSON value for the event.

◆ isRedacted()

bool Quotient::RoomEvent::isRedacted ( ) const
inline

Definition at line 42 of file roomevent.h.

◆ isReplaced()

bool Quotient::RoomEvent::isReplaced ( ) const

Determine whether the event has been replaced.

Returns
true if this event has been overridden by another event with "rel_type": "m.replace"; false otherwise

◆ isReply()

bool Quotient::RoomEvent::isReply ( bool  includeFallbacks = false) const

Determine whether the event is a reply to another message.

Parameters
includeFallbacksinclude thread fallback replies for non-threaded clients.
Returns
true if this event is a reply, i.e. it has "m.in_reply_to" event ID and is not a thread fallback (except where includeFallbacks is true); false otherwise.
Note
It's possible to reply to another message in a thread so this function will return true for a "rel_type" of "m.thread" if "is_falling_back" is false.

◆ isStateEvent()

bool Quotient::RoomEvent::isStateEvent ( ) const

◆ isThreaded()

bool Quotient::RoomEvent::isThreaded ( ) const

Determine whether the event is part of a thread.

Returns
true if this event is part of a thread, i.e. it has "rel_type": "m.thread" or "m.relations": { "m.thread": {}}; false otherwise.

◆ originalEvent()

const EncryptedEvent * Quotient::RoomEvent::originalEvent ( ) const
inline

Definition at line 80 of file roomevent.h.

◆ originTimestamp()

QDateTime Quotient::RoomEvent::originTimestamp ( ) const

◆ redactedBecause()

const event_ptr_tt< RedactionEvent > & Quotient::RoomEvent::redactedBecause ( ) const
inline

Definition at line 43 of file roomevent.h.

◆ redactionReason()

QString Quotient::RoomEvent::redactionReason ( ) const

◆ relatesTo()

std::optional< EventRelation > Quotient::RoomEvent::relatesTo ( ) const

The EventRelation for this event.

Returns
an EventRelation object which can be checked for type if it exists, std::nullopt otherwise.

◆ relationsToThis()

QJsonObject Quotient::RoomEvent::relationsToThis ( ) const

Get relations to this event.

This is a counterpart of relatesTo(): it returns the list of (known, see the note) relations to the current event.

Note
This method uses unsigned/m.relations object that may not have fully accurate data. Use with caution.

◆ replacedBy()

QString Quotient::RoomEvent::replacedBy ( ) const

Get the id of the event that replaced this one.

Returns
The id of the replacement event if the current event has been replaced by another one; an empty string otherwise.
See also
isReplaced, replacedEvent

◆ replacedEvent()

QString Quotient::RoomEvent::replacedEvent ( ) const

Obtain id of an event replaced by the current one.

See also
RoomEvent::isReplaced, RoomEvent::replacedBy

◆ replyEventId()

QString Quotient::RoomEvent::replyEventId ( bool  includeFallbacks = false) const

The ID for the event being replied to.

Parameters
includeFallbacksinclude thread fallback replies for non-threaded clients.
Returns
The event ID for a reply, this includes threaded replies where "rel_type" is "m.thread" and "is_falling_back" is false (except where includeFallbacks is true).

◆ roomId()

QString Quotient::RoomEvent::roomId ( ) const

◆ senderId()

QString Quotient::RoomEvent::senderId ( ) const

◆ setOriginalEvent()

void Quotient::RoomEvent::setOriginalEvent ( event_ptr_tt< EncryptedEvent > &&  originalEvent)

◆ setRelation()

void Quotient::RoomEvent::setRelation ( const EventRelation er)

Set the event relation data.

Adds the relation to another event with the contents of er. If another relation exists it is entirely overwritten.

◆ setRoomId()

void Quotient::RoomEvent::setRoomId ( const QString roomId)

Fill the pending event object with the room id.

◆ setSender()

void Quotient::RoomEvent::setSender ( const QString senderId)

Fill the pending event object with the sender id.

◆ setTransactionId()

void Quotient::RoomEvent::setTransactionId ( const QString txnId)

Fill the pending event object with the transaction id.

Parameters
txnId- transaction id, normally obtained from Connection::generateTxnId()

◆ stateKey()

QString Quotient::RoomEvent::stateKey ( ) const

◆ threadRootEventId()

QString Quotient::RoomEvent::threadRootEventId ( ) const

The event ID for the thread root event.

Note
This will return the ID of the event if it is the thread root.
If the event is the thread root event and has not been updated with the server-side the function will return an empty string as we can't tell if the message is threaded.
Returns
The event ID of the thread root if threaded, an empty string otherwise.

◆ transactionId()

QString Quotient::RoomEvent::transactionId ( ) const

The transaction_id JSON value for the event.


The documentation for this class was generated from the following file: