Ejemplo n.º 1
0
 public function registerAssets()
 {
     $model = new PoprigunChatMessage();
     $model->receiverId = Chat::decodeUserId($this->options['receiver_id']);
     $model->messageType = PoprigunChatMessage::MESSAGE_TO_USER;
     echo $this->renderFile($this->template, ['model' => $model, 'options' => $this->options]);
 }
Ejemplo n.º 2
0
 /**
  * Validate receiver
  *
  * @param $attribute
  * @param $params
  */
 public function valdateReceiver($attribute, $params)
 {
     if ($this->messageType == self::MESSAGE_TO_USER) {
         $this->receiverId = Chat::decodeUserId($this->receiverId);
     } elseif ($this->messageType == self::MESSAGE_TO_DIALOG) {
         $this->receiverId = Chat::decodeDialogId($this->receiverId);
     } else {
         $this->addError($attribute, 'Incorrect receiver');
     }
 }
Ejemplo n.º 3
0
 /**
  * Delete message (change status)
  *
  * @param $messageId
  * @return array
  */
 public function actionDeleteMessage($messageId)
 {
     return ['status' => PoprigunChatUserRel::deleteMessage(Chat::decodeUserId($messageId)) ? 'success' : 'error'];
 }