mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 00:17:03 +03:00
Changes for #180
This commit is contained in:
parent
9bfbd755c2
commit
0e2e44a269
2 changed files with 29 additions and 30 deletions
|
|
@ -132,19 +132,11 @@ export class AttachmentModel extends AbstractModel {
|
||||||
return serverRequestRaw('View', this.download);
|
return serverRequestRaw('View', this.download);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
linkThumbnail() {
|
|
||||||
return this.hasThumbnail() ? serverRequestRaw('ViewThumbnail', this.download) : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
linkThumbnailPreviewStyle() {
|
linkThumbnailPreviewStyle() {
|
||||||
const link = this.linkThumbnail();
|
return this.hasThumbnail() ? 'background:url(' + serverRequestRaw('ViewThumbnail', this.download) + ')' : '';
|
||||||
return link ? 'background:url(' + link + ')' : '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -63,29 +63,36 @@ class Attachment implements \JsonSerializable
|
||||||
|
|
||||||
public function FileName(bool $bCalculateOnEmpty = false) : string
|
public function FileName(bool $bCalculateOnEmpty = false) : string
|
||||||
{
|
{
|
||||||
$sFileName = '';
|
if (!$this->oBodyStructure) {
|
||||||
if ($this->oBodyStructure)
|
return '';
|
||||||
{
|
|
||||||
$sFileName = $this->oBodyStructure->FileName();
|
|
||||||
if ($bCalculateOnEmpty && !\strlen(\trim($sFileName)))
|
|
||||||
{
|
|
||||||
$sMimeType = \strtolower(\trim($this->MimeType()));
|
|
||||||
if ('message/rfc822' === $sMimeType)
|
|
||||||
{
|
|
||||||
$sFileName = 'message'.$this->MimeIndex().'.eml';
|
|
||||||
}
|
|
||||||
else if ('text/calendar' === $sMimeType)
|
|
||||||
{
|
|
||||||
$sFileName = 'calendar'.$this->MimeIndex().'.ics';
|
|
||||||
}
|
|
||||||
else if (\strlen($sMimeType))
|
|
||||||
{
|
|
||||||
$sFileName = \str_replace('/', $this->MimeIndex().'.', $sMimeType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sFileName;
|
$sFileName = \trim($this->oBodyStructure->FileName());
|
||||||
|
if (\strlen($sFileName) || !$bCalculateOnEmpty) {
|
||||||
|
return $sFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sIdx = '-' . $this->MimeIndex();
|
||||||
|
|
||||||
|
$sMimeType = \strtolower(\trim($this->MimeType()));
|
||||||
|
if ('message/rfc822' === $sMimeType) {
|
||||||
|
return "message{$sIdx}.eml";
|
||||||
|
}
|
||||||
|
if ('text/calendar' === $sMimeType) {
|
||||||
|
return "calendar{$sIdx}.ics";
|
||||||
|
}
|
||||||
|
if ('text/plain' === $sMimeType) {
|
||||||
|
return "part{$sIdx}.txt";
|
||||||
|
}
|
||||||
|
if (\preg_match('@text/(vcard|html|csv|xml|css|asp)@', $sMimeType, $aMatch)
|
||||||
|
|| \preg_match('@image/(png|jpeg|gif|bmp|cgm|ief|tiff|webp)@', $sMimeType, $aMatch)) {
|
||||||
|
return "part{$sIdx}.{$aMatch[1]}";
|
||||||
|
}
|
||||||
|
if (\strlen($sMimeType)) {
|
||||||
|
return \str_replace('/', $sIdx.'.', $sMimeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($this->oBodyStructure->IsInline() ? 'part' : 'inline' ) . $sIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function MimeType() : string
|
public function MimeType() : string
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue