diff --git a/src/entity/gateway/inmemory.rs b/src/entity/gateway/inmemory.rs index 07fd186..88636ec 100644 --- a/src/entity/gateway/inmemory.rs +++ b/src/entity/gateway/inmemory.rs @@ -72,6 +72,10 @@ impl EntityGateway for InMemoryGatewayTransaction { } } + async fn save_user_settings(&mut self, settings: &UserSettingsEntity) -> Result<(), GatewayError> { + self.original_gateway.save_user_settings(settings).await + } + async fn save_character(&mut self, char: &CharacterEntity) -> Result<(), GatewayError> { copy_if_needed(&mut *self.working_gateway.characters.lock().await, &*self.original_gateway.characters.lock().await, @@ -418,6 +422,12 @@ impl EntityGateway for InMemoryGateway { .ok_or(GatewayError::Error) } + async fn save_user_settings(&mut self, settings: &UserSettingsEntity) -> Result<(), GatewayError> { + let mut user_settings = self.user_settings.lock().await; + user_settings.insert(settings.id, settings.clone()); + Ok(()) + } + async fn get_characters_by_user(&mut self, user: &UserAccountEntity) -> Result<[Option; 4], GatewayError> { let characters = self.characters.lock().await; const NONE: Option = None; diff --git a/src/entity/gateway/postgres/postgres.rs b/src/entity/gateway/postgres/postgres.rs index 5ec3ffd..ba77827 100644 --- a/src/entity/gateway/postgres/postgres.rs +++ b/src/entity/gateway/postgres/postgres.rs @@ -217,7 +217,7 @@ async fn save_user_settings(conn: &mut sqlx::PgConnection, settings: &UserSettin .bind(&settings.settings.symbol_chats.to_vec()) .bind(settings.settings.team_name.iter().copied().flat_map(|i| i.to_le_bytes().to_vec()).collect::>()) .bind(settings.id.0) - .fetch_one(conn).await?; + .execute(conn).await?; Ok(()) } @@ -236,8 +236,7 @@ async fn create_character(conn: &mut sqlx::PgConnection, char: NewCharacterEntit $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, - $26, $27, $28, $29, $30, - $31, $32) + $26, $27, $28, $29, $30) returning *;"#; let character = sqlx::query_as::<_, PgCharacter>(q) .bind(char.user_id.0)