MCPcopy Create free account
hub / github.com/Botloader/botloader / update_plugin_dev_source

Function update_plugin_dev_source

components/webapi/src/routes/plugins.rs:232–256  ·  view source on GitHub ↗

update plugin dev source

(
    State(state): State<AppState>,
    Extension(session): Extension<LoggedInSession>,
    Extension(plugin): Extension<Plugin>,
    Json(body): Json<UpdatePluginDevSourceRequest>,
)

Source from the content-addressed store, hash-verified

230
231// update plugin dev source
232pub async fn update_plugin_dev_source(
233 State(state): State<AppState>,
234 Extension(session): Extension<LoggedInSession>,
235 Extension(plugin): Extension<Plugin>,
236 Json(body): Json<UpdatePluginDevSourceRequest>,
237) -> ApiResult<impl IntoResponse> {
238 if let Err(err) = validate(&body, &()) {
239 return Err(ApiErrorResponse::ValidationFailed(err));
240 }
241
242 if plugin.author_id != session.session.user.id {
243 return Err(ApiErrorResponse::NoAccessToPlugin);
244 }
245
246 let plugin = state
247 .db
248 .update_script_plugin_dev_version(plugin.id, body.new_source)
249 .await
250 .map_err(|err| {
251 error!(?err, "failed updating plugin");
252 ApiErrorResponse::InternalError
253 })?;
254
255 Ok(Json(plugin))
256}
257
258// publish plugin version
259#[derive(Deserialize)]

Callers

nothing calls this directly

Calls 2

validateFunction · 0.85

Tested by

no test coverage detected