Skip to content

Commit

Permalink
update.
Browse files Browse the repository at this point in the history
  • Loading branch information
kehiy committed Jan 14, 2025
1 parent b9a6822 commit e8962ea
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion delivery/websocket/event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,35 @@ func (s *Server) handleEvent(conn *websocket.Conn, m message.Message) { //nolint
}

// you can only delete events you own.
deleteFilter.Authors = []string{msg.Event.PublicKey}
if len(deleteFilter.Authors) == 1 {
if deleteFilter.Authors[0] != msg.Event.PublicKey {
okm := message.MakeOK(false,
msg.Event.ID,
fmt.Sprintf(
"error: you can request to delete your events only: %s",
deleteFilter.Authors),
)

_ = conn.WriteMessage(1, okm)

status = invalidFail

return
}
} else {
okm := message.MakeOK(false,
msg.Event.ID,
fmt.Sprintf(
"error: you can request to delete your events only: %s",
deleteFilter.Authors),
)

_ = conn.WriteMessage(1, okm)

status = invalidFail

return
}

go s.handler.DeleteByFilter(deleteFilter) //nolint
}
Expand Down

0 comments on commit e8962ea

Please sign in to comment.