Removes a message from the channels pinboard.

@param Message $message The message to un-pin.

@return \React\Promise\Promise
764025
public function unpinMessage(Message $message)
    {
        $deferred = new Deferred();

        if (! $message->pinned) {
            return \React\Promise\reject(new \Exception('This message is not pinned.'));
        }

        if ($message->channel_id != $this->id) {
            return \React\Promise\reject(new \Exception('You cannot un-pin a message from a different channel.'));
        }

        $this->http->delete("channels/{$this->id}/pins/{$message->id}")->then(
            function () use (&$message, $deferred) {
                $message->pinned = false;
                $deferred->resolve($message);
            },
            \React\Partial\bind_right($this->reject, $deferred)
        );

        return $deferred->promise();
    }
934113
public function destroy(MessageRequest $request, Message $message)
    {
        try {

            if (!empty($request->get('arrayIds'))) {
                $ids = $request->get('arrayIds');
                $t   = $this->repository->deleteMultiple($ids);
                return $t;
            } else {
                $t = $message->delete();
            }

            $this->repository->pushCriteria(new \Litepie\Message\Repositories\Criteria\MessageAdminCriteria());
            $inbox_count = $this->repository->msgCount('Inbox');
            $trash_count = $this->repository->msgCount('Trash');

            return response()->json([
                'message'     => trans('messages.success.deleted', ['Module' => trans('message::message.name')]),
                'code'        => 202,
                'redirect'    => trans_url('/admin/message/message/0'),
                'inbox_count' => $inbox_count,
                'trash_count' => $trash_count,
            ], 202);

        } catch (Exception $e) {

            return response()->json([
                'message'  => $e->getMessage(),
                'code'     => 400,
                'redirect' => trans_url('/admin/message/message/' . $message->getRouteKey()),
            ], 400);
        }

    }
857086
public static function removeHeader(array $message, $header)
    {
        if (isset($message['headers'])) {
            foreach (array_keys($message['headers']) as $key) {
                if (!strcasecmp($header, $key)) {
                    unset($message['headers'][$key]);
                }
            }
        }

        return $message;
    }
149170
public function push(QueueMessage $message)
    {
        $request = [
            'QueueUrl' => $this->getQueueUrl($message->getQueueName()),
            'MessageBody' => json_encode($message),
        ];

        $request['DelaySeconds'] = $message->getDelay();

        $options = $message->getOptions();

        $request = array_merge($request, $options);

        return $this->client->sendMessage($request)->get('MessageId');
    }
1360279
public function removeMessage(\Sopinet\ChatBundle\Entity\Message $message)
    {
        $this->messages->removeElement($message);
    }
100124
public function delete(QueueMessage $message)
    {
        $queue = $message->getQueueName() ?: $this->queue;

        $query = $this->db->getQuery(true);

        $query->delete($query->quoteName($this->table))
            ->where('id = :id')
            ->where('queue = :queue')
            ->bind('id', $message->getId())
            ->bind('queue', $queue);

        $this->db->setQuery($query)->execute();

        return $this;
    }
251268
public function skip($message = '')
    {
        if ($this->skipped !== true) {
            $this->skipped = true;
            $this->skipped_because = $message;
        }

        return $this;
    }
809404
public function queue(Message $message)
	{
		// Get the gateway for the certificate
		$gateway = $this->getGatewayForCertificate( $message->getCertificate() );

		// Queue the message
		return $gateway->queue($message);
	}
277945
public function sendMessage(Message $message): void
    {
        // Ensure the message will always be sent to the default channel if asked for.
        if ($this->options['sticky_channel']) {
            $message->setChannel($this->options['channel']);
        }

        $payload = $this->preparePayload($message);

        $encoded = \json_encode($payload, JSON_UNESCAPED_UNICODE);

        if (false === $encoded) {
            throw new \RuntimeException(\sprintf('JSON encoding error %s: %s', \json_last_error(), \json_last_error_msg()));
        }

        $this->httpClient->post('', [], $encoded);
    }
142747
public function deleteMessages($messages)
    {
        $deferred = new Deferred();

        if (! is_array($messages) &&
            ! ($messages instanceof Traversable)
        ) {
            $deferred->reject(new \Exception('$messages must be an array or implement Traversable.'));

            return $deferred->promise();
        }

        $count = count($messages);

        if ($count == 0) {
            $deferred->reject(new \Exception('You cannot delete 0 messages.'));

            return $deferred->promise();
        } elseif ($count == 1) {
            $deferred->reject(new \Exception('You cannot delete 1 message.'));

            return $deferred->promise();
        }

        $messageID = [];

        foreach ($messages as $message) {
            if ($message instanceof Message) {
                $messageID[] = $message->id;
            } else {
                $messageID[] = $message;
            }
        }

        $this->http->post(
            "channels/{$this->id}/messages/bulk_delete",
            [
                'messages' => $messageID,
            ]
        )->then(
            \React\Partial\bind_right($this->resolve, $deferred),
            \React\Partial\bind_right($this->reject, $deferred)
        );

        return $deferred->promise();
    }
907380
public function push(QueueMessage $message)
    {
        $queue = $message->getQueueName() ?: $this->queue;

        $options = $message->getOptions();

        $options['delay'] = $message->getDelay();

        return $this->client->postMessage($queue, json_encode($message), $options)->id;
    }
925505
public function delete(QueueMessage $message)
    {
        $queue = $message->getQueueName() ?: $this->queue;

        $this->client->deleteMessage($queue, $message->getId(), $message->get('reservation_id'));

        return $this;
    }
1361674
public function unique($message = null)
    {
        $this->addValidationRule('_unique');

        if (! is_null($message)) {
            $this->addValidationMessage('unique', $message);
        }

        return $this;
    }
734880
protected function inhibit(\CharlotteDunois\Livia\Commands\Context $message) {
        return (new \React\Promise\Promise(function (callable $resolve, callable $reject) use ($message) {
            $promises = array();
            
            foreach($this->inhibitors as $inhib) {
                $inhibited = $inhib($message);
                if(!($inhibited instanceof \React\Promise\PromiseInterface)) {
                    if($inhibited === false) {
                        $inhibited = \React\Promise\resolve($inhibited);
                    } else {
                        $inhibited = \React\Promise\reject($inhibited);
                    }
                }
                
                $promises[] = $inhibited;
            }
            
            \React\Promise\all($promises)->done(function ($values) use ($resolve, $reject) {
                foreach($values as $value) {
                    if($value !== false) {
                        return $reject($value);
                    }
                }
                
                $resolve();
            }, $reject);
        }));
    }
684439
public function message(string $message)
    {
        $this->_validations[\count($this->_validations) - 1]['message'] = $message;

        return $this;
    }
433381
protected function handleMessage($message)
    {
        if (!is_null($response = $this->call('message.*', array($message)))) {
            return $response;
        }

        return $this->call("message.{$message['MsgType']}", array($message));
    }
972919
public function pushHandler($message = null)
    {
        $this->handle();

        if (\is_callable($message)) {
            $this->response = \call_user_func($message, $this->message);
        }

        if (\is_string($message) and class_exists($message)) {
            $this->messageHandlers[] = $message;
        }

        return $this;
    }