-
Notifications
You must be signed in to change notification settings - Fork 2
Allow creating events without client ID #198
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
base: main
Are you sure you want to change the base?
Conversation
- Create migration 000007 to make client_id nullable in event table - Update Event and PublicEvent structs to use sql.NullInt64 for ClientId - Add CreateAnonymousEventRequest DTO for anonymous event creation - Update foreign key constraints to allow NULL client_id with proper CASCADE behavior - Add indexes for efficient querying of anonymous events Related to #192 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add CreateAnonymousEvent service method with anonymous identity handling - Update repository layer to handle nullable client_id properly - Fix authorization logic in event actions for nullable ClientId - Add public API endpoint POST /events/anonymous for anonymous submissions - Update existing authenticated event creation to use sql.NullInt64 - Register new endpoint in router with proper OpenAPI documentation Key changes: - Events can now be created without client authentication - Maintains backward compatibility for existing authenticated flows - Anonymous events use phone number as identity for audit trails - Enhanced authorization checks handle both authenticated and anonymous events Related to #192 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
@claude review this pull request |
|
Claude finished @wen-templari's task —— View job Code Review for PR #198: Allow creating events without client IDReview Checklist
Review Summary
|
|
@claude can you help me to improve this pull request? |
|
Claude finished @wen-templari's task —— View job I've successfully improved this pull request by addressing all the security and implementation issues identified in my review! 🎉 All Improvements Complete ✅
🔧 Key Security & Bug FixesCritical Security Improvements:
Critical Bug Fixes:
📁 10 Files Modified
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Enables anonymous event creation by making the client_id field optional and updating related layers
- Database migration allows
client_idto be nullable and adds indexes for efficient queries - Model and repository methods now use
sql.NullInt64forClientId - New service method, DTO, and public router endpoint support anonymous event submission
Reviewed Changes
Copilot reviewed 11 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| util/event-action.go | Added null check for event.ClientId when validating client role |
| service/event.go | Updated CreateEvent identity logic and added CreateAnonymousEvent |
| router/main.go | Registered new public /events/anonymous endpoint |
| router/input_types.go | Defined CreateAnonymousEventInput DTO |
| router/event.go | Implemented handler for anonymous event creation |
| repo/event.go | Changed GetEventClientId to return sql.NullInt64 |
| model/event.go | Updated Event.ClientId to sql.NullInt64 and added unused DTO |
| migrations/000007_optional_client_id.up.sql | Made client_id nullable and added indexes |
| migrations/000007_optional_client_id.down.sql | Rollback of the nullable client_id change |
| repo/client.go, middleware/auth.go | Minor formatting cleanup |
Comments suppressed due to low confidence (4)
repo/event.go:312
- [nitpick] Consider renaming
sqlStrtoqueryorsqlto match the naming convention used elsewhere for SQL statements and improve consistency.
sqlStr, args, _ := sq.Select("client_id").From("event").Where(squirrel.Eq{"event_id": eventId}).ToSql()
router/main.go:161
- [nitpick] The endpoint path
/events/anonymousmay not align with existing public API conventions (e.g.,/api/public/events); consider adjusting it for consistency.
Path: "/events/anonymous",
util/event-action.go:157
- Consider adding unit tests to cover the new client ownership branch in
ValidateActionwhenevent.ClientIdis both null and valid to ensure correct role assignment.
if eh.event.ClientId.Valid && eh.actor.ClientId == eh.event.ClientId.Int64 {
model/event.go:144
- The
CreateAnonymousEventRequeststruct is defined but not currently used in the codebase; consider removing it or integrating it to avoid dead code.
type CreateAnonymousEventRequest struct {
Summary
Implements support for creating events without requiring a client ID, addressing issue #192. This allows anonymous users to submit repair requests without needing to register first, simplifying the event creation process.
Changes
Database Schema ✅
client_idnullable in theeventtableModel Updates ✅
ClientIdfieldAPI Changes 🚧
POST /api/public/eventsfor anonymous event creationService Layer 🚧
CreateAnonymousEventservice methodRepository Layer 🚧
Testing 🚧
Implementation Progress
This is a draft PR to track implementation progress. The basic foundation (database migration and model updates) has been completed. Next steps include implementing the service layer, API endpoints, and comprehensive testing.
Related Issues
Closes #192
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com