]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
better type logic
authorEvan Prodromou <evan@prodromou.name>
Fri, 18 Jul 2008 20:20:52 +0000 (16:20 -0400)
committerEvan Prodromou <evan@prodromou.name>
Fri, 18 Jul 2008 20:20:52 +0000 (16:20 -0400)
darcs-hash:20080718202052-84dde-cf788df7bcf76f971229d18041823a9483a164cc.gz

maildaemon.php

index dcd4b2d30d21cbebfa1e44aeb3c491dca80e3093..185f6609c0142b95215cbe4d11b7e51617aa28f0 100755 (executable)
@@ -123,10 +123,10 @@ class MailerDaemon {
                }
                $from = $parsed->headers['from'];
                $to = $parsed->headers['to'];
+
+               $type = $parsed->ctype_primary . '/' . $parsed->ctype_secondary;
                
-               switch ($parsed->ctype_primary) {
-                case 'multitype':
-                       # try and find a text/plain in the mix
+               if ($parsed->ctype_primary == 'multitype') {
                        foreach ($parsed->parts as $part) {
                                if ($part->ctype_primary == 'text' &&
                                        $part->ctype_secondary == 'plain') {
@@ -134,16 +134,9 @@ class MailerDaemon {
                                        break;
                                }
                        }
-                       break;
-                case 'text':
-                       switch ($parsed->ctype_secondary) {
-                        case 'plain':
-                               $msg = $parsed->body;
-                               break;
-                        default:
-                               $this->unsupported_type($parsed);
-                       }
-                default:
+               } else if ($type == 'text/plain') {
+                       $msg = $parsed->body;
+               } else {
                        $this->unsupported_type($parsed);
                }