66
77use GuzzleHttp \Psr7 \Utils ;
88use PhpList \Core \Domain \Messaging \Exception \AttachmentFileNotFoundException ;
9- use PhpList \Core \Domain \Messaging \Exception \MessageNotReceivedException ;
9+ use PhpList \Core \Domain \Messaging \Exception \SubscriberNotFoundException ;
1010use PhpList \Core \Domain \Messaging \Model \Attachment ;
1111use PhpList \Core \Domain \Messaging \Model \Dto \DownloadableAttachment ;
1212use PhpList \Core \Domain \Subscription \Repository \SubscriberRepository ;
@@ -27,6 +27,9 @@ public function getDownloadable(Attachment $attachment, string $uid): Downloadab
2727 $ this ->validateUid ($ uid );
2828
2929 $ original = $ attachment ->getFilename ();
30+ if ($ original === null || $ original === '' ) {
31+ throw new AttachmentFileNotFoundException ('Attachment has no filename. ' );
32+ }
3033 $ filename = basename ($ original );
3134 $ filePath = $ this ->validateFilePath ($ filename , $ original );
3235
@@ -50,11 +53,13 @@ public function getDownloadable(Attachment $attachment, string $uid): Downloadab
5053
5154 private function validateUid (string $ uid ): void
5255 {
53- if ($ uid !== Attachment::FORWARD ) {
54- $ subscriber = $ this ->subscriberRepository ->findOneByEmail ($ uid );
55- if ($ subscriber === null ) {
56- throw new MessageNotReceivedException ();
57- }
56+ if ($ uid === Attachment::FORWARD ) {
57+ return ;
58+ }
59+
60+ $ subscriber = $ this ->subscriberRepository ->findOneByEmail ($ uid );
61+ if ($ subscriber === null ) {
62+ throw new SubscriberNotFoundException ();
5863 }
5964 }
6065
0 commit comments