Skip to content

Commit

Permalink
correctly raise feishu error (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoQuote authored Nov 15, 2021
1 parent 5b05b33 commit ee3890d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions helpdesk/libs/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@
TIME_ZONE,
TIME_FORMAT
)
from helpdesk.libs.sentry import report

logger = logging.getLogger(__name__)


def timeLocalize(value):
tz = timezone(TIME_ZONE)
utc = timezone('Etc/UTC')
dt = value
dt_with_timezone = utc.localize(dt)
return dt_with_timezone.astimezone(tz).strftime(TIME_FORMAT)

_templates = Jinja2Templates(directory='templates/notification')
_templates.env.filters['timeLocalize'] = timeLocalize

_templates = Jinja2Templates(directory='templates/notification')
_templates.env.filters['timeLocalize'] = timeLocalize


class Notification:
Expand Down Expand Up @@ -151,5 +154,8 @@ async def send(self):
}
}
}
r = requests.post(WEBHOOK_URL, json=msg)
r.raise_for_status()
r = requests.post(WEBHOOK_URL, json={"msg_type": "interactive", "card": msg})
if r.status_code == 200 and r.json()["StatusCode"] == 0:
return
else:
report()

0 comments on commit ee3890d

Please sign in to comment.