Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/JAVA/Openclaw/extensions/matrix/src/matrix/actions/   (Openclaw AI Version 22©)  Datei vom 26.3.2026 mit Größe 1 kB image not shown  

Quelle  reactions.ts

  Sprache: JAVA
 

import {
  buildMatrixReactionRelationsPath,
  selectOwnMatrixReactionEventIds,
  summarizeMatrixReactionEvents,
} from "../reaction-common.js";
import { withResolvedRoomAction } from "./client.js";
import { resolveMatrixActionLimit } from "./limits.js";
import {
  type MatrixActionClientOpts,
  type MatrixRawEvent,
  type MatrixReactionSummary,
} from "./types.js";

type ActionClient = NonNullable<MatrixActionClientOpts["client"]>;

async function listMatrixReactionEvents(
  client: ActionClient,
  roomId: string,
  messageId: string,
  limit: number,
): Promise<MatrixRawEvent[]> {
  const res = (await client.doRequest("GET", buildMatrixReactionRelationsPath(roomId, messageId), {
    dir: "b",
    limit,
  })) as { chunk?: MatrixRawEvent[] };
  return Array.isArray(res.chunk) ? res.chunk : [];
}

export async function listMatrixReactions(
  roomId: string,
  messageId: string,
  opts: MatrixActionClientOpts & { limit?: number } = {},
): Promise<MatrixReactionSummary[]> {
  return await withResolvedRoomAction(roomId, opts, async (client, resolvedRoom) => {
    const limit = resolveMatrixActionLimit(opts.limit, 100);
    const chunk = await listMatrixReactionEvents(client, resolvedRoom, messageId, limit);
    return summarizeMatrixReactionEvents(chunk);
  });
}

export async function removeMatrixReactions(
  roomId: string,
  messageId: string,
  opts: MatrixActionClientOpts & { emoji?: string } = {},
): Promise<{ removed: number }> {
  return await withResolvedRoomAction(roomId, opts, async (client, resolvedRoom) => {
    const chunk = await listMatrixReactionEvents(client, resolvedRoom, messageId, 200);
    const userId = await client.getUserId();
    if (!userId) {
      return { removed: 0 };
    }
    const toRemove = selectOwnMatrixReactionEventIds(chunk, userId, opts.emoji);
    if (toRemove.length === 0) {
      return { removed: 0 };
    }
    await Promise.all(toRemove.map((id) => client.redactEvent(resolvedRoom, id)));
    return { removed: toRemove.length };
  });
}

Messung V0.5 in Prozent
C=100 H=100 G=100

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© Formatika GbR, Deutschland






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.