[fix] Corrections ruff CI (UP017/UP041/UP012/I001/F401/FURB162) : backend/notify.py
This commit is contained in:
+4
-4
@@ -25,7 +25,7 @@ import os
|
|||||||
import smtplib
|
import smtplib
|
||||||
import threading
|
import threading
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime, timezone
|
from datetime import UTC, datetime
|
||||||
from email.message import EmailMessage
|
from email.message import EmailMessage
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@@ -182,7 +182,7 @@ def create_channel(name: str, channel_type: str, config: dict[str, Any]) -> dict
|
|||||||
"type": channel_type,
|
"type": channel_type,
|
||||||
"enabled": True,
|
"enabled": True,
|
||||||
"config": normalized,
|
"config": normalized,
|
||||||
"created_at": datetime.now(timezone.utc).isoformat(),
|
"created_at": datetime.now(UTC).isoformat(),
|
||||||
"last_sent_at": None,
|
"last_sent_at": None,
|
||||||
"last_error": None,
|
"last_error": None,
|
||||||
}
|
}
|
||||||
@@ -287,7 +287,7 @@ def _send_webhook(url: str, title: str, message: str, trigger: str) -> None:
|
|||||||
"event": trigger,
|
"event": trigger,
|
||||||
"title": title,
|
"title": title,
|
||||||
"message": message,
|
"message": message,
|
||||||
"timestamp": datetime.now(timezone.utc).isoformat(),
|
"timestamp": datetime.now(UTC).isoformat(),
|
||||||
"source": "obsigate-notify",
|
"source": "obsigate-notify",
|
||||||
},
|
},
|
||||||
timeout=10.0,
|
timeout=10.0,
|
||||||
@@ -345,6 +345,6 @@ def _mark_sent(channel_id: str, error: str | None) -> None:
|
|||||||
channels = _read_channels()
|
channels = _read_channels()
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
if channel.get("id") == channel_id:
|
if channel.get("id") == channel_id:
|
||||||
channel["last_sent_at"] = datetime.now(timezone.utc).isoformat()
|
channel["last_sent_at"] = datetime.now(UTC).isoformat()
|
||||||
channel["last_error"] = error
|
channel["last_error"] = error
|
||||||
_write_channels(channels)
|
_write_channels(channels)
|
||||||
|
|||||||
Reference in New Issue
Block a user