Browse Source

消息内容统一设置页脚

luolongfei 3 years ago
parent
commit
2de123a415

+ 7 - 6
libs/Connector/MessageGateway.php

@@ -56,19 +56,20 @@ abstract class MessageGateway implements MessageServiceInterface
      *
      *
      * @param $footer
      * @param $footer
      * @param $newline
      * @param $newline
-     * @param $enable
+     * @param $enablePushFreqTips
      *
      *
      * @return void
      * @return void
      */
      */
-    public function setCommonFooter(&$footer, $newline = "\n", $enable = true)
+    public function setCommonFooter(&$footer, $newline = "\n", $enablePushFreqTips = true)
     {
     {
+        if ($enablePushFreqTips) {
+            $footer .= $newline . $newline . lang('100133');
+        }
+
+        // 服务器信息相关文言
         if (env('SHOW_SERVER_INFO')) {
         if (env('SHOW_SERVER_INFO')) {
             $footer .= $newline . $newline . lang('100134');
             $footer .= $newline . $newline . lang('100134');
             $footer .= $newline . get_ip_info();
             $footer .= $newline . get_ip_info();
         }
         }
-
-        if ($enable) {
-            $footer .= $newline . $newline . lang('100133');
-        }
     }
     }
 }
 }

+ 9 - 7
libs/MessageServices/Bark.php

@@ -140,18 +140,14 @@ class Bark extends MessageGateway
     /**
     /**
      * 获取页脚
      * 获取页脚
      *
      *
-     * @param bool $isRenewalResult 是否续期结果,续期结果不用提醒调整推送频率
-     *
      * @return string
      * @return string
      */
      */
-    public function getFooter(bool $isRenewalResult = false)
+    public function getFooter()
     {
     {
         $footer = '';
         $footer = '';
 
 
         $footer .= lang('100078');
         $footer .= lang('100078');
 
 
-        $this->setCommonFooter($footer, "\n", !$isRenewalResult);
-
         return $footer;
         return $footer;
     }
     }
 
 
@@ -206,7 +202,7 @@ class Bark extends MessageGateway
         $text .= lang('100086');
         $text .= lang('100086');
         $text .= $this->genDomainStatusText($domainStatus);
         $text .= $this->genDomainStatusText($domainStatus);
 
 
-        $text .= $this->getFooter(true);
+        $text .= $this->getFooter();
 
 
         return $text;
         return $text;
     }
     }
