From d332555c0ebb5ba6c1ffa6c018466d410b7e4f6b Mon Sep 17 00:00:00 2001 From: Cay Henning Date: Tue, 28 Nov 2023 11:16:20 -0500 Subject: [PATCH] Remove unused Msg constructor and update response types --- fuel/app/classes/controller/api/user.php | 8 ++++---- fuel/app/classes/materia/msg.php | 6 ------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/fuel/app/classes/controller/api/user.php b/fuel/app/classes/controller/api/user.php index 0f5344008..467d2082a 100644 --- a/fuel/app/classes/controller/api/user.php +++ b/fuel/app/classes/controller/api/user.php @@ -20,7 +20,7 @@ public function get_activity() public function post_settings() { - if (\Service_User::verify_session() !== true) return $this->response('Not logged in', 401); + if (\Service_User::verify_session() !== true) return $this->response(\Materia\Msg::no_login(), 401); $success = false; $set_meta = [ @@ -42,9 +42,9 @@ public function post_settings() public function post_roles() { - if (\Service_User::verify_session() !== true) return $this->response('Not logged in', 401); + if (\Service_User::verify_session() !== true) return $this->response(\Materia\Msg::no_login(), 401); // this endpoint is only available to superusers! - if ( ! \Materia\Perm_Manager::is_super_user()) return $this->response('Not authorized', 403); + if ( ! \Materia\Perm_Manager::is_super_user()) return $this->response(\Materia\Msg::no_perm(), 403); $success = false; $user_id = Input::json('id', null); @@ -53,7 +53,7 @@ public function post_roles() 'support_user' => Input::json('support_user', false) ]; - if ( ! $user_id) return $this->response('User ID not provided', 401); + if ( ! $user_id) return $this->response(\Materia\Msg::invalid_input('User ID not provided'), 401); $current_roles = \Materia\Perm_Manager::get_user_roles($user_id); $current_roles_condensed = array_map( fn($r) => $r->name, $current_roles); diff --git a/fuel/app/classes/materia/msg.php b/fuel/app/classes/materia/msg.php index 2b510d676..229b7014a 100644 --- a/fuel/app/classes/materia/msg.php +++ b/fuel/app/classes/materia/msg.php @@ -69,12 +69,6 @@ static public function student_collab() return $msg; } - static public function student() - { - $msg = new Msg('Students are unable to receive notifications via Materia', 'No Notifications', Msg::NOTICE, false, 403); - return $msg; - } - static public function failure($msg = 'The requested action could not be completed', $title = 'Action Failed') { $msg = new Msg($msg, $title, Msg::ERROR, false, 403);