Skip to content

feat: webhooks added#76

Open
muckmuck96 wants to merge 2 commits intonickheyer:mainfrom
muckmuck96:feature/webhooks
Open

feat: webhooks added#76
muckmuck96 wants to merge 2 commits intonickheyer:mainfrom
muckmuck96:feature/webhooks

Conversation

@muckmuck96
Copy link
Copy Markdown

@muckmuck96 muckmuck96 commented Mar 13, 2026

This PR adds webhooks which can be configured per server. It is possible to create generic or discord format ones.

Some looks

image image image

Copy link
Copy Markdown
Owner

@nickheyer nickheyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple comments and one discussion topic, we are nearly there! Sorry again for the wait, I promise ill follow up quickly.

Comment thread internal/module/events.go
}

// OnServerHealthy triggers MODULE_EVENT_TYPE_SERVER_HEALTHY for all modules
func (d *EventDispatcher) OnServerHealthy(ctx context.Context, serverID string) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you may have removed server event dispatching for OnServerHealthy, OnPlayerJoin, and OnPlayerLeave.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah my bad. It went off while I was cleaning some of my own stuff, I will revert that one.

<ServerTasks {server} active={activeTab === 'tasks'} />
</TabsContent>

<TabsContent value="webhooks" class="h-full overflow-y-auto">
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion started in discord, but just to review - it might be a good idea to merge tasks and webhooks, to avoid redundancy in functionality as they both operate similarly.

The easy implementation would be:
A Tasks tab, and in that tab's contents there would be the existing Scheduled Tasks table, as well as your Webhooks table.

Alternatively, a more difficult, but cleaner implementation could be:
A Tasks tab, but there would be a single tasks table.
Inside that table would be both Scheduled Tasks as well as Triggered Tasks (or Event Tasks or whatever we call it). This would mean Webhook becomes a task type, and instead of tasks being purely time based scheduling, they can also hook into events!


// UpdateWebhook updates an existing webhook
func (s *WebhookService) UpdateWebhook(ctx context.Context, req *connect.Request[v1.UpdateWebhookRequest]) (*connect.Response[v1.UpdateWebhookResponse], error) {
webhook, err := s.store.GetWebhook(ctx, req.Msg.Id)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following is more so a note to self, not part of your review:

So there might be a bug here, though it has nothing to do with your implementation, this one is on me. in connectrpc, "empty" means null or "zeroed" value. For update routes like this, its a bit tricky if you want to "unset" or clear an existing value - given that the pattern below and elsewhere is if req.Msg.FieldVal != nil { model.Field = req.Msg.FieldVal }

If your Secret is set in CreateWebhook, but you wanted to actually clear the secret, you'd set it to an empty string input, but that would translate to nil in this update fn.

}

// dispatchWebhook sends a webhook event
func (m *Manager) dispatchWebhook(ctx context.Context, serverID string, eventType storage.WebhookEventType, data map[string]interface{}) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but please change map[string]interface{} to map[string]any. All interface{} should be changed to any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants