mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-08-27 03:21:17 -04:00
6220b50946
- Bumped version from 1.3.0 to 1.3.1 in the manifest. - Removed deprecated issue comment events: issue_comment_created, issue_comment_edited, issue_comment_deleted. - Consolidated issue comment handling into a unified structure for better maintainability. - Updated README to reflect changes in event handling and provide clearer setup instructions.
30 lines
878 B
Python
30 lines
878 B
Python
from __future__ import annotations
|
|
|
|
from collections.abc import Mapping
|
|
from typing import Any
|
|
|
|
from werkzeug import Request
|
|
|
|
from dify_plugin.entities.trigger import Variables
|
|
from dify_plugin.errors.trigger import EventIgnoreError
|
|
from dify_plugin.interfaces.trigger import Event
|
|
|
|
|
|
class ForkEvent(Event):
|
|
"""Unified Fork event."""
|
|
|
|
def _on_event(self, request: Request, parameters: Mapping[str, Any]) -> Variables:
|
|
payload = request.get_json()
|
|
if not payload:
|
|
raise ValueError("No payload received")
|
|
|
|
forker = (payload.get("sender") or {}).get("login")
|
|
allowed = parameters.get("forker")
|
|
if allowed:
|
|
users = {u.strip() for u in str(allowed).split(",") if u.strip()}
|
|
if users and forker not in users:
|
|
raise EventIgnoreError()
|
|
|
|
return Variables(variables={**payload})
|
|
|