mirror of
https://github.com/aaPanel/aaPanel.git
synced 2026-09-08 02:27:54 +02:00
1. Added Mail Marketing Automation trigger tasks 2. Added Mail Marketing Groups Import, Export, Merge 3. Added Mail Marketing Subscribers to support paste import 4. Added Mail Marketing Template Import Export Duplicate 5. Added Mail server add timed automatic reply 6. Added HTTPS Protection function for Website (disables automatic HTTP to HTTPS redirection when enabled) 7. Optimize Website Interface Button Integration 8. Optimize the response speed of WP Toolkit interface
179 lines
5.6 KiB
Python
179 lines
5.6 KiB
Python
import glob
|
|
import hashlib
|
|
import json
|
|
import os
|
|
import re
|
|
import sys
|
|
import time
|
|
|
|
import psutil
|
|
from datetime import datetime
|
|
from importlib import import_module
|
|
from typing import Tuple, Union, Optional, List
|
|
|
|
from .send_tool import WxAccountMsg, WxAccountLoginMsg
|
|
from .base_task import BaseTask
|
|
from .mods import PUSH_DATA_PATH, TaskConfig, SenderConfig, PANEL_PATH
|
|
from .util import read_file, DB, write_file, check_site_status,GET_CLASS, ExecShell, get_config_value, public_get_cache_func, \
|
|
public_set_cache_func, get_network_ip, public_get_user_info, public_http_post, panel_version
|
|
from mod.base.web_conf import RealSSLManger
|
|
|
|
# 邮局域名进入黑名单
|
|
class MailDomainBlcheck(BaseTask):
|
|
push_tip_file = "/www/server/panel/data/mail_domain_blcheck_send_type.pl"
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.source_name = "mail_domain_black"
|
|
self.template_name = "Your IP is on the email blacklist"
|
|
self.title = "Your IP is on the email blacklist"
|
|
|
|
def check_task_data(self, task_data: dict) -> Union[dict, str]:
|
|
return {}
|
|
|
|
def get_keyword(self, task_data: dict) -> str:
|
|
return "mail_domain_black"
|
|
|
|
def get_push_data(self, task_id: str, task_data: dict) -> Optional[dict]:
|
|
return None
|
|
|
|
def filter_template(self, template) -> dict:
|
|
return template
|
|
|
|
def to_sms_msg(self, push_data: dict, push_public_data: dict) -> Tuple[str, dict]:
|
|
return "", {}
|
|
|
|
def task_config_update_hook(self, task: dict) -> None:
|
|
|
|
sender = task["sender"]
|
|
if len(sender) > 0:
|
|
send_id = sender[0]
|
|
else:
|
|
return
|
|
|
|
sender_data = SenderConfig().get_by_id(send_id)
|
|
if sender_data:
|
|
write_file(self.push_tip_file, sender_data["sender_type"])
|
|
|
|
def task_config_create_hook(self, task: dict) -> None:
|
|
return self.task_config_update_hook(task)
|
|
|
|
def task_config_remove_hook(self, task: dict) -> None:
|
|
if os.path.exists(self.push_tip_file):
|
|
os.remove(self.push_tip_file)
|
|
|
|
# 邮局服务异常告警
|
|
class MailServerDown(BaseTask):
|
|
push_tip_file = "/www/server/panel/data/mail_server_down_send_type.pl"
|
|
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.source_name = "mail_server_status"
|
|
self.template_name = "Your Mail Service is down"
|
|
self.title = "Your Mail Service is down"
|
|
|
|
def check_task_data(self, task_data: dict) -> Union[dict, str]:
|
|
return {}
|
|
|
|
def get_keyword(self, task_data: dict) -> str:
|
|
return "mail_server_status"
|
|
|
|
def get_push_data(self, task_id: str, task_data: dict) -> Optional[dict]:
|
|
return None
|
|
|
|
def filter_template(self, template) -> dict:
|
|
return template
|
|
|
|
def to_sms_msg(self, push_data: dict, push_public_data: dict) -> Tuple[str, dict]:
|
|
return "", {}
|
|
|
|
def task_config_update_hook(self, task: dict) -> None:
|
|
|
|
sender = task["sender"]
|
|
if len(sender) > 0:
|
|
send_id = sender[0]
|
|
else:
|
|
return
|
|
|
|
sender_data = SenderConfig().get_by_id(send_id)
|
|
if sender_data:
|
|
write_file(self.push_tip_file, sender_data["sender_type"])
|
|
|
|
def task_config_create_hook(self, task: dict) -> None:
|
|
return self.task_config_update_hook(task)
|
|
|
|
def task_config_remove_hook(self, task: dict) -> None:
|
|
if os.path.exists(self.push_tip_file):
|
|
os.remove(self.push_tip_file)
|
|
|
|
# 邮局服务异常告警
|
|
class CertExpiry(BaseTask):
|
|
push_tip_file = "/www/server/panel/data/mail_cert_expiry_send_type.pl"
|
|
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.source_name = "mail_server_certificate_expired"
|
|
self.template_name = "Mail Server certificate expired"
|
|
self.title = "Your Mail Server certificate expired"
|
|
|
|
def check_task_data(self, task_data: dict) -> Union[dict, str]:
|
|
return {}
|
|
|
|
def get_keyword(self, task_data: dict) -> str:
|
|
return "mail_server_certificate_expired"
|
|
|
|
def get_push_data(self, task_id: str, task_data: dict) -> Optional[dict]:
|
|
return None
|
|
|
|
def filter_template(self, template) -> dict:
|
|
return template
|
|
|
|
def to_sms_msg(self, push_data: dict, push_public_data: dict) -> Tuple[str, dict]:
|
|
return "", {}
|
|
|
|
def task_config_update_hook(self, task: dict) -> None:
|
|
|
|
sender = task["sender"]
|
|
if len(sender) > 0:
|
|
send_id = sender[0]
|
|
else:
|
|
return
|
|
|
|
sender_data = SenderConfig().get_by_id(send_id)
|
|
if sender_data:
|
|
write_file(self.push_tip_file, sender_data["sender_type"])
|
|
|
|
def task_config_create_hook(self, task: dict) -> None:
|
|
return self.task_config_update_hook(task)
|
|
|
|
def task_config_remove_hook(self, task: dict) -> None:
|
|
if os.path.exists(self.push_tip_file):
|
|
os.remove(self.push_tip_file)
|
|
|
|
|
|
class ViewMsgFormat(object):
|
|
_FORMAT = {
|
|
"1": (
|
|
lambda x: "<span>When your MailServer domain is blacklisted, an alarm is generated</span>"
|
|
),
|
|
"2": (
|
|
lambda x: "<span>When your Mail Service is down, an alarm is generated</span>"
|
|
),
|
|
"3": (
|
|
lambda x: "<span>When your Mail Server certificate expired, an alarm is generated</span>"
|
|
)
|
|
}
|
|
|
|
def get_msg(self, task: dict) -> Optional[str]:
|
|
if task["template_id"] in ["80"]:
|
|
return self._FORMAT["1"](task)
|
|
if task["template_id"] in ["81"]:
|
|
return self._FORMAT["2"](task)
|
|
if task["template_id"] in ["82"]:
|
|
return self._FORMAT["3"](task)
|
|
if task["template_id"] in self._FORMAT:
|
|
return self._FORMAT[task["template_id"]](task)
|
|
return None
|