Add filter by controller uid in macro execute

This commit is contained in:
Tobias Reisinger 2024-05-02 21:24:31 +02:00
parent 02c613e0fd
commit 8616c70f21
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE

View file

@ -1,13 +1,14 @@
use actix::Addr;
use actix_web::{delete, get, post, put, web, HttpResponse};
use actix_web::{delete, get, HttpResponse, post, put, web};
use itertools::Itertools;
use sqlx::{Pool, Sqlite};
use emgauwa_common::db::DbMacro;
use emgauwa_common::errors::{DatabaseError, EmgauwaError};
use emgauwa_common::models::{convert_db_list, FromDbModel, Macro, MacroAction, Relay};
use emgauwa_common::types::{
ControllerWsAction, EmgauwaUid, RequestMacroCreate, RequestMacroExecute, RequestMacroUpdate,
};
use itertools::Itertools;
use sqlx::{Pool, Sqlite};
use crate::app_state;
use crate::app_state::AppState;
@ -141,7 +142,9 @@ pub async fn execute(
let mut affected_relay_ids: Vec<i64> = Vec::new();
for action in actions.iter_mut() {
if affected_relay_ids.contains(&action.relay.r.id) {
if affected_relay_ids.contains(&action.relay.r.id)
|| action.relay.controller_id != controller_uid
{
continue;
}
action.relay.reload(&mut pool_conn)?;