Allow editing unsent messages
As of 0db4d71ec2 (Prevent edits of
unsent messages), messages that are edits of (or replies to) unsent
messages were not allowed. This change was made because otherwise
the edits were discarded due to use of txnid rather than mxid in the
"m.relates_to" object. Remove this restriction and fix the issue by
replacing txnid with mxid in all related events when the message is
sent (and we obtain mxid from the server).
This commit is contained in:
parent
9e2b5a1061
commit
9f798e76ed
4 changed files with 67 additions and 7 deletions
|
|
@ -1681,6 +1681,27 @@ Cache::storeEvent(const std::string &room_id,
|
|||
txn.commit();
|
||||
}
|
||||
|
||||
void
|
||||
Cache::replaceEvent(const std::string &room_id,
|
||||
const std::string &event_id,
|
||||
const mtx::events::collections::TimelineEvent &event)
|
||||
{
|
||||
auto txn = lmdb::txn::begin(env_);
|
||||
auto eventsDb = getEventsDb(txn, room_id);
|
||||
auto relationsDb = getRelationsDb(txn, room_id);
|
||||
auto event_json = mtx::accessors::serialize_event(event.data).dump();
|
||||
|
||||
{
|
||||
eventsDb.del(txn, event_id);
|
||||
eventsDb.put(txn, event_id, event_json);
|
||||
for (auto relation : mtx::accessors::relations(event.data).relations) {
|
||||
relationsDb.put(txn, relation.event_id, event_id);
|
||||
}
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
std::vector<std::string>
|
||||
Cache::relatedEvents(const std::string &room_id, const std::string &event_id)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue