Migrate to Postgresql for better network handling. Add more user functionality.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
class Api::EventsController < ApplicationController
|
||||
skip_before_action :verify_authenticity_token
|
||||
allow_unauthenticated_access # Skip normal session auth, use DSN auth instead
|
||||
|
||||
# POST /api/:project_id/events
|
||||
def create
|
||||
@@ -27,8 +28,8 @@ class Api::EventsController < ApplicationController
|
||||
response.headers['X-Sample-Rate'] = current_sampling[:allowed_requests].to_s
|
||||
response.headers['X-Sample-Until'] = current_sampling[:effective_until]
|
||||
|
||||
# Check if agent sent a rule version to compare against
|
||||
client_version = request.headers['X-Rule-Version']&.to_i
|
||||
# Check if agent sent a rule version in the JSON body to compare against
|
||||
client_version = event_data.dig('last_rule_sync')&.to_i
|
||||
|
||||
response_data = {
|
||||
success: true,
|
||||
@@ -40,8 +41,7 @@ class Api::EventsController < ApplicationController
|
||||
if client_version.blank? || client_version != rule_version
|
||||
# Get rules updated since client version
|
||||
if client_version.present?
|
||||
since_time = Time.at(client_version / 1_000_000, client_version % 1_000_000)
|
||||
rules = Rule.where("updated_at > ?", since_time).enabled.sync_order
|
||||
rules = Rule.since(client_version).enabled
|
||||
else
|
||||
# Full sync for new agents
|
||||
rules = Rule.active.sync_order
|
||||
|
||||
Reference in New Issue
Block a user