Skip to content

Commit

Permalink
feat(webhook): add support for server_name field in WebhookEventInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
InfinityPacer committed Oct 10, 2024
1 parent d2a613a commit 828e9ab
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/api/endpoints/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def webhook_message(background_tasks: BackgroundTasks,
_: str = Depends(verify_apitoken)
) -> Any:
"""
Webhook响应,配置请求中需要添加参数:token=API_TOKEN&source=消息配置名
Webhook响应,配置请求中需要添加参数:token=API_TOKEN&source=媒体服务器名
"""
body = await request.body()
form = await request.form()
Expand All @@ -35,7 +35,7 @@ async def webhook_message(background_tasks: BackgroundTasks,
def webhook_message(background_tasks: BackgroundTasks,
request: Request, _: str = Depends(verify_apitoken)) -> Any:
"""
Webhook响应,配置请求中需要添加参数:token=API_TOKEN&source=消息配置名
Webhook响应,配置请求中需要添加参数:token=API_TOKEN&source=媒体服务器名
"""
args = request.query_params
background_tasks.add_task(start_webhook_chain, None, None, args)
Expand Down
5 changes: 4 additions & 1 deletion app/modules/emby/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ def webhook_parser(self, body: Any, form: Any, args: Any) -> Optional[schemas.We
server: Emby = self.get_instance(source)
if not server:
return None
return server.get_webhook_message(form, args)
result = server.get_webhook_message(form, args)
if result:
result.server_name = source
return result

for server in self.get_instances().values():
if server:
Expand Down
5 changes: 4 additions & 1 deletion app/modules/jellyfin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ def webhook_parser(self, body: Any, form: Any, args: Any) -> Optional[schemas.We
server: Jellyfin = self.get_instance(source)
if not server:
return None
return server.get_webhook_message(body)
result = server.get_webhook_message(body)
if result:
result.server_name = source
return result

for server in self.get_instances().values():
if server:
Expand Down
5 changes: 4 additions & 1 deletion app/modules/plex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ def webhook_parser(self, body: Any, form: Any, args: Any) -> Optional[schemas.We
server: Plex = self.get_instance(source)
if not server:
return None
return server.get_webhook_message(form)
result = server.get_webhook_message(form)
if result:
result.server_name = source
return result

for server in self.get_instances().values():
if server:
Expand Down
1 change: 1 addition & 0 deletions app/schemas/mediaserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class WebhookEventInfo(BaseModel):
"""
event: Optional[str] = None
channel: Optional[str] = None
server_name: Optional[str] = None
item_type: Optional[str] = None
item_name: Optional[str] = None
item_id: Optional[str] = None
Expand Down

0 comments on commit 828e9ab

Please sign in to comment.