@@ -247,16 +243,22 @@ class Bark extends MessageGateway
     {
     {
         $this->check($content, $data);
         $this->check($content, $data);
 
 
+        $commonFooter = '';
+
         if ($type === 1 || $type === 4) {
         if ($type === 1 || $type === 4) {
-            // Do nothing
+            $this->setCommonFooter($commonFooter, "\n", false);
         } else if ($type === 2) {
         } else if ($type === 2) {
+            $this->setCommonFooter($commonFooter, "\n", false);
             $content = $this->genDomainRenewalResultsText($data['username'], $data['renewalSuccessArr'], $data['renewalFailuresArr'], $data['domainStatusArr']);
             $content = $this->genDomainRenewalResultsText($data['username'], $data['renewalSuccessArr'], $data['renewalFailuresArr'], $data['domainStatusArr']);
         } else if ($type === 3) {
         } else if ($type === 3) {
+            $this->setCommonFooter($commonFooter);
             $content = $this->genDomainStatusFullText($data['username'], $data['domainStatusArr']);
             $content = $this->genDomainStatusFullText($data['username'], $data['domainStatusArr']);
         } else {
         } else {
             throw new \Exception(lang('100003'));
             throw new \Exception(lang('100003'));
         }
         }
 
 
+        $content .= $commonFooter;
+
         $query = [
         $query = [
             'level' => $this->level,
             'level' => $this->level,
             'automaticallyCopy' => $this->automaticallyCopy, // 携带参数 automaticallyCopy=1, 收到推送时,推送内容会自动复制到粘贴板(如发现不能自动复制,可尝试重启一下手机)
             'automaticallyCopy' => $this->automaticallyCopy, // 携带参数 automaticallyCopy=1, 收到推送时,推送内容会自动复制到粘贴板(如发现不能自动复制,可尝试重启一下手机)

+ 16 - 6
libs/MessageServices/Mail.php

@@ -189,6 +189,9 @@ class Mail extends MessageGateway
         $subject = $subject === '' ? mb_substr($content, 0, 12) . '...' : $subject;
         $subject = $subject === '' ? mb_substr($content, 0, 12) . '...' : $subject;
         $this->phpMailerInstance->Subject = $subject;
         $this->phpMailerInstance->Subject = $subject;
 
 
+        // 页脚
+        $footer = '';
+
         /**
         /**
          * 正文
          * 正文
          * 使用 html 文件内容作为正文,其中的图片将被 base64 编码,另确保 html 样式为内联形式,且某些样式可能需要 !important 方能正常显示,
          * 使用 html 文件内容作为正文,其中的图片将被 base64 编码,另确保 html 样式为内联形式,且某些样式可能需要 !important 方能正常显示,
@@ -201,22 +204,25 @@ class Mail extends MessageGateway
          */
          */
         if ($type === 1) {
         if ($type === 1) {
             $template = file_get_contents($this->noticeTemplatePath);
             $template = file_get_contents($this->noticeTemplatePath);
-            $message = sprintf($template, $content);
+            $this->setCommonFooter($footer, '<br>', false);
+            $message = $this->genMessageContent([
+                $content,
+                $footer
+            ], $template);
         } else if ($type === 2) {
         } else if ($type === 2) {
             $template = file_get_contents($this->successfulRenewalTemplatePath);
             $template = file_get_contents($this->successfulRenewalTemplatePath);
+            $this->setCommonFooter($footer, '<br>', false);
             $realData = [
             $realData = [
                 $data['username'],
                 $data['username'],
                 $data['renewalSuccessArr'] ? sprintf(lang('100075'), $this->genDomainsHtml($data['renewalSuccessArr'])) : '',
                 $data['renewalSuccessArr'] ? sprintf(lang('100075'), $this->genDomainsHtml($data['renewalSuccessArr'])) : '',
                 $data['renewalFailuresArr'] ? sprintf(lang('100076'), $this->genDomainsHtml($data['renewalFailuresArr'])) : '',
                 $data['renewalFailuresArr'] ? sprintf(lang('100076'), $this->genDomainsHtml($data['renewalFailuresArr'])) : '',
-                $this->genDomainStatusHtml($data['domainStatusArr'])
+                $this->genDomainStatusHtml($data['domainStatusArr']),
+                $footer
             ];
             ];
             $message = $this->genMessageContent($realData, $template);
             $message = $this->genMessageContent($realData, $template);
         } else if ($type === 3) {
         } else if ($type === 3) {
             $template = file_get_contents($this->noRenewalRequiredTemplatePath);
             $template = file_get_contents($this->noRenewalRequiredTemplatePath);
-
-            $footer = '';
             $this->setCommonFooter($footer, '<br>');
             $this->setCommonFooter($footer, '<br>');
-
             $realData = [
             $realData = [
                 $data['username'],
                 $data['username'],
                 $this->genDomainStatusHtml($data['domainStatusArr']),
                 $this->genDomainStatusHtml($data['domainStatusArr']),
@@ -225,7 +231,11 @@ class Mail extends MessageGateway
             $message = $this->genMessageContent($realData, $template);
             $message = $this->genMessageContent($realData, $template);
         } else if ($type === 4) {
         } else if ($type === 4) {
             $template = file_get_contents($this->noticeTemplatePath);
             $template = file_get_contents($this->noticeTemplatePath);
-            $message = sprintf($template, $this->newLine2Br($content));
+            $this->setCommonFooter($footer, '<br>', false);
+            $message = $this->genMessageContent([
+                $this->newLine2Br($content),
+                $footer
+            ], $template);
         } else {
         } else {
             throw new \Exception(lang('100003'));
             throw new \Exception(lang('100003'));
         }
         }

+ 9 - 7
libs/MessageServices/ServerChan.php

@@ -60,18 +60,14 @@ class ServerChan extends MessageGateway
     /**
     /**
      * 获取 MarkDown 页脚
      * 获取 MarkDown 页脚
      *
      *
-     * @param bool $isRenewalResult 是否续期结果,续期结果不用提醒调整推送频率
-     *
      * @return string
      * @return string
      */
      */
-    public function getMarkDownFooter(bool $isRenewalResult = false)
+    public function getMarkDownFooter()
     {
     {
         $footer = '';
         $footer = '';
 
 
         $footer .= lang('100091');
         $footer .= lang('100091');
 
 
-        $this->setCommonFooter($footer, "\n", !$isRenewalResult);
-
         return $footer;
         return $footer;
     }
     }
 
 
@@ -126,7 +122,7 @@ class ServerChan extends MessageGateway
         $text .= lang('100099');
         $text .= lang('100099');
         $text .= $this->genDomainStatusMarkDownText($domainStatus);
         $text .= $this->genDomainStatusMarkDownText($domainStatus);
 
 
-        $text .= $this->getMarkDownFooter(true);
+        $text .= $this->getMarkDownFooter();
 
 
         return $text;
         return $text;
     }
     }
@@ -168,16 +164,22 @@ class ServerChan extends MessageGateway
     {
     {
         $this->check($content, $data);
         $this->check($content, $data);
 
 
+        $commonFooter = '';
+
         if ($type === 1 || $type === 4) {
         if ($type === 1 || $type === 4) {
-            // Do nothing
+            $this->setCommonFooter($commonFooter, "\n", false);
         } else if ($type === 2) {
         } else if ($type === 2) {
+            $this->setCommonFooter($commonFooter, "\n", false);
             $content = $this->genDomainRenewalResultsMarkDownText($data['username'], $data['renewalSuccessArr'], $data['renewalFailuresArr'], $data['domainStatusArr']);
             $content = $this->genDomainRenewalResultsMarkDownText($data['username'], $data['renewalSuccessArr'], $data['renewalFailuresArr'], $data['domainStatusArr']);
         } else if ($type === 3) {
         } else if ($type === 3) {
+            $this->setCommonFooter($commonFooter);
             $content = $this->genDomainStatusFullMarkDownText($data['username'], $data['domainStatusArr']);
             $content = $this->genDomainStatusFullMarkDownText($data['username'], $data['domainStatusArr']);
         } else {
         } else {
             throw new \Exception(lang('100003'));
             throw new \Exception(lang('100003'));
         }
         }
 
 
+        $content .= $commonFooter;
+
         $subject = $subject === '' ? mb_substr($content, 0, 12) . '...' : $subject;
         $subject = $subject === '' ? mb_substr($content, 0, 12) . '...' : $subject;
 
 
         try {
         try {

+ 9 - 7
libs/MessageServices/TelegramBot.php

@@ -93,18 +93,14 @@ class TelegramBot extends MessageGateway
     /**
     /**
      * 获取 MarkDown 页脚
      * 获取 MarkDown 页脚
      *
      *
-     * @param bool $isRenewalResult 是否续期结果,续期结果不用提醒调整推送频率
-     *
      * @return string
      * @return string
      */
      */
-    public function getMarkDownFooter(bool $isRenewalResult = false)
+    public function getMarkDownFooter()
     {
     {
         $footer = '';
         $footer = '';
 
 
         $footer .= lang('100103');
         $footer .= lang('100103');
 
 
-        $this->setCommonFooter($footer, "\n", !$isRenewalResult);
-
         return $footer;
         return $footer;
     }
     }
 
 
@@ -159,7 +155,7 @@ class TelegramBot extends MessageGateway
         $text .= lang('100111');
         $text .= lang('100111');
         $text .= $this->genDomainStatusMarkDownText($domainStatus);
         $text .= $this->genDomainStatusMarkDownText($domainStatus);
 
 
-        $text .= $this->getMarkDownFooter(true);
+        $text .= $this->getMarkDownFooter();
 
 
         return $text;
         return $text;
     }
     }
@@ -256,16 +252,22 @@ class TelegramBot extends MessageGateway
     {
     {
         $this->check($content, $data);
         $this->check($content, $data);
 
 
+        $commonFooter = '';
+
         if ($type === 1 || $type === 4) {
         if ($type === 1 || $type === 4) {
-            // Do nothing
+            $this->setCommonFooter($commonFooter, "\n", false);
         } else if ($type === 2) {
         } else if ($type === 2) {
+            $this->setCommonFooter($commonFooter, "\n", false);
             $content = $this->genDomainRenewalResultsMarkDownText($data['username'], $data['renewalSuccessArr'], $data['renewalFailuresArr'], $data['domainStatusArr']);
             $content = $this->genDomainRenewalResultsMarkDownText($data['username'], $data['renewalSuccessArr'], $data['renewalFailuresArr'], $data['domainStatusArr']);
         } else if ($type === 3) {
         } else if ($type === 3) {
+            $this->setCommonFooter($commonFooter);
             $content = $this->genDomainStatusFullMarkDownText($data['username'], $data['domainStatusArr']);
             $content = $this->genDomainStatusFullMarkDownText($data['username'], $data['domainStatusArr']);
         } else {
         } else {
             throw new \Exception(lang('100003'));
             throw new \Exception(lang('100003'));
         }
         }
 
 
+        $content .= $commonFooter;
+
         $isMarkdown = true;
         $isMarkdown = true;
 
 
         // 使用可变参数控制 telegram 送信类型,一般不会用到
         // 使用可变参数控制 telegram 送信类型,一般不会用到

+ 9 - 7
libs/MessageServices/WeChat.php

@@ -152,18 +152,14 @@ class WeChat extends MessageGateway
     /**
     /**
      * 获取页脚
      * 获取页脚
      *
      *
-     * @param bool $isRenewalResult 是否续期结果,续期结果不用提醒调整推送频率
-     *
      * @return string
      * @return string
      */
      */
-    public function getFooter(bool $isRenewalResult = false)
+    public function getFooter()
     {
     {
         $footer = '';
         $footer = '';
 
 
         $footer .= lang('100116');
         $footer .= lang('100116');
 
 
-        $this->setCommonFooter($footer, "\n", !$isRenewalResult);
-
         return $footer;
         return $footer;
     }
     }
 
 
@@ -218,7 +214,7 @@ class WeChat extends MessageGateway
         $text .= lang('100124');
         $text .= lang('100124');
         $text .= $this->genDomainStatusText($domainStatus);
         $text .= $this->genDomainStatusText($domainStatus);
 
 
-        $text .= $this->getFooter(true);
+        $text .= $this->getFooter();
 
 
         return $text;
         return $text;
     }
     }
@@ -266,16 +262,22 @@ class WeChat extends MessageGateway
     {
     {
         $this->check($content, $data);
         $this->check($content, $data);
 
 
+        $commonFooter = '';
+
         if ($type === 1 || $type === 4) {
         if ($type === 1 || $type === 4) {
-            // Do nothing
+            $this->setCommonFooter($commonFooter, "\n", false);
         } else if ($type === 2) {
         } else if ($type === 2) {
+            $this->setCommonFooter($commonFooter, "\n", false);
             $content = $this->genDomainRenewalResultsText($data['username'], $data['renewalSuccessArr'], $data['renewalFailuresArr'], $data['domainStatusArr']);
             $content = $this->genDomainRenewalResultsText($data['username'], $data['renewalSuccessArr'], $data['renewalFailuresArr'], $data['domainStatusArr']);
         } else if ($type === 3) {
         } else if ($type === 3) {
+            $this->setCommonFooter($commonFooter);
             $content = $this->genDomainStatusFullText($data['username'], $data['domainStatusArr']);
             $content = $this->genDomainStatusFullText($data['username'], $data['domainStatusArr']);
         } else {
         } else {
             throw new \Exception(lang('100003'));
             throw new \Exception(lang('100003'));
         }
         }
 
 
+        $content .= $commonFooter;
+
         if ($subject !== '') {
         if ($subject !== '') {
             $content = $subject . "\n\n" . $content;
             $content = $subject . "\n\n" . $content;
         }
         }

+ 1 - 0
resources/mail/en/notice.html

@@ -347,6 +347,7 @@
                 <div>
                 <div>
                     <p>
                     <p>
                         %s
                         %s
+                        %s
                     </p>
                     </p>
                 </div>
                 </div>
                 <div class="mmsgLetterInscribe" style="padding:40px 0 0;">
                 <div class="mmsgLetterInscribe" style="padding:40px 0 0;">

+ 1 - 0
resources/mail/en/successful_renewal.html

@@ -358,6 +358,7 @@
                         <br><br>For further information, please visit <a
                         <br><br>For further information, please visit <a
                                 href="https://my.freenom.com/domains.php?a=renewals" target="_blank" rel="noopener">
                                 href="https://my.freenom.com/domains.php?a=renewals" target="_blank" rel="noopener">
                             Freenom’s official website</a>
                             Freenom’s official website</a>
+                        %s
                     </p>
                     </p>
                 </div>
                 </div>
                 <div class="mmsgLetterInscribe" style="padding:40px 0 0;">
                 <div class="mmsgLetterInscribe" style="padding:40px 0 0;">

+ 1 - 0
resources/mail/zh/notice.html

@@ -341,6 +341,7 @@
                 <div>
                 <div>
                     <p>
                     <p>
                         %s
                         %s
+                        %s
                     </p>
                     </p>
                 </div>
                 </div>
                 <div class="mmsgLetterInscribe" style="padding:40px 0 0;">
                 <div class="mmsgLetterInscribe" style="padding:40px 0 0;">

+ 1 - 0
resources/mail/zh/successful_renewal.html

@@ -348,6 +348,7 @@
                         <span class="notRenewed">%s</span>
                         <span class="notRenewed">%s</span>
                         <br>emmmm,除以上内容外,我还帮小主看了一下:<br><br><span class="domainDays">%s</span>
                         <br>emmmm,除以上内容外,我还帮小主看了一下:<br><br><span class="domainDays">%s</span>
                         <br><br>更多信息可以参考 <a href="https://my.freenom.com/domains.php?a=renewals" target="_blank" rel="noopener">Freenom官网</a> 哦~
                         <br><br>更多信息可以参考 <a href="https://my.freenom.com/domains.php?a=renewals" target="_blank" rel="noopener">Freenom官网</a> 哦~
+                        %s
                     </p>
                     </p>
                 </div>
                 </div>
                 <div class="mmsgLetterInscribe" style="padding:40px 0 0;">
                 <div class="mmsgLetterInscribe" style="padding:40px 0 0;">