(
State(state): State<AppState>,
Extension(current_guild): Extension<CurrentUserGuild>,
Path(GuildScriptPathParams { script_id }): Path<GuildScriptPathParams>,
Json(payload): Json<Upda
| 202 | } |
| 203 | |
| 204 | pub async fn validate_script_settings( |
| 205 | State(state): State<AppState>, |
| 206 | Extension(current_guild): Extension<CurrentUserGuild>, |
| 207 | Path(GuildScriptPathParams { script_id }): Path<GuildScriptPathParams>, |
| 208 | Json(payload): Json<UpdateRequestData>, |
| 209 | ) -> ApiResult<impl IntoResponse> { |
| 210 | let current_script = state |
| 211 | .db |
| 212 | .get_script_by_id(current_guild.id, script_id) |
| 213 | .await |
| 214 | .map_err(|err| { |
| 215 | if err.is_not_found() { |
| 216 | ApiErrorResponse::ScriptNotFound |
| 217 | } else { |
| 218 | error!(%err, "failed fetching script"); |
| 219 | ApiErrorResponse::InternalError |
| 220 | } |
| 221 | })?; |
| 222 | |
| 223 | let sc = UpdateScript { |
| 224 | id: script_id, |
| 225 | enabled: payload.enabled, |
| 226 | original_source: payload.original_source, |
| 227 | name: payload.name, |
| 228 | plugin_version_number: None, |
| 229 | settings_values: payload.settings_values, |
| 230 | }; |
| 231 | |
| 232 | let validation_data = ScriptValidationContextData { |
| 233 | script: current_script, |
| 234 | guild_data: None, |
| 235 | }; |
| 236 | |
| 237 | if let Err(validation_errors) = validate(&sc, &validation_data) { |
| 238 | return Err(ApiErrorResponse::ValidationFailed(validation_errors)); |
| 239 | } |
| 240 | |
| 241 | Ok(EmptyResponse) |
| 242 | } |
| 243 | |
| 244 | pub async fn delete_guild_script( |
| 245 | State(state): State<AppState>, |
nothing calls this directly
no test coverage detected