diff --git a/pkg/integrations/discord/send-chat.go b/pkg/integrations/discord/send-chat.go index f3e499a0..4e6024df 100644 --- a/pkg/integrations/discord/send-chat.go +++ b/pkg/integrations/discord/send-chat.go @@ -51,7 +51,7 @@ func SendChat(ctx context.Context, w *discordtypes.Webhook, did string, scm *pla return fmt.Errorf("failed to marshal payload: %w", err) } - log.Warn(ctx, "sending chat to discord", "payload", string(jsonPayload)) + log.Warn(ctx, "sending chat to discord", "payload", string(jsonPayload), "webhook_url", w.URL) req, err := http.NewRequestWithContext(ctx, "POST", w.URL, bytes.NewReader(jsonPayload)) if err != nil { @@ -71,10 +71,9 @@ func SendChat(ctx context.Context, w *discordtypes.Webhook, did string, scm *pla } if resp.StatusCode != 204 { + log.Error(ctx, "chat webhook delivery failed", "webhook_url", w.URL, "status_code", resp.StatusCode, "response_body", string(body)) return fmt.Errorf("failed to send chat to discord: %s", string(body)) } - log.Warn(ctx, "chat sent to discord", "payload", string(body)) - return nil } diff --git a/pkg/integrations/discord/send-livestream.go b/pkg/integrations/discord/send-livestream.go index c7819dcb..c4119393 100644 --- a/pkg/integrations/discord/send-livestream.go +++ b/pkg/integrations/discord/send-livestream.go @@ -93,7 +93,7 @@ func SendLivestream(ctx context.Context, w *discordtypes.Webhook, pdsURL string, return fmt.Errorf("failed to marshal payload: %w", err) } - log.Warn(ctx, "sending livestream to discord", "payload", string(jsonPayload)) + log.Warn(ctx, "sending livestream to discord", "payload", string(jsonPayload), "webhook_url", w.URL) req, err := http.NewRequestWithContext(ctx, "POST", w.URL, bytes.NewReader(jsonPayload)) if err != nil { @@ -112,6 +112,7 @@ func SendLivestream(ctx context.Context, w *discordtypes.Webhook, pdsURL string, if err != nil { return fmt.Errorf("failed to read response body: %w", err) } + log.Error(ctx, "livestream webhook delivery failed", "webhook_url", w.URL, "status_code", resp.StatusCode, "response_body", string(body)) return fmt.Errorf("failed to send request (http %d): %s", resp.StatusCode, string(body)) } diff --git a/pkg/integrations/discord/send-stream-received.go b/pkg/integrations/discord/send-stream-received.go index d12f4599..f22c42af 100644 --- a/pkg/integrations/discord/send-stream-received.go +++ b/pkg/integrations/discord/send-stream-received.go @@ -11,6 +11,7 @@ import ( "stream.place/streamplace/pkg/aqhttp" "stream.place/streamplace/pkg/integrations/discord/discordtypes" + "stream.place/streamplace/pkg/log" ) func SendStreamReceived(ctx context.Context, w *discordtypes.Webhook, streamerDID string) error { @@ -28,6 +29,8 @@ func SendStreamReceived(ctx context.Context, w *discordtypes.Webhook, streamerDI return fmt.Errorf("failed to marshal payload: %w", err) } + log.Log(ctx, "sending stream.received to discord", "streamerDID", streamerDID, "webhook_url", w.URL) + req, err := http.NewRequestWithContext(ctx, "POST", w.URL, bytes.NewReader(jsonPayload)) if err != nil { return fmt.Errorf("failed to create request: %w", err) @@ -45,6 +48,7 @@ func SendStreamReceived(ctx context.Context, w *discordtypes.Webhook, streamerDI if err != nil { return fmt.Errorf("failed to read response body: %w", err) } + log.Error(ctx, "stream.received webhook delivery failed", "webhook_url", w.URL, "status_code", resp.StatusCode, "response_body", string(body)) return fmt.Errorf("failed to send request (http %d): %s", resp.StatusCode, string(body)) } diff --git a/pkg/spxrpc/webhook.go b/pkg/spxrpc/webhook.go index f6ac245a..895875e9 100644 --- a/pkg/spxrpc/webhook.go +++ b/pkg/spxrpc/webhook.go @@ -44,7 +44,7 @@ func (s *Server) handlePlaceStreamServerCreateWebhook(ctx context.Context, input // Create webhook err = s.statefulDB.CreateWebhook(webhook) if err != nil { - log.Error(ctx, "failed to create webhook", "err", err) + log.Error(ctx, "failed to create webhook in database", "err", err, "url", input.Url, "events", input.Events) return nil, echo.NewHTTPError(http.StatusInternalServerError, "Failed to create webhook") } @@ -83,9 +83,12 @@ func (s *Server) handlePlaceStreamServerListWebhooks(ctx context.Context, active } // Build filters + // active defaults to true (show all active webhooks). When the client + // explicitly passes active=false, we filter to show inactive webhooks. + // When active=true, we show only active webhooks. filters := make(map[string]interface{}) - if !active { - filters["active"] = active + if active { + filters["active"] = true } // Get webhooks diff --git a/pkg/statedb/webhook.go b/pkg/statedb/webhook.go index a65d9c43..b74df539 100644 --- a/pkg/statedb/webhook.go +++ b/pkg/statedb/webhook.go @@ -225,19 +225,12 @@ func (w *Webhook) ToLexicon() (placestream.ServerDefs_Webhook, error) { // FromLexiconInput converts a placestream.ServerCreateWebhook_Input to a database Webhook func WebhookFromLexiconInput(input placestream.ServerCreateWebhook_Input, userDID, id string) (*Webhook, error) { - // Debug log the raw input - fmt.Printf("DEBUG: WebhookFromLexiconInput input.Events: %+v (type: %T)\n", input.Events, input.Events) - for i, event := range input.Events { - fmt.Printf("DEBUG: Event[%d]: %q (type: %T)\n", i, event, event) - } - var eventsJSON json.RawMessage if len(input.Events) > 0 { jsonBytes, err := json.Marshal(input.Events) if err != nil { return nil, fmt.Errorf("failed to marshal events: %w", err) } - fmt.Printf("DEBUG: Marshaled events JSON: %q\n", string(jsonBytes)) eventsJSON = json.RawMessage(jsonBytes) } else { // Default to empty array if no events provided