Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quellcode-Bibliothek auto-join.ts

  Sprache: JAVA
 

import { normalizeStringifiedOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
import { getMatrixRuntime } from "../../runtime.js";
import type { MatrixConfig } from "../../types.js";
import type { MatrixClient } from "../sdk.js";
import type { RuntimeEnv } from "./runtime-api.js";

export function registerMatrixAutoJoin(params: {
  client: MatrixClient;
  accountConfig: Pick<MatrixConfig, "autoJoin" | "autoJoinAllowlist">;
  runtime: RuntimeEnv;
}) {
  const { client, accountConfig, runtime } = params;
  const core = getMatrixRuntime();
  const logVerbose = (message: string) => {
    if (!core.logging.shouldLogVerbose()) {
      return;
    }
    runtime.log?.(message);
  };
  const autoJoin = accountConfig.autoJoin ?? "off";
  const rawAllowlist = (accountConfig.autoJoinAllowlist ?? [])
    .map((entry) => normalizeStringifiedOptionalString(entry))
    .filter((entry): entry is string => Boolean(entry));
  const autoJoinAllowlist = new Set(rawAllowlist);
  const allowedRoomIds = new Set(rawAllowlist.filter((entry) => entry.startsWith("!")));
  const allowedAliases = rawAllowlist.filter((entry) => entry.startsWith("#"));
  const resolvedAliasRoomIds = new Map<string, string>();

  if (autoJoin === "off") {
    return;
  }

  if (autoJoin === "always") {
    logVerbose("matrix: auto-join enabled for all invites");
  } else {
    logVerbose("matrix: auto-join enabled for allowlist invites");
  }

  const resolveAllowedAliasRoomId = async (alias: string): Promise<string | null> => {
    if (resolvedAliasRoomIds.has(alias)) {
      return resolvedAliasRoomIds.get(alias) ?? null;
    }
    const resolved = await params.client.resolveRoom(alias);
    if (resolved) {
      resolvedAliasRoomIds.set(alias, resolved);
    }
    return resolved;
  };

  const resolveAllowedAliasRoomIds = async (): Promise<string[]> => {
    const resolved = await Promise.all(
      allowedAliases.map(async (alias) => {
        try {
          return await resolveAllowedAliasRoomId(alias);
        } catch (err) {
          runtime.error?.(`matrix: failed resolving allowlisted alias ${alias}: ${String(err)}`);
          return null;
        }
      }),
    );
    return resolved.filter((roomId): roomId is string => Boolean(roomId));
  };

  // Handle invites directly so both "always" and "allowlist" modes share the same path.
  client.on("room.invite", async (roomId: string, _inviteEvent: unknown) => {
    if (autoJoin === "allowlist") {
      const allowedAliasRoomIds = await resolveAllowedAliasRoomIds();
      const allowed =
        autoJoinAllowlist.has("*") ||
        allowedRoomIds.has(roomId) ||
        allowedAliasRoomIds.some((resolvedRoomId) => resolvedRoomId === roomId);

      if (!allowed) {
        logVerbose(`matrix: invite ignored (not in allowlist) room=${roomId}`);
        return;
      }
    }

    try {
      await client.joinRoom(roomId);
      logVerbose(`matrix: joined room ${roomId}`);
    } catch (err) {
      runtime.error?.(`matrix: failed to join room ${roomId}: ${String(err)}`);
    }
  });
}

Messung V0.5 in Prozent
C=93 H=91 G=91

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:  (vorverarbeitet am  2026-06-06) ¤

*Bot Zugriff






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002