From e520b7b9d3b32039b42db84aa85b034287d74394 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Thu, 14 Apr 2022 14:09:39 +0100
Subject: [PATCH] Bug 30536: Use objects->find in SMTP Servers controller

This patch removes the direct reference to the koha.embed
stashed variable in the SMTP controller and switches us
to the modern objects->find approach.
---
 Koha/REST/V1/Config/SMTP/Servers.pm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Koha/REST/V1/Config/SMTP/Servers.pm b/Koha/REST/V1/Config/SMTP/Servers.pm
index 5949c535f4..869ea60204 100644
--- a/Koha/REST/V1/Config/SMTP/Servers.pm
+++ b/Koha/REST/V1/Config/SMTP/Servers.pm
@@ -59,7 +59,9 @@ sub get {
     my $c = shift->openapi->valid_input or return;
 
     return try {
-        my $smtp_server = Koha::SMTP::Servers->find( $c->validation->param('smtp_server_id') );
+        my $smtp_server_id = $c->validation->param('smtp_server_id');
+        my $smtp_server =
+          $c->objects->find( Koha::SMTP::Servers->new, $smpt_server_id );
 
         unless ($smtp_server) {
             return $c->render(
@@ -70,11 +72,9 @@ sub get {
             );
         }
 
-        my $embed = $c->stash('koha.embed');
-
         return $c->render(
             status  => 200,
-            openapi => $smtp_server->to_api({ embed => $embed })
+            openapi => $smtp_server
         );
     }
     catch {
-- 
2.20.1