small plugin changes + make minesweeper and snake plugin
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
export type PluginRpcCaller = {
|
||||
id: number;
|
||||
username: string;
|
||||
role: string;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ declare const self: {
|
||||
type PluginExports = {
|
||||
setup?: (ctx: PluginContext) => unknown | Promise<unknown>;
|
||||
onEvent?: (ctx: PluginContext, clientId: string, event: string, payload: unknown) => unknown | Promise<unknown>;
|
||||
rpc?: Record<string, (ctx: PluginContext, params: unknown, meta: { caller: { id: number; role: string } }) => unknown | Promise<unknown>>;
|
||||
rpc?: Record<string, (ctx: PluginContext, params: unknown, meta: { caller: { id: number; username: string; role: string } }) => unknown | Promise<unknown>>;
|
||||
buildHooks?: Record<string, (ctx: PluginContext, payload: unknown) => unknown | Promise<unknown>>;
|
||||
onBuildPrepare?: (ctx: PluginContext, payload: unknown) => unknown | Promise<unknown>;
|
||||
onBuildTarget?: (ctx: PluginContext, payload: unknown) => unknown | Promise<unknown>;
|
||||
|
||||
@@ -278,7 +278,7 @@ export async function handlePluginRoutes(
|
||||
plugin.id,
|
||||
"dashboardContributions",
|
||||
{ clientIds: authorizedClientIds },
|
||||
{ id: user.userId, role: user.role },
|
||||
{ id: user.userId, username: user.username, role: user.role },
|
||||
);
|
||||
const rows = Array.isArray(result?.contributions) ? result.contributions : Array.isArray(result) ? result : [];
|
||||
for (const row of rows) {
|
||||
@@ -1293,6 +1293,7 @@ export async function handlePluginRoutes(
|
||||
try {
|
||||
const result = await deps.pluginRuntime.rpc(pluginId, method, body.params, {
|
||||
id: user.userId,
|
||||
username: user.username,
|
||||
role: user.role,
|
||||
});
|
||||
metrics.recordCommand("plugin_rpc");
|
||||
|
||||
Reference in New Issue
Block a user