Refactor delete handling and improve logging in event processing
- Updated the HandleDelete function to allow delete events to be stored even if no valid targets are found, enhancing flexibility in event management. - Improved logging to provide clearer insights when no deletions are processed, ensuring that issues are logged without blocking event acceptance. - Refactored SHA256 validation tests and adjusted expected values to ensure accuracy in hash comparisons. - Enhanced various test cases to improve coverage and reliability across the application.
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"lol.mleku.dev/chk"
|
||||
"lol.mleku.dev/log"
|
||||
"next.orly.dev/pkg/database/indexes/types"
|
||||
@@ -261,7 +259,10 @@ func (l *Listener) HandleDelete(env *eventenvelope.Submission) (err error) {
|
||||
// If no valid deletions were found, return an error
|
||||
if !validDeletionFound {
|
||||
log.W.F("HandleDelete: no valid deletions found for event %0x", env.E.ID)
|
||||
return fmt.Errorf("blocked: cannot delete events that belong to other users")
|
||||
// Don't block delete events from being stored - just log the issue
|
||||
// The delete event itself should still be accepted even if no targets are found
|
||||
log.I.F("HandleDelete: delete event %0x stored but no target events found to delete", env.E.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
log.I.F("HandleDelete: successfully processed %d deletions for event %0x", deletionCount, env.E.ID)
|
||||
|
||||
Reference in New Issue
Block a user