Skip to content

Commit f71a0ea

Browse files
author
akshay kumar
committed
Merge branch '1.0' of https://github.com/uvdesk/mailbox-component into HEAD
2 parents caf740f + 0d4d696 commit f71a0ea

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed

CHANGELOG-1.0.md

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ CHANGELOG for 1.0.x
33

44
This changelog references any relevant changes introduced in 1.0 minor versions.
55

6+
* 1.0.2 (2019-10-22)
7+
* **Misc. Updates:**
8+
* Use https when available while refreshing mailboxes via CLI
9+
* Updated README.md with link to the official gitter chat for uvdesk/mailbox-component
10+
611
* 1.0.1 (2019-10-15)
712
* **Misc. Updates:**
813
* Only users with admin level privileges can configure mailbox settings

Console/RefreshMailboxCommand.php

+20-6
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,16 @@ public function refreshMailbox($server_host, $server_username, $server_password,
9595

9696
if (is_array($emailCollection)) {
9797
$emailCount = count($emailCollection);
98+
$useSecureConnection = $this->isSecureConnectionAvailable();
99+
98100
$output->writeln("\n <comment>5. Total fetched email -> </comment><info>$emailCount</info><comment></comment>");
99101
$output->writeln("\n <comment>6. Starting to convert Emails into Tickets -> </comment>\n=============================================\n=============================================\n");
100102
$counter = 1;
101103

102104
foreach ($emailCollection as $id => $messageNumber) {
103105
$output->writeln("\n <comment> Converting email </comment><info>$counter</info><comment> out of </comment><info>$emailCount</info><comment>.</comment>");
104106
$message = imap_fetchbody($imap, $messageNumber, "");
105-
$this->pushMessage($message);
107+
$this->pushMessage($message, $useSecureConnection);
106108
$counter ++;
107109
}
108110

@@ -113,24 +115,36 @@ public function refreshMailbox($server_host, $server_username, $server_password,
113115
return;
114116
}
115117

116-
public function pushMessage($message)
118+
public function pushMessage($message, bool $secure = false)
117119
{
118120
$router = $this->container->get('router');
119121
$router->getContext()->setHost($this->container->getParameter('uvdesk.site_url'));
122+
$router->getContext()->setScheme(true === $secure ? 'https' : 'http');
120123

121124
$curlHandler = curl_init();
122125
$requestUrl = $router->generate('helpdesk_member_mailbox_notification', [], UrlGeneratorInterface::ABSOLUTE_URL);
123126

124-
if ($this->container->getParameter('uvdesk.site_url') != $router->getContext()->getHost()) {
125-
$requestUrl = str_replace($router->getContext()->getHost(), $this->container->getParameter('uvdesk.site_url'), $requestUrl);
126-
}
127-
128127
curl_setopt($curlHandler, CURLOPT_HEADER, 0);
129128
curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, 1);
130129
curl_setopt($curlHandler, CURLOPT_POST, 1);
131130
curl_setopt($curlHandler, CURLOPT_URL, $requestUrl);
132131
curl_setopt($curlHandler, CURLOPT_POSTFIELDS, http_build_query(['email' => $message]));
132+
133133
$curlResponse = curl_exec($curlHandler);
134134
curl_close($curlHandler);
135135
}
136+
137+
protected function isSecureConnectionAvailable()
138+
{
139+
$headers = [CURLOPT_NOBODY => true, CURLOPT_HEADER => false];
140+
$curlHandler = curl_init('https://' . $this->container->getParameter('uvdesk.site_url'));
141+
142+
curl_setopt_array($curlHandler, $headers);
143+
curl_exec($curlHandler);
144+
145+
$isSecureRequestAvailable = curl_errno($curlHandler) === 0 ? true : false;
146+
curl_close($curlHandler);
147+
148+
return $isSecureRequestAvailable;
149+
}
136150
}

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,34 @@
11
# mailbox
22
The Mailbox component provides tools that allows your helpdesk to process tickets from multiple email sources.
3+
4+
<p align="center"><a href="https://www.uvdesk.com/en/" target="_blank">
5+
<img src="https://s3-ap-southeast-1.amazonaws.com/cdn.uvdesk.com/uvdesk/bundles/webkuldefault/images/uvdesk-wide.svg">
6+
</a></p>
7+
8+
<p align="center">
9+
<a href="https://packagist.org/packages/uvdesk/mailbox-component"><img src="https://poser.pugx.org/uvdesk/mailbox-component/v/stable.svg" alt="Latest Stable Version"></a>
10+
<a href="https://packagist.org/packages/uvdesk/mailbox-component"><img src="https://poser.pugx.org/uvdesk/mailbox-component/d/total.svg" alt="Total Downloads"></a>
11+
<a href="https://packagist.org/packages/uvdesk/mailbox-component"><img src="https://poser.pugx.org/uvdesk/mailbox-component/license.svg" alt="License"></a>
12+
<a href="https://gitter.im/uvdesk/mailbox-component"><img src="https://badges.gitter.im/uvdesk/mailbox-component.svg" alt="connect on gitter"></a>
13+
</p>
14+
15+
The **Mailbox** component enables your [UVDesk Community][1] helpdesk to fetch emails from multiple sources and process them into tickets effortlessly.
16+
17+
Installation
18+
--------------
19+
20+
Before installing, make sure that you have [Composer][2] installed.
21+
22+
To require mailbox-component into your helpdesk project, simply run the following composer command from your project root:
23+
24+
```bash
25+
$ composer require uvdesk/mailbox-component
26+
```
27+
28+
License
29+
--------------
30+
31+
The **Mailbox** component and libraries included within the bundle are released under the MIT or BSD license.
32+
33+
[1]: https://www.uvdesk.com/
34+
[2]: https://getcomposer.org/

0 commit comments

Comments
 (0)