Bläddra i källkod

修复GoogleVoice

陈德本 5 år sedan
förälder
incheckning
6bcd6b98fd
1 ändrade filer med 17 tillägg och 22 borttagningar
  1. 17 22
      Library/Sms/GoogleVoice.php

+ 17 - 22
Library/Sms/GoogleVoice.php

@@ -44,39 +44,34 @@ class GoogleVoice implements Sms
             'UTF-8' // Server encoding (optional)
         );
         $mail_ids = $mailbox->searchMailbox('FROM txt.voice.google.com');
-        $from_google=true;
-        $cache=Redis::instance();
-        $i=0;
+        rsort($mail_ids);
+        $cache = Redis::instance();
+        $i = 0;
+        krsort($mail_info);
         foreach ($mail_ids as $mail_id) {
-            if ($i>=20){
+            if ($i >= 20) {
                 break;
-            }else{
-                $key="mails_gv:".$mail_id;
-                $temp=$cache->get($key);
+            } else {
+                $key = "mails_gv:" . $mail_id;
+                $temp = $cache->get($key);
                 if (!$temp) {
                     $detail = $mailbox->getMail($mail_id);
-                    if ($from_google){
-                        $from_num=$detail->fromName;
-                        $txt = explode("\r\n", $detail->textPlain)[1];
-                        $date=$detail->date;
-                    }else{
-                        $from_num=str_replace("Message from ", "", $detail->subject);
-                        $txt=$detail->textPlain;
-                        $rwn=explode("\r\n", $detail->headersRaw);
-                        $date=explode(": ", $rwn[2])[1];
-                    }
-                    $temp=[
-                        'from' =>$from_num,
-                        'time' => date("Y-m-d H:i:s",strtotime($date)),
+                    $from_num = str_replace("Message from ", "", $detail->subject);
+                    $txt = $detail->textPlain;
+                    $rwn = explode("\r\n", $detail->headersRaw);
+                    $date = explode(": ", $rwn[2])[1];
+                    $temp = [
+                        'from' => $from_num,
+                        'time' => date("Y-m-d H:i:s", strtotime($date)),
                         'message' => $txt
                     ];
                     $cache->set($key, $temp);
                 }
-                $mail_info[]=$temp;
+                $mail_info[] = $temp;
             }
             $i++;
         }
-        krsort($mail_info);
+//        rsort($mail_info);
         return $mail_info;
     }