forked from CCCHH/hedgedoc-expire
Add a command to test the email config with
This commit is contained in:
parent
d73c5f8a52
commit
5d950facab
1 changed files with 15 additions and 1 deletions
|
@ -251,6 +251,18 @@ class HedgedocExpire:
|
|||
self.check_revisions_to_be_expired(db)
|
||||
self.check_notes_to_be_expired(db)
|
||||
|
||||
def cmd_emailcheck(self) -> None:
|
||||
msg = MIMEMultipart()
|
||||
msg['From'] = self.email_sender.mail_from
|
||||
msg['To'] = self.email_sender.mail_from
|
||||
msg['Subject'] = f'Hedgedoc Expire: Test Mail'
|
||||
msg.attach(MIMEText(dedent(f'''\
|
||||
This is a test email to confirm proper configuration of the SMTP client.
|
||||
|
||||
The admin team for {self.config.url}
|
||||
''')))
|
||||
self.email_sender.send(msg)
|
||||
|
||||
def cmd_expire(self) -> None:
|
||||
with pgsql.Connection((self.config.postgres_hostname, self.config.postgres_port),
|
||||
self.config.postgres_username, self.config.postgres_password) as db:
|
||||
|
@ -281,7 +293,7 @@ def main():
|
|||
help='remove all notes not changed in these many days')
|
||||
parser.add_argument('-r', '--revisions', metavar='DAYS', type=float, default=14,
|
||||
help='remove all revisions created more than these many days ago')
|
||||
parser.add_argument('command', choices=['check', 'cron', 'expire'], default='check', nargs='?',
|
||||
parser.add_argument('command', choices=['check', 'cron', 'emailcheck', 'expire'], default='check', nargs='?',
|
||||
help='action to perform')
|
||||
parser.add_argument('-v', '--verbose', action='store_true', default=False,
|
||||
help='print more info while running')
|
||||
|
@ -306,6 +318,8 @@ def main():
|
|||
if seconds > 0:
|
||||
sleep(seconds)
|
||||
hedgedoc_expire.cmd_expire()
|
||||
elif args.command == 'emailcheck':
|
||||
hedgedoc_expire.cmd_emailcheck()
|
||||
elif args.command == 'expire':
|
||||
hedgedoc_expire.cmd_expire()
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue