Remove IpAddress model.
This commit is contained in:
@@ -4,8 +4,8 @@ class IpAddressesController < ApplicationController
|
|||||||
respond_to :html, :xml, :json
|
respond_to :html, :xml, :json
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@ip_address = authorize IpAddress.new(ip_addr: params[:id])
|
@ip_address = authorize Danbooru::IpAddress.new(params[:id]), policy_class: IpAddressPolicy
|
||||||
@ip_info = @ip_address.ip_addr.ip_info
|
@ip_info = @ip_address.ip_info
|
||||||
respond_with(@ip_info)
|
respond_with(@ip_info)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class BigqueryExportService
|
|||||||
Rails.application.eager_load!
|
Rails.application.eager_load!
|
||||||
|
|
||||||
models = ApplicationRecord.descendants.sort_by(&:name)
|
models = ApplicationRecord.descendants.sort_by(&:name)
|
||||||
models -= [GoodJob::BaseRecord, GoodJob::Process, GoodJob::Execution, GoodJob::ActiveJobJob, GoodJob::Job, GoodJob::Setting, IpAddress, TagRelationship, ArtistVersion, ArtistCommentaryVersion, NoteVersion, PoolVersion, PostVersion, WikiPageVersion, Post, PostVote, MediaAsset, Favorite, AITag]
|
models -= [GoodJob::BaseRecord, GoodJob::Process, GoodJob::Execution, GoodJob::ActiveJobJob, GoodJob::Job, GoodJob::Setting, TagRelationship, ArtistVersion, ArtistCommentaryVersion, NoteVersion, PoolVersion, PostVersion, WikiPageVersion, Post, PostVote, MediaAsset, Favorite, AITag]
|
||||||
models
|
models
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class IpAddress < ApplicationRecord
|
|
||||||
belongs_to :model, polymorphic: true
|
|
||||||
belongs_to :user
|
|
||||||
attribute :ip_addr, :ip_address
|
|
||||||
|
|
||||||
def self.model_types
|
|
||||||
%w[Post User Comment Dmail ArtistVersion ArtistCommentaryVersion NoteVersion WikiPageVersion]
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.visible(user)
|
|
||||||
user.is_admin? ? all : where.not(model_type: "Dmail")
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.search(params)
|
|
||||||
q = search_attributes(params, :ip_addr, :user, :model)
|
|
||||||
q.order(created_at: :desc)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.group_by_ip_addr(ipv4_masklen = nil, ipv6_masklen = nil)
|
|
||||||
ipv4_masklen ||= 32
|
|
||||||
ipv6_masklen ||= 128
|
|
||||||
|
|
||||||
q = select(sanitize_sql([<<~SQL.squish, ipv4_masklen, ipv6_masklen]))
|
|
||||||
CASE
|
|
||||||
WHEN family(ip_addr) = 4
|
|
||||||
THEN network(set_masklen(ip_addr, ?))
|
|
||||||
ELSE network(set_masklen(ip_addr, ?))
|
|
||||||
END AS ip_addr,
|
|
||||||
COUNT(*) AS count_all
|
|
||||||
SQL
|
|
||||||
|
|
||||||
q.group("1").reorder("count_all DESC, ip_addr")
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.group_by_user
|
|
||||||
group(:user_id).select("user_id, COUNT(*) AS count_all").reorder("count_all DESC, user_id")
|
|
||||||
end
|
|
||||||
|
|
||||||
def lookup
|
|
||||||
@lookup ||= ip_addr.ip_lookup
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_s
|
|
||||||
ip_addr.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
def readonly?
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.available_includes
|
|
||||||
[:user, :model]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -28,10 +28,10 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Proxy?</th>
|
<th>Proxy?</th>
|
||||||
<td><%= ip_address.ip_addr.is_proxy? ? "Yes" : "No" %></td>
|
<td><%= ip_address.is_proxy? ? "Yes" : "No" %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% if ip_address.ip_addr.is_tor? %>
|
<% if ip_address.is_tor? %>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Tor?</th>
|
<th>Tor?</th>
|
||||||
<td>Yes</td>
|
<td>Yes</td>
|
||||||
@@ -41,8 +41,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>IP Banned?</th>
|
<th>IP Banned?</th>
|
||||||
<td>
|
<td>
|
||||||
<% if IpBan.ip_matches(ip_address.ip_addr.to_s).exists? %>
|
<% if IpBan.ip_matches(ip_address.to_s).exists? %>
|
||||||
Yes (<%= link_to "info", ip_bans_path(search: { ip_addr: ip_address.ip_addr.to_s }) %>)
|
Yes (<%= link_to "info", ip_bans_path(search: { ip_addr: ip_address.to_s }) %>)
|
||||||
<% else %>
|
<% else %>
|
||||||
No
|
No
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
<th>Details</th>
|
<th>Details</th>
|
||||||
<td>
|
<td>
|
||||||
<details>
|
<details>
|
||||||
<pre><%= JSON.pretty_generate(ip_address.lookup.response) %></pre>
|
<pre><%= JSON.pretty_generate(ip_address.ip_lookup.response) %></pre>
|
||||||
</details>
|
</details>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<div id="c-ip-addresses">
|
<div id="c-ip-addresses">
|
||||||
<div id="a-show">
|
<div id="a-show">
|
||||||
<h1>IP Address: <%= @ip_address.ip_addr %></h1>
|
<h1>IP Address: <%= @ip_address %></h1>
|
||||||
|
|
||||||
<%= render "info", ip_address: @ip_address, ip_info: @ip_info %>
|
<%= render "info", ip_address: @ip_address, ip_info: @ip_info %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if policy(IpAddress).show? %>
|
<% if policy(:ip_address).show? %>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Last IP</th>
|
<th>Last IP</th>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<% t.column "Name", td: { class: "col-expand" } do |user| %>
|
<% t.column "Name", td: { class: "col-expand" } do |user| %>
|
||||||
<%= link_to_user user %>
|
<%= link_to_user user %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if policy(IpAddress).show? %>
|
<% if policy(:ip_address).show? %>
|
||||||
<% t.column "IP" do |user| %>
|
<% t.column "IP" do |user| %>
|
||||||
<% if user.last_ip_addr.present? %>
|
<% if user.last_ip_addr.present? %>
|
||||||
<%= link_to user.last_ip_addr, ip_address_path(user.last_ip_addr) %>
|
<%= link_to user.last_ip_addr, ip_address_path(user.last_ip_addr) %>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
<div class="user-tooltip-header-bottom">
|
<div class="user-tooltip-header-bottom">
|
||||||
<%= time_tag @user.created_at.to_date.iso8601, @user.created_at, class: "user-tooltip-created-at" %>
|
<%= time_tag @user.created_at.to_date.iso8601, @user.created_at, class: "user-tooltip-created-at" %>
|
||||||
<% if @user.last_ip_addr.present? && policy(IpAddress).show? %>
|
<% if @user.last_ip_addr.present? && policy(:ip_address).show? %>
|
||||||
· <%= link_to_ip @user.last_ip_addr, shorten: true, class: "link-plain" %>
|
· <%= link_to_ip @user.last_ip_addr, shorten: true, class: "link-plain" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user