Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEOPLE: Webhooks für Update, Create #1796

Open
mtnstar opened this issue Jul 25, 2022 · 0 comments
Open

PEOPLE: Webhooks für Update, Create #1796

mtnstar opened this issue Jul 25, 2022 · 0 comments

Comments

@mtnstar
Copy link
Member

mtnstar commented Jul 25, 2022

Basierend auf der Idee von #1133 soll eine erste Basis für Webhooks realisiert werden:

  • Ausführung der Webhook erfolgt asynchron über einen WebhookExecutionJob
  • Logging erfolgt über das Hitobito Log TECH: Generisches Hitobito Log #1840
  • Webhooks können vorerst noch nicht übers UI verwaltet werden sondern werden direkt via rails console auf der gewünschten Umgebung manuell erfasst oder ggf. via Wagon geseedet (disabled: true)
  • Für die Ausführung eines Webhooks wird ein WebHookCall entry erzeugt
    • Dieser Entry hängt an einem WebHook Entry
    • Das Feld body enthält den fertig gerenderten Body
    • Nachdem der WebHook erfolgreich abgesetzt wurde, wird der Eintrag aus der DB gelöscht
    • Die Ausführung des Webhooks erfolgt über den WebhookExecutionJob
    • Falls die Ausführung fehlschlägt, wird der Eintrag nicht gelöscht und erhält den Status :error

Tech-Spec

  • Neues Model WebHook

    • name, string, null: false
    • target_url: string, null: false
    • http_action: get, post, ... null: false
    • http_headers, String, null: true
    • secret_http_headers, String, null: true, verschlüsselt in db
    • type: String, STI für Custom Webhook Erweiterung
    • model_type: String, vorerst nur Person, null: false
    • model_actions: String, update, create, ... mehrere möglich
    • body_serializer_class: String, null: false
    • disabled, boolean, default: false
    • debug, boolean, default: false, wenn true, wird der komplette Requests und die Response in den Hitobito Log Entry geschrieben
  • Neuer Job: WebhookExecutionJob

    • Recurring Job
    • Prüft 1x pro Minute ob ein pending WebHookCall vorhanden ist
    • Führt pending WebHookCalls aus und Logged diese entsprechend bzw. updatet den Status oder löscht die Einträge nach erfolgreichem Ausführen
  • Sicherstellen das konfigurierte Webhooks bei Person #update, #create getriggert werden

  • Ausführung des WebhookExectionJob wird im neuen Hitobito Log aufgezeichnet

  • Neues Model WebHookCall

    • body: string, null: false
    • webhook_id: int, null: false, belongs_to: webhook
    • status: int, null: false, [:pending, :error]
    • timestamps
  • Für etwas Inspiration: https://www.johnnunemaker.com/webhooks/

ToDo

  • [ ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant