working on global logging/events
parent
8620bba0ef
commit
91fea2066f
@ -0,0 +1,7 @@
|
|||||||
|
from wowstash.library.elasticsearch import send_es
|
||||||
|
from wowstash.library.mattermost import post_webhook
|
||||||
|
|
||||||
|
|
||||||
|
def capture_event(event_type, user_obj):
|
||||||
|
send_es({'type': event_type, 'user': user_obj.email})
|
||||||
|
post_webhook(f'`{event_type}` from user {user_obj.id}')
|
@ -0,0 +1,22 @@
|
|||||||
|
from requests import post as r_post
|
||||||
|
from json import dumps
|
||||||
|
from flask import current_app
|
||||||
|
from wowstash import config
|
||||||
|
|
||||||
|
|
||||||
|
def post_webhook(msg):
|
||||||
|
if getattr(config, 'MM_ENABLED', False):
|
||||||
|
try:
|
||||||
|
if current_app.config["DEBUG"]:
|
||||||
|
msg = "[DEBUG] " + msg
|
||||||
|
data = {
|
||||||
|
"text": msg,
|
||||||
|
"channel": config.MM_CHANNEL,
|
||||||
|
"username": config.MM_USERNAME,
|
||||||
|
"icon_url": config.MM_ICON
|
||||||
|
}
|
||||||
|
res = r_post(config.MM_ENDPOINT, data=dumps(data))
|
||||||
|
res.raise_for_status()
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
Loading…
Reference in New Issue