mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 03:47:26 +00:00
30 lines
987 B
TypeScript
30 lines
987 B
TypeScript
import { getMatrixRuntime } from "../../runtime.js";
|
|
import { syncMatrixOwnProfile, type MatrixProfileSyncResult } from "../profile.js";
|
|
import { withResolvedActionClient } from "./client.js";
|
|
import type { MatrixActionClientOpts } from "./types.js";
|
|
|
|
export async function updateMatrixOwnProfile(
|
|
opts: MatrixActionClientOpts & {
|
|
displayName?: string;
|
|
avatarUrl?: string;
|
|
} = {},
|
|
): Promise<MatrixProfileSyncResult> {
|
|
const displayName = opts.displayName?.trim();
|
|
const avatarUrl = opts.avatarUrl?.trim();
|
|
const runtime = getMatrixRuntime();
|
|
return await withResolvedActionClient(
|
|
opts,
|
|
async (client) => {
|
|
const userId = await client.getUserId();
|
|
return await syncMatrixOwnProfile({
|
|
client,
|
|
userId,
|
|
displayName: displayName || undefined,
|
|
avatarUrl: avatarUrl || undefined,
|
|
loadAvatarFromUrl: async (url, maxBytes) => await runtime.media.loadWebMedia(url, maxBytes),
|
|
});
|
|
},
|
|
"persist",
|
|
);
|
|
}
|