Connect Stacosys to SRMail
This commit is contained in:
parent
daed9e9cb5
commit
692b90d7d9
4 changed files with 29 additions and 1 deletions
25
app/controllers/mail.py
Normal file
25
app/controllers/mail.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from flask import request, jsonify, abort
|
||||||
|
from app import app
|
||||||
|
from app.services import processor
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/inbox", methods=['POST'])
|
||||||
|
def new_mail():
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = request.get_json()
|
||||||
|
logger.info(data)
|
||||||
|
|
||||||
|
processor.enqueue({'request': 'new_mail', 'data': data})
|
||||||
|
|
||||||
|
except:
|
||||||
|
logger.exception("new mail failure")
|
||||||
|
abort(400)
|
||||||
|
|
||||||
|
return "OK"
|
|
@ -20,6 +20,7 @@ import config
|
||||||
from app.services import database
|
from app.services import database
|
||||||
from app.services import processor
|
from app.services import processor
|
||||||
from app.controllers import api
|
from app.controllers import api
|
||||||
|
from app.controllers import mail
|
||||||
from app import app
|
from app import app
|
||||||
|
|
||||||
# configure logging
|
# configure logging
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Processor(Thread):
|
||||||
#elif req['type'] == 'unsubscribe':
|
#elif req['type'] == 'unsubscribe':
|
||||||
# unsubscribe_reader(req['email'], req['article'])
|
# unsubscribe_reader(req['email'], req['article'])
|
||||||
else:
|
else:
|
||||||
logger.info("Dequeue unknown request " + msg)
|
logger.info("Dequeue unknown request " + str(msg))
|
||||||
|
|
||||||
|
|
||||||
def new_comment(data):
|
def new_comment(data):
|
||||||
|
|
|
@ -7,6 +7,8 @@ LANG = "en"
|
||||||
#DB_URL = "mysql://stacosys_user:stacosys_password@localhost:3306/stacosys"
|
#DB_URL = "mysql://stacosys_user:stacosys_password@localhost:3306/stacosys"
|
||||||
DB_URL = "sqlite:///db.sqlite"
|
DB_URL = "sqlite:///db.sqlite"
|
||||||
|
|
||||||
|
MAIL_URL = "http://localhost:8025"
|
||||||
|
|
||||||
HTTP_ADDRESS = "0.0.0.0"
|
HTTP_ADDRESS = "0.0.0.0"
|
||||||
HTTP_PORT = 8000
|
HTTP_PORT = 8000
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue