首次提交by MimoCode
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import httpx
|
||||
from app.notifications.base import NotificationProvider
|
||||
from app.config import settings
|
||||
|
||||
|
||||
class PushPlusProvider(NotificationProvider):
|
||||
def __init__(self):
|
||||
self.token = settings.PUSHPLUS_TOKEN
|
||||
|
||||
def validate_config(self) -> bool:
|
||||
return bool(self.token)
|
||||
|
||||
async def send(self, title: str, content: str) -> bool:
|
||||
if not self.validate_config():
|
||||
return False
|
||||
|
||||
url = "https://www.pushplus.plus/send"
|
||||
data = {
|
||||
"token": self.token,
|
||||
"title": title,
|
||||
"content": content
|
||||
}
|
||||
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.post(url, json=data)
|
||||
result = response.json()
|
||||
return result.get("code") == 200
|
||||
Reference in New Issue
Block a user