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

Function update_plugin_meta

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

update plugin meta

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

Source from the content-addressed store, hash-verified

180
181// update plugin meta
182pub async fn update_plugin_meta(
183 State(state): State<AppState>,
184 Extension(session): Extension<LoggedInSession>,
185 Extension(plugin): Extension<Plugin>,
186 Json(body): Json<UpdatePluginMetaRequest>,
187) -> ApiResult<impl IntoResponse> {
188 let update = UpdatePluginMeta {
189 name: body.name,
190 short_description: body.short_description,
191 long_description: body.long_description,
192 is_public: body.is_public,
193 is_official: None,
194 author_id: None,
195 is_published: body.is_published,
196 discord_thread_id: None,
197 };
198
199 if let Err(err) = validate(&update, &()) {
200 return Err(ApiErrorResponse::ValidationFailed(err));
201 }
202
203 if plugin.author_id != session.session.user.id {
204 return Err(ApiErrorResponse::NoAccessToPlugin);
205 }
206
207 let plugin = state
208 .db
209 .update_plugin_meta(plugin.id, update)
210 .await
211 .map_err(|err| {
212 error!(?err, "failed updating plugin");
213 ApiErrorResponse::InternalError
214 })?;
215
216 Ok(Json(plugin))
217}
218
219#[derive(Deserialize)]
220pub struct UpdatePluginDevSourceRequest {

Callers

nothing calls this directly

Calls 2

validateFunction · 0.85
update_plugin_metaMethod · 0.80

Tested by

no test coverage detected