When an event is first transmitted, a temporary copy of the event is * inserted into the timeline, with a temporary event id, and a status of * 'SENDING'. * *
Once the echo comes back from the server, the content of the event * (MatrixEvent.event) is replaced by the complete event from the homeserver, * thus updating its event id, as well as server-generated fields such as the * timestamp. Its status is set to null. * *
Once the /send request completes, if the remote echo has not already * arrived, the event is updated with a new event id and the status is set to * 'SENT'. The server-generated fields are of course not updated yet. * *
If the /send fails, In this case, the event's status is set to * 'NOT_SENT'. If it is later resent, the process starts again, setting the * status to 'SENDING'. Alternatively, the message may be cancelled, which * removes the event from the room, and sets the status to 'CANCELLED'. * *
This event is raised to reflect each of the transitions above.
*
* @param event - The matrix event which has been updated
*
* @param room - The room containing the redacted event
*
* @param oldEventId - The previous event id (the temporary event id,
* except when updating a successfully-sent event when its echo arrives)
*
* @param oldStatus - The previous event status.
*/
[RoomEvent.LocalEchoUpdated]: (event: MatrixEvent, room: Room, oldEventId?: string, oldStatus?: EventStatus | null) => void;
[RoomEvent.OldStateUpdated]: (room: Room, previousRoomState: RoomState, roomState: RoomState) => void;
[RoomEvent.CurrentStateUpdated]: (room: Room, previousRoomState: RoomState, roomState: RoomState) => void;
[RoomEvent.HistoryImportedWithinTimeline]: (markerEvent: MatrixEvent, room: Room) => void;
[RoomEvent.UnreadNotifications]: (unreadNotifications?: NotificationCount, threadId?: string) => void;
[RoomEvent.TimelineRefresh]: (room: Room, eventTimelineSet: EventTimelineSet) => void;
[ThreadEvent.New]: (thread: Thread, toStartOfTimeline: boolean) => void;
/**
* Fires when a new poll instance is added to the room state
* @param poll - the new poll
*/
[PollEvent.New]: (poll: Poll) => void;
} & Pick For a room, we store an ordered sequence of timelines, which may or may not
* be continuous. Each timeline lists a series of events, as well as tracking
* the room state at the start and the end of the timeline. It also tracks
* forward and backward pagination tokens, as well as containing links to the
* next timeline in the sequence.
*
* There is one special timeline - the 'live' timeline, which represents the
* timeline to which events are being added in real-time as they are received
* from the /sync API. Note that you should not retain references to this
* timeline - even if it is the current timeline right now, it may not remain
* so if the server gives us a timeline gap in /sync.
*
* In order that we can find events from their ids later, we also maintain a
* map from event_id to timeline and index.
*
* @param roomId - Required. The ID of this room.
* @param client - Required. The client, used to lazy load members.
* @param myUserId - Required. The ID of the syncing user.
* @param opts - Configuration options
*/
constructor(roomId: string, client: MatrixClient, myUserId: string, opts?: IOpts);
private threadTimelineSetsPromise;
createThreadsTimelineSets(): Promise<[EventTimelineSet, EventTimelineSet] | null>;
/**
* Bulk decrypt critical events in a room
*
* Critical events represents the minimal set of events to decrypt
* for a typical UI to function properly
*
* - Last event of every room (to generate likely message preview)
* - All events up to the read receipt (to calculate an accurate notification count)
*
* @returns Signals when all events have been decrypted
*/
decryptCriticalEvents(): Promise This is used when /sync returns a 'limited' timeline.
*
* @param backPaginationToken - token for back-paginating the new timeline
* @param forwardPaginationToken - token for forward-paginating the old live timeline,
* if absent or null, all timelines are reset, removing old ones (including the previous live
* timeline which would otherwise be unable to paginate forwards without this token).
* Removing just the old live timeline whilst preserving previous ones is not supported.
*/
resetLiveTimeline(backPaginationToken?: string | null, forwardPaginationToken?: string | null): void;
/**
* Fix up this.timeline, this.oldState and this.currentState
*
* @internal
*/
private fixUpLegacyTimelineFields;
/**
* Returns whether there are any devices in the room that are unverified
*
* Note: Callers should first check if crypto is enabled on this device. If it is
* disabled, then we aren't tracking room devices at all, so we can't answer this, and an
* error will be thrown.
*
* @returns the result
*/
hasUnverifiedDevices(): Promise Will fire "Room.timeline" for each event added.
*
* @param events - A list of events to add.
*
* @param toStartOfTimeline - True to add these events to the start
* (oldest) instead of the end (newest) of the timeline. If true, the oldest
* event will be the last element of 'events'.
*
* @param timeline - timeline to
* add events to.
*
* @param paginationToken - token for the next batch of events
*
* @remarks
* Fires {@link RoomEvent.Timeline}
*/
addEventsToTimeline(events: MatrixEvent[], toStartOfTimeline: boolean, timeline: EventTimeline, paginationToken?: string): void;
/**
* Get the instance of the thread associated with the current event
* @param eventId - the ID of the current event
* @returns a thread instance if known
*/
getThread(eventId: string): Thread | null;
/**
* Get all the known threads in the room
*/
getThreads(): Thread[];
/**
* Get a member from the current room state.
* @param userId - The user ID of the member.
* @returns The member or `null`.
*/
getMember(userId: string): RoomMember | null;
/**
* Get all currently loaded members from the current
* room state.
* @returns Room members
*/
getMembers(): RoomMember[];
/**
* Get a list of members whose membership state is "join".
* @returns A list of currently joined members.
*/
getJoinedMembers(): RoomMember[];
/**
* Returns the number of joined members in this room
* This method caches the result.
* This is a wrapper around the method of the same name in roomState, returning
* its result for the room's current state.
* @returns The number of members in this room whose membership is 'join'
*/
getJoinedMemberCount(): number;
/**
* Returns the number of invited members in this room
* @returns The number of members in this room whose membership is 'invite'
*/
getInvitedMemberCount(): number;
/**
* Returns the number of invited + joined members in this room
* @returns The number of members in this room whose membership is 'invite' or 'join'
*/
getInvitedAndJoinedMemberCount(): number;
/**
* Get a list of members with given membership state.
* @param membership - The membership state.
* @returns A list of members with the given membership state.
*/
getMembersWithMembership(membership: string): RoomMember[];
/**
* Get a list of members we should be encrypting for in this room
* @returns A list of members who
* we should encrypt messages for in this room.
*/
getEncryptionTargetMembers(): Promise The event is added to either the pendingEventList, or the live timeline,
* depending on the setting of opts.pendingEventOrdering.
*
* This is an internal method, intended for use by MatrixClient.
*
* @param event - The event to add.
*
* @param txnId - Transaction id for this outgoing event
*
* @throws if the event doesn't have status SENDING, or we aren't given a
* unique transaction id.
*
* @remarks
* Fires {@link RoomEvent.LocalEchoUpdated}
*/
addPendingEvent(event: MatrixEvent, txnId: string): void;
/**
* Persists all pending events to local storage
*
* If the current room is encrypted only encrypted events will be persisted
* all messages that are not yet encrypted will be discarded
*
* This is because the flow of EVENT_STATUS transition is
* `queued => sending => encrypting => sending => sent`
*
* Steps 3 and 4 are skipped for unencrypted room.
* It is better to discard an unencrypted message rather than persisting
* it locally for everyone to read
*/
private savePendingEvents;
/**
* Used to aggregate the local echo for a relation, and also
* for re-applying a relation after it's redaction has been cancelled,
* as the local echo for the redaction of the relation would have
* un-aggregated the relation. Note that this is different from regular messages,
* which are just kept detached for their local echo.
*
* Also note that live events are aggregated in the live EventTimelineSet.
* @param event - the relation event that needs to be aggregated.
*/
private aggregateNonLiveRelation;
getEventForTxnId(txnId: string): MatrixEvent | undefined;
/**
* Deal with the echo of a message we sent.
*
* We move the event to the live timeline if it isn't there already, and
* update it.
*
* @param remoteEvent - The event received from
* /sync
* @param localEvent - The local echo, which
* should be either in the pendingEventList or the timeline.
*
* @internal
*
* @remarks
* Fires {@link RoomEvent.LocalEchoUpdated}
*/
handleRemoteEcho(remoteEvent: MatrixEvent, localEvent: MatrixEvent): void;
/**
* Update the status / event id on a pending event, to reflect its transmission
* progress.
*
* This is an internal method.
*
* @param event - local echo event
* @param newStatus - status to assign
* @param newEventId - new event id to assign. Ignored unless newStatus == EventStatus.SENT.
*
* @remarks
* Fires {@link RoomEvent.LocalEchoUpdated}
*/
updatePendingEvent(event: MatrixEvent, newStatus: EventStatus, newEventId?: string): void;
private revertRedactionLocalEcho;
/**
* Add some events to this room. This can include state events, message
* events and typing notifications. These events are treated as "live" so
* they will go to the end of the timeline.
*
* @param events - A list of events to add.
* @param addLiveEventOptions - addLiveEvent options
* @throws If `duplicateStrategy` is not falsey, 'replace' or 'ignore'.
*/
addLiveEvents(events: MatrixEvent[], addLiveEventOptions?: IAddLiveEventOptions): void;
/**
* @deprecated In favor of the overload with `IAddLiveEventOptions`
*/
addLiveEvents(events: MatrixEvent[], duplicateStrategy?: DuplicateStrategy, fromCache?: boolean): void;
partitionThreadedEvents(events: MatrixEvent[]): [timelineEvents: MatrixEvent[], threadedEvents: MatrixEvent[]];
/**
* Given some events, find the IDs of all the thread roots that are referred to by them.
*/
private findThreadRoots;
/**
* Add a receipt event to the room.
* @param event - The m.receipt event.
* @param synthetic - True if this event is implicit.
*/
addReceipt(event: MatrixEvent, synthetic?: boolean): void;
/**
* Adds/handles ephemeral events such as typing notifications and read receipts.
* @param events - A list of events to process
*/
addEphemeralEvents(events: MatrixEvent[]): void;
/**
* Removes events from this room.
* @param eventIds - A list of eventIds to remove.
*/
removeEvents(eventIds: string[]): void;
/**
* Removes a single event from this room.
*
* @param eventId - The id of the event to remove
*
* @returns true if the event was removed from any of the room's timeline sets
*/
removeEvent(eventId: string): boolean;
/**
* Recalculate various aspects of the room, including the room name and
* room summary. Call this any time the room's current state is modified.
* May fire "Room.name" if the room name is updated.
*
* @remarks
* Fires {@link RoomEvent.Name}
*/
recalculate(): void;
/**
* Update the room-tag event for the room. The previous one is overwritten.
* @param event - the m.tag event
*/
addTags(event: MatrixEvent): void;
/**
* Update the account_data events for this room, overwriting events of the same type.
* @param events - an array of account_data events to add
*/
addAccountData(events: MatrixEvent[]): void;
/**
* Access account_data event of given event type for this room
* @param type - the type of account_data event to be accessed
* @returns the account_data event in question
*/
getAccountData(type: EventType | string): MatrixEvent | undefined;
/**
* Returns whether the syncing user has permission to send a message in the room
* @returns true if the user should be permitted to send
* message events into the room.
*/
maySendMessage(): boolean;
/**
* Returns whether the given user has permissions to issue an invite for this room.
* @param userId - the ID of the Matrix user to check permissions for
* @returns true if the user should be permitted to issue invites for this room.
*/
canInvite(userId: string): boolean;
/**
* Returns the join rule based on the m.room.join_rule state event, defaulting to `invite`.
* @returns the join_rule applied to this room
*/
getJoinRule(): JoinRule;
/**
* Returns the history visibility based on the m.room.history_visibility state event, defaulting to `shared`.
* @returns the history_visibility applied to this room
*/
getHistoryVisibility(): HistoryVisibility;
/**
* Returns the history visibility based on the m.room.history_visibility state event, defaulting to `shared`.
* @returns the history_visibility applied to this room
*/
getGuestAccess(): GuestAccess;
/**
* Returns the type of the room from the `m.room.create` event content or undefined if none is set
* @returns the type of the room.
*/
getType(): RoomType | string | undefined;
/**
* Returns whether the room is a space-room as defined by MSC1772.
* @returns true if the room's type is RoomType.Space
*/
isSpaceRoom(): boolean;
/**
* Returns whether the room is a call-room as defined by MSC3417.
* @returns true if the room's type is RoomType.UnstableCall
*/
isCallRoom(): boolean;
/**
* Returns whether the room is a video room.
* @returns true if the room's type is RoomType.ElementVideo
*/
isElementVideoRoom(): boolean;
/**
* Find the predecessor of this room.
*
* @param msc3946ProcessDynamicPredecessor - if true, look for an
* m.room.predecessor state event and use it if found (MSC3946).
* @returns null if this room has no predecessor. Otherwise, returns
* the roomId, last eventId and viaServers of the predecessor room.
*
* If msc3946ProcessDynamicPredecessor is true, use m.predecessor events
* as well as m.room.create events to find predecessors.
*
* Note: if an m.predecessor event is used, eventId may be undefined
* since last_known_event_id is optional.
*
* Note: viaServers may be undefined, and will definitely be undefined if
* this predecessor comes from a RoomCreate event (rather than a
* RoomPredecessor, which has the optional via_servers property).
*/
findPredecessor(msc3946ProcessDynamicPredecessor?: boolean): {
roomId: string;
eventId?: string;
viaServers?: string[];
} | null;
private roomNameGenerator;
/**
* This is an internal method. Calculates the name of the room from the current
* room state.
* @param userId - The client's user ID. Used to filter room members
* correctly.
* @param ignoreRoomNameEvent - Return the implicit room name that we'd see if there
* was no m.room.name event.
* @returns The calculated room name.
*/
private calculateRoomName;
/**
* When we receive a new visibility change event:
*
* - store this visibility change alongside the timeline, in case we
* later need to apply it to an event that we haven't received yet;
* - if we have already received the event whose visibility has changed,
* patch it to reflect the visibility change and inform listeners.
*/
private applyNewVisibilityEvent;
private redactVisibilityChangeEvent;
/**
* When we receive an event whose visibility has been altered by
* a (more recent) visibility change event, patch the event in
* place so that clients now not to display it.
*
* @param event - Any matrix event. If this event has at least one a
* pending visibility change event, apply the latest visibility
* change event.
*/
private applyPendingVisibilityEvents;
/**
* Find when a client has gained thread capabilities by inspecting the oldest
* threaded receipt
* @returns the timestamp of the oldest threaded receipt
*/
getOldestThreadedReceiptTs(): number;
/**
* Returns the most recent unthreaded receipt for a given user
* @param userId - the MxID of the User
* @returns an unthreaded Receipt. Can be undefined if receipts have been disabled
* or a user chooses to use private read receipts (or we have simply not received
* a receipt from this user yet).
*/
getLastUnthreadedReceiptFor(userId: string): Receipt | undefined;
/**
* This issue should also be addressed on synapse's side and is tracked as part
* of https://github.com/matrix-org/synapse/issues/14837
*
*
* We consider a room fully read if the current user has sent
* the last event in the live timeline of that context and if the read receipt
* we have on record matches.
* This also detects all unread threads and applies the same logic to those
* contexts
*/
fixupNotifications(userId: string): void;
}
export declare enum RoomNameType {
EmptyRoom = 0,
Generated = 1,
Actual = 2
}
export interface EmptyRoomNameState {
type: RoomNameType.EmptyRoom;
oldName?: string;
}
export interface GeneratedRoomNameState {
type: RoomNameType.Generated;
subtype?: "Inviting";
names: string[];
count: number;
}
export interface ActualRoomNameState {
type: RoomNameType.Actual;
name: string;
}
export type RoomNameState = EmptyRoomNameState | GeneratedRoomNameState | ActualRoomNameState;
export {};
//# sourceMappingURL=room.d.ts.map