-
Notifications
You must be signed in to change notification settings - Fork 17
refactor: rename confusing origin getter to senderDomain in EventWrapper #329
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
6c265ff
61e51f5
598eb02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,6 +72,13 @@ export abstract class PersistentEventBase< | |
| private authEventsIds: Set<EventID> = new Set(); | ||
| private prevEventsIds: Set<EventID> = new Set(); | ||
|
|
||
| /** | ||
| * The origin server that created this event. | ||
| * This is metadata stored separately from the PDU and is used to track | ||
| * which server the event came from in federation scenarios. | ||
| */ | ||
| public eventOrigin?: string; | ||
|
Member
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. why is this new property needed?
Author
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. Great catch — you’re right, that extra property is not needed. I removed
This keeps the behavior clear without introducing extra mutable state in |
||
|
|
||
| constructor( | ||
| event: PduWithHashesAndSignaturesOptional, | ||
| public readonly version: Version, | ||
|
|
@@ -118,13 +125,18 @@ export abstract class PersistentEventBase< | |
|
|
||
| // TODO: This should be removed or different name used instead? | ||
|
|
||
| get origin() { | ||
| const domain = extractDomainFromId(this.rawEvent.sender); | ||
| if (!domain) { | ||
| throw new Error('Invalid sender, no domain found'); | ||
| } | ||
| return domain; | ||
| } | ||
| /** | ||
| * Gets the domain of the sender from their ID. | ||
| * @returns {string} The sender's domain. | ||
| * @throws {Error} If the sender ID is invalid or has no domain. | ||
| */ | ||
| get senderDomain() { | ||
| const domain = extractDomainFromId(this.rawEvent.sender); | ||
| if (!domain) { | ||
| throw new Error('Invalid sender, no domain found'); | ||
| } | ||
| return domain; | ||
| } | ||
|
|
||
| get residentServer() { | ||
| const residentServer = extractDomainFromId(this.rawEvent.room_id); | ||
|
|
@@ -142,6 +154,15 @@ export abstract class PersistentEventBase< | |
| return this.rawEvent.origin_server_ts; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the origin server that created this event. | ||
| * This is the server identity where the event originated (from federation). | ||
| * @returns {string | undefined} The origin server name, or undefined if not set. | ||
| */ | ||
| get origin() { | ||
| return this.eventOrigin; | ||
| } | ||
|
|
||
| // if we are accessing the inner event, the event itself should be frozen immediately to not change the reference hash any longer, affecting the id | ||
| // if anywhere the code still tries to, we will throw an error, which is why "lock" isn't just a flag in the class. | ||
| get event(): Readonly<PduForType<Type>> { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.