-
-
Notifications
You must be signed in to change notification settings - Fork 583
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
Ignore thread relations on state events for consistency with edits #3540
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ import { | |
import { Crypto } from "../crypto"; | ||
import { deepSortedObjectEntries, internaliseString } from "../utils"; | ||
import { RoomMember } from "./room-member"; | ||
import { Thread, ThreadEvent, ThreadEventHandlerMap, THREAD_RELATION_TYPE } from "./thread"; | ||
import { Thread, THREAD_RELATION_TYPE, ThreadEvent, ThreadEventHandlerMap } from "./thread"; | ||
import { IActionsObject } from "../pushprocessor"; | ||
import { TypedReEmitter } from "../ReEmitter"; | ||
import { MatrixError } from "../http-api"; | ||
|
@@ -576,6 +576,10 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat | |
* Get the event ID of the thread head | ||
*/ | ||
public get threadRootId(): string | undefined { | ||
// don't allow state events to be threaded as per the spec | ||
if (this.isState()) { | ||
return undefined; | ||
} | ||
const relatesTo = this.getWireContent()?.["m.relates_to"]; | ||
if (relatesTo?.rel_type === THREAD_RELATION_TYPE.name) { | ||
return relatesTo.event_id; | ||
|
@@ -597,6 +601,11 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat | |
* A helper to check if an event is a thread's head or not | ||
*/ | ||
public get isThreadRoot(): boolean { | ||
// don't allow state events to be threaded as per the spec | ||
if (this.isState()) { | ||
return false; | ||
} | ||
|
||
const threadDetails = this.getServerAggregatedRelation<IThreadBundledRelationship>(THREAD_RELATION_TYPE.name); | ||
|
||
// Bundled relationships only returned when the sync response is limited | ||
|
@@ -1365,7 +1374,11 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat | |
// Relation info is lifted out of the encrypted content when sent to | ||
// encrypted rooms, so we have to check `getWireContent` for this. | ||
const relation = this.getWireContent()?.["m.relates_to"]; | ||
if (this.isState() && relation?.rel_type === RelationType.Replace) { | ||
if ( | ||
this.isState() && | ||
relation?.rel_type && | ||
([RelationType.Replace, RelationType.Thread] as string[]).includes(relation.rel_type) | ||
) { | ||
// State events cannot be m.replace relations | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... or some other type of relation? ;) |
||
return false; | ||
} | ||
|
@@ -1618,6 +1631,10 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat | |
* @param thread - the thread | ||
*/ | ||
public setThread(thread?: Thread): void { | ||
// don't allow state events to be threaded as per the spec | ||
if (this.isState()) { | ||
return; | ||
} | ||
if (this.thread) { | ||
this.reEmitter.stopReEmitting(this.thread, [ThreadEvent.Update]); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implicit cast to bool