diff --git a/application/config/message.php b/application/config/message.php index 4987ed519..af5861c55 100644 --- a/application/config/message.php +++ b/application/config/message.php @@ -4,6 +4,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); $config['msg_delivery'] = true; $config['send_immediately'] = false; // If the message should be sent immediately +$config['system_person_id'] = 1; // Dummy sender, used for sending messages from the system define('EMAIL_KONTAKT_TYPE', 'email'); // Email kontakt type define('SENT_INFO_NEWLINE', '\n'); // tbl_msg_recipient->sentInfo separator diff --git a/application/controllers/api/v1/system/Message.php b/application/controllers/api/v1/system/Message.php index 9e8af424e..585b7ba2b 100644 --- a/application/controllers/api/v1/system/Message.php +++ b/application/controllers/api/v1/system/Message.php @@ -132,7 +132,7 @@ class Message extends APIv1_Controller if (is_object($validation) && $validation->error == EXIT_SUCCESS) { $result = $this->messagelib->sendMessage( - $this->post()['person_id'], + isset($this->post()['person_id']) ? $this->post()['person_id'] : null, isset($this->post()['receiver_id']) ? $this->post()['receiver_id'] : null, $this->post()['subject'], $this->post()['body'], @@ -204,10 +204,6 @@ class Message extends APIv1_Controller { return $this->_error('Parameter is null'); } - if (!isset($message['person_id'])) - { - return $this->_error('person_id is not set'); - } if (!isset($message['subject'])) { return $this->_error('subject is not set'); diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 7e89f2a7f..2739e1953 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -199,7 +199,9 @@ class MessageLib public function sendMessage($sender_id, $receiver_id, $subject, $body, $priority = PRIORITY_NORMAL, $relationmessage_id = null, $oe_kurzbz = null) { if (!is_numeric($sender_id)) - return $this->_error('', MSG_ERR_INVALID_SENDER_ID); + { + $sender_id = $this->ci->config->item('system_person_id'); + } $receivers = null;