Migrate to Postgresql for better network handling. Add more user functionality.
This commit is contained in:
@@ -7,6 +7,7 @@ module Api
|
||||
# These endpoints are kept for administrative/debugging purposes only
|
||||
|
||||
skip_before_action :verify_authenticity_token
|
||||
allow_unauthenticated_access # Skip normal session auth, use project key auth instead
|
||||
before_action :authenticate_project!
|
||||
before_action :check_project_enabled
|
||||
|
||||
@@ -23,8 +24,8 @@ module Api
|
||||
}
|
||||
end
|
||||
|
||||
# GET /api/:public_key/rules?since=1730646186272060
|
||||
# Incremental sync - returns rules updated since timestamp (microsecond Unix timestamp)
|
||||
# GET /api/:public_key/rules?since=1730646186
|
||||
# Incremental sync - returns rules updated since timestamp (Unix timestamp in seconds)
|
||||
# GET /api/:public_key/rules
|
||||
# Full sync - returns all active rules
|
||||
def index
|
||||
@@ -69,17 +70,14 @@ module Api
|
||||
end
|
||||
|
||||
def parse_timestamp(timestamp_str)
|
||||
# Parse microsecond Unix timestamp
|
||||
# Parse Unix timestamp in seconds
|
||||
unless timestamp_str.match?(/^\d+$/)
|
||||
raise ArgumentError, "Invalid timestamp format. Expected microsecond Unix timestamp (e.g., 1730646186272060)"
|
||||
raise ArgumentError, "Invalid timestamp format. Expected Unix timestamp in seconds (e.g., 1730646186)"
|
||||
end
|
||||
|
||||
total_microseconds = timestamp_str.to_i
|
||||
seconds = total_microseconds / 1_000_000
|
||||
microseconds = total_microseconds % 1_000_000
|
||||
Time.at(seconds, microseconds)
|
||||
Time.at(timestamp_str.to_i)
|
||||
rescue ArgumentError => e
|
||||
raise ArgumentError, "Invalid timestamp format: #{e.message}. Use microsecond Unix timestamp (e.g., 1730646186272060)"
|
||||
raise ArgumentError, "Invalid timestamp format: #{e.message}. Use Unix timestamp in seconds (e.g., 1730646186)"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user