Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mouday committed Apr 22, 2023
1 parent 1fadf79 commit b12ae25
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
3 changes: 1 addition & 2 deletions domain_admin/service/cache_domain_info_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from domain_admin.model.cache_domain_info_model import CacheDomainInfoModel
from domain_admin.utils import domain_util
from domain_admin.utils import domain_util
from domain_admin.utils.whois_util import whois_util


Expand All @@ -34,7 +33,7 @@ def get_domain_info(domain: str) -> CacheDomainInfoModel:
domain=root_domain,
domain_start_time=domain_whois['start_time'],
domain_expire_time=domain_whois['expire_time'],
expire_time=datetime.now() + timedelta(hours=1)
expire_time=domain_whois['expire_time'] - timedelta(minutes=3)
)

return row
7 changes: 2 additions & 5 deletions domain_admin/service/domain_service.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# -*- coding: utf-8 -*-
import json
import os
import time
import traceback
import warnings
from datetime import datetime

from playhouse.shortcuts import model_to_dict
from peewee import chunked
from playhouse.shortcuts import model_to_dict

from domain_admin.log import logger
from domain_admin.model.base_model import db
from domain_admin.model.domain_model import DomainModel
from domain_admin.model.group_model import GroupModel
from domain_admin.model.log_scheduler_model import LogSchedulerModel
Expand All @@ -22,7 +20,6 @@
from domain_admin.utils import domain_util
from domain_admin.utils.cert_util import cert_common
from domain_admin.utils.flask_ext.app_exception import AppException, ForbiddenAppException
from concurrent.futures import ThreadPoolExecutor


def add_domain(data):
Expand Down
10 changes: 5 additions & 5 deletions domain_admin/service/email_service.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from domain_admin.log import logger
from domain_admin.service import system_service
from domain_admin.utils.email_util import EmailServer
from domain_admin.utils.flask_ext.app_exception import AppException


def send_email(content: str,
to_addresses: list,
content_type: str = 'plain'):
def send_email(
content: str,
to_addresses: list,
content_type: str = 'plain'
):
"""
发送邮件
:param content:
Expand Down
22 changes: 16 additions & 6 deletions domain_admin/utils/email_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@


class EmailServer(object):
def __init__(self, mail_host, mail_port,mail_alias, mail_username, mail_password):
"""
邮件发送
"""

def __init__(self,
mail_host,
mail_port,
mail_alias,
mail_username,
mail_password):
self.mail_host = mail_host
self.mail_port = mail_port
self.mail_alias = mail_alias
Expand All @@ -24,6 +33,11 @@ def server(self):

return self._server

def quit(self):
if self.server:
self.server.quit()
self._server = None

def get_server(self):
"""
获取邮件服务器
Expand All @@ -47,15 +61,11 @@ def get_server(self):

return server

def quit(self):
if self.server:
self.server.quit()

def get_email_content(self, subject, content, content_type='plain'):
# 构造邮件
msg = MIMEText(content, content_type, 'utf-8')
# 邮箱昵称、发件人邮箱账号
msg['From'] = formataddr([self.mail_alias, self.mail_username])
msg['From'] = formataddr((self.mail_alias, self.mail_username))
# msg['To'] = to_addresses.join(',')
msg['Subject'] = subject
return msg
Expand Down

0 comments on commit b12ae25

Please sign in to comment.