feat: complete Ancestor quote bot with production-ready Docker support

This commit is contained in:
unfunny
2026-09-13 14:14:38 -04:00
parent f2016da05a
commit fe7351a7dc
1145 changed files with 30890 additions and 97684 deletions

View File

@@ -1,12 +1,13 @@
import { type MatrixClient, PendingEventOrdering } from "../client.ts";
import { MatrixEvent } from "./event.ts";
import { EventTimeline } from "./event-timeline.ts";
import { EventTimelineSet, type EventTimelineSetHandlerMap } from "./event-timeline-set.ts";
import { type NotificationCountType, type Room, RoomEvent } from "./room.ts";
import { type RoomState } from "./room-state.ts";
import { ServerControlledNamespacedValue } from "../NamespacedValue.ts";
import { ReadReceipt } from "./read-receipt.ts";
import { type CachedReceiptStructure, type Receipt } from "../@types/read_receipts.ts";
import { Optional } from "matrix-events-sdk";
import { MatrixClient, PendingEventOrdering } from "../client";
import { MatrixEvent } from "./event";
import { EventTimeline } from "./event-timeline";
import { EventTimelineSet, EventTimelineSetHandlerMap } from "./event-timeline-set";
import { NotificationCountType, Room, RoomEvent } from "./room";
import { RoomState } from "./room-state";
import { ServerControlledNamespacedValue } from "../NamespacedValue";
import { ReadReceipt } from "./read-receipt";
import { CachedReceiptStructure, Receipt } from "../@types/read_receipts";
export declare enum ThreadEvent {
New = "Thread.new",
Update = "Thread.update",
@@ -21,6 +22,10 @@ export type ThreadEventHandlerMap = {
[ThreadEvent.ViewThread]: () => void;
[ThreadEvent.Delete]: (thread: Thread) => void;
} & EventTimelineSetHandlerMap;
/**
* @deprecated please use ThreadEventHandlerMap instead
*/
export type EventHandlerMap = ThreadEventHandlerMap;
interface IThreadOpts {
room: Room;
client: MatrixClient;
@@ -43,40 +48,9 @@ export declare class Thread extends ReadReceipt<ThreadEmittedEvents, ThreadEvent
* A reference to all the events ID at the bottom of the threads
*/
readonly timelineSet: EventTimelineSet;
timeline: MatrixEvent[];
private _currentUserParticipated;
private reEmitter;
/**
* The last event in this thread, if we don't yet have this in the timeline.
*
* When we run {@link processRootEvent} (which I think happens during the
* setting-up of the thread), we set this to the event pointed to by the
* server in `latest_event` [1] that came through with the thread root.
*
* [1]: https://spec.matrix.org/v1.8/client-server-api/#server-side-aggregation-of-mthread-relationships
*
* Later, when we have populated the timeline, this is set to undefined, so
* that methods like {@link replyToEvent} fall through to use lastReply,
* which looks in the timeline for the latest event that is a "thread reply"
* i.e. directly refers to the thread root with an m.thread relation.
*
* So it looks like this is only really relevant when initialEventsFetched
* is false, because as soon as the initial events have been fetched, we
* should have a proper chunk of timeline from the pagination fetch.
*
* If all replies in this thread are redacted, this is set to the root
* event. I'm not clear what the meaning of this is, since usually after the
* initial events have been fetched, lastEvent should be undefined.
* In fact, the whole usage inside onRedaction looks suspect - it may be
* that we were thinking lastEvent always refers to the actual last event,
* but it only does so before initialEventsFetched becomes true.
*
* The usage of lastEvent inside {@link onEcho} looks suspicious, since I'd
* think we probably mean {@link replyToEvent} there - we are trying not to
* echo a duplicate event, and we probably want that behaviour even after
* initialEventsFetched has become true.
*
* -- andyb
*/
private lastEvent;
private replyCount;
private lastPendingEvent;
@@ -85,15 +59,7 @@ export declare class Thread extends ReadReceipt<ThreadEmittedEvents, ThreadEvent
readonly client: MatrixClient;
private readonly pendingEventOrdering;
private processRootEventPromise?;
/**
* Whether or not we need to fetch the initial set of events for the thread. We can
* only do this if the server has support for it, so if it doesn't we just pretend
* that we've already fetched them.
*/
initialEventsFetched: boolean;
private initalEventFetchProm;
private preInitEventTargets;
private preInitObserverState;
/**
* An array of events to add to the timeline once the thread has been initialised
* with server suppport.
@@ -137,10 +103,8 @@ export declare class Thread extends ReadReceipt<ThreadEmittedEvents, ThreadEvent
* to the start (and not the end) of the timeline.
* @param emit - whether to emit the Update event if the thread was updated or not.
*/
addEvent(event: MatrixEvent, toStartOfTimeline: boolean, emit?: boolean): void;
private addRelatedThreadEvent;
private findPreInitTargetEvent;
processEvent(event: MatrixEvent | null | undefined): Promise<void>;
addEvent(event: MatrixEvent, toStartOfTimeline: boolean, emit?: boolean): Promise<void>;
processEvent(event: Optional<MatrixEvent>): Promise<void>;
/**
* Processes the receipts that were caught during initial sync
* When clients become aware of a thread, they try to retrieve those read receipts
@@ -169,8 +133,8 @@ export declare class Thread extends ReadReceipt<ThreadEmittedEvents, ThreadEvent
private updateThreadFromRootEvent;
private updateThreadMetadata;
private fetchEditsWhereNeeded;
setEventMetadata(event: MatrixEvent | null | undefined): void;
clearEventMetadata(event: MatrixEvent | null | undefined): void;
setEventMetadata(event: Optional<MatrixEvent>): void;
clearEventMetadata(event: Optional<MatrixEvent>): void;
/**
* Finds an event by ID in the current thread
*/
@@ -190,14 +154,7 @@ export declare class Thread extends ReadReceipt<ThreadEmittedEvents, ThreadEvent
* A getter for the last event of the thread.
* This might be a synthesized event, if so, it will not emit any events to listeners.
*/
get replyToEvent(): MatrixEvent | null;
/**
* The live event timeline for this thread.
* @deprecated Present for backwards compatibility.
* Use this.events instead
* @returns The live event timeline for this thread.
*/
get timeline(): MatrixEvent[];
get replyToEvent(): Optional<MatrixEvent>;
get events(): MatrixEvent[];
has(eventId: string): boolean;
get hasCurrentUserParticipated(): boolean;
@@ -240,8 +197,8 @@ export declare const FILTER_RELATED_BY_SENDERS: ServerControlledNamespacedValue<
export declare const FILTER_RELATED_BY_REL_TYPES: ServerControlledNamespacedValue<"related_by_rel_types", "io.element.relation_types">;
export declare const THREAD_RELATION_TYPE: ServerControlledNamespacedValue<"m.thread", "io.element.thread">;
export declare enum ThreadFilterType {
My = 0,
All = 1
"My" = 0,
"All" = 1
}
export declare function threadFilterTypeToFilter(type: ThreadFilterType | null): "all" | "participated";
export {};