mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 12:08:00 +01:00
Code cleanup
This commit is contained in:
parent
2c144c14a3
commit
5e21a74346
22 changed files with 6 additions and 139 deletions
|
@ -21,8 +21,8 @@ metadata: post_search_json
|
||||||
'body', p.body,
|
'body', p.body,
|
||||||
'subject', t.title,
|
'subject', t.title,
|
||||||
'ip', p.ip,
|
'ip', p.ip,
|
||||||
'user_agent', p.user_agent,
|
'user_agent', '',
|
||||||
'referrer', p.referrer,
|
'referrer', '',
|
||||||
'fingerprint', p.fingerprint,
|
'fingerprint', p.fingerprint,
|
||||||
'topic_position', p.topic_position,
|
'topic_position', p.topic_position,
|
||||||
'forum', f.short_name,
|
'forum', f.short_name,
|
||||||
|
|
|
@ -13,8 +13,6 @@ defmodule Philomena.ArtistLinks.ArtistLink do
|
||||||
|
|
||||||
field :aasm_state, :string, default: "unverified"
|
field :aasm_state, :string, default: "unverified"
|
||||||
field :uri, :string
|
field :uri, :string
|
||||||
field :hostname, :string
|
|
||||||
field :path, :string
|
|
||||||
field :verification_code, :string
|
field :verification_code, :string
|
||||||
field :public, :boolean, default: true
|
field :public, :boolean, default: true
|
||||||
field :next_check_at, :utc_datetime
|
field :next_check_at, :utc_datetime
|
||||||
|
|
|
@ -12,7 +12,6 @@ defmodule Philomena.Channels.Channel do
|
||||||
|
|
||||||
field :short_name, :string
|
field :short_name, :string
|
||||||
field :title, :string, default: ""
|
field :title, :string, default: ""
|
||||||
field :tags, :string
|
|
||||||
field :viewers, :integer, default: 0
|
field :viewers, :integer, default: 0
|
||||||
field :nsfw, :boolean, default: false
|
field :nsfw, :boolean, default: false
|
||||||
field :is_live, :boolean, default: false
|
field :is_live, :boolean, default: false
|
||||||
|
@ -20,16 +19,6 @@ defmodule Philomena.Channels.Channel do
|
||||||
field :next_check_at, :utc_datetime
|
field :next_check_at, :utc_datetime
|
||||||
field :last_live_at, :utc_datetime
|
field :last_live_at, :utc_datetime
|
||||||
|
|
||||||
field :viewer_minutes_today, :integer, default: 0
|
|
||||||
field :viewer_minutes_thisweek, :integer, default: 0
|
|
||||||
field :viewer_minutes_thismonth, :integer, default: 0
|
|
||||||
field :total_viewer_minutes, :integer, default: 0
|
|
||||||
|
|
||||||
field :banner_image, :string
|
|
||||||
field :channel_image, :string
|
|
||||||
field :remote_stream_id, :integer
|
|
||||||
field :thumbnail_url, :string, default: ""
|
|
||||||
|
|
||||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,15 +14,12 @@ defmodule Philomena.Comments.Comment do
|
||||||
field :body, :string
|
field :body, :string
|
||||||
field :ip, EctoNetwork.INET
|
field :ip, EctoNetwork.INET
|
||||||
field :fingerprint, :string
|
field :fingerprint, :string
|
||||||
field :user_agent, :string, default: ""
|
|
||||||
field :referrer, :string, default: ""
|
|
||||||
field :anonymous, :boolean, default: false
|
field :anonymous, :boolean, default: false
|
||||||
field :hidden_from_users, :boolean, default: false
|
field :hidden_from_users, :boolean, default: false
|
||||||
field :edit_reason, :string
|
field :edit_reason, :string
|
||||||
field :edited_at, :utc_datetime
|
field :edited_at, :utc_datetime
|
||||||
field :deletion_reason, :string, default: ""
|
field :deletion_reason, :string, default: ""
|
||||||
field :destroyed_content, :boolean, default: false
|
field :destroyed_content, :boolean, default: false
|
||||||
field :name_at_post_time, :string
|
|
||||||
field :approved, :boolean
|
field :approved, :boolean
|
||||||
|
|
||||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||||
|
@ -35,7 +32,6 @@ defmodule Philomena.Comments.Comment do
|
||||||
|> validate_required([:body])
|
|> validate_required([:body])
|
||||||
|> validate_length(:body, min: 1, max: 300_000, count: :bytes)
|
|> validate_length(:body, min: 1, max: 300_000, count: :bytes)
|
||||||
|> change(attribution)
|
|> change(attribution)
|
||||||
|> put_name_at_post_time(attribution[:user])
|
|
||||||
|> Approval.maybe_put_approval(attribution[:user])
|
|> Approval.maybe_put_approval(attribution[:user])
|
||||||
|> Approval.maybe_strip_images(attribution[:user])
|
|> Approval.maybe_strip_images(attribution[:user])
|
||||||
end
|
end
|
||||||
|
@ -74,7 +70,4 @@ defmodule Philomena.Comments.Comment do
|
||||||
change(comment)
|
change(comment)
|
||||||
|> put_change(:approved, true)
|
|> put_change(:approved, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp put_name_at_post_time(changeset, nil), do: changeset
|
|
||||||
defp put_name_at_post_time(changeset, user), do: change(changeset, name_at_post_time: user.name)
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -94,11 +94,6 @@ defmodule Philomena.Images do
|
||||||
|
|
||||||
Multi.new()
|
Multi.new()
|
||||||
|> Multi.insert(:image, image)
|
|> Multi.insert(:image, image)
|
||||||
|> Multi.run(:name_caches, fn repo, %{image: image} ->
|
|
||||||
image
|
|
||||||
|> Image.cache_changeset()
|
|
||||||
|> repo.update()
|
|
||||||
end)
|
|
||||||
|> Multi.run(:added_tag_count, fn repo, %{image: image} ->
|
|> Multi.run(:added_tag_count, fn repo, %{image: image} ->
|
||||||
tag_ids = image.added_tags |> Enum.map(& &1.id)
|
tag_ids = image.added_tags |> Enum.map(& &1.id)
|
||||||
tags = Tag |> where([t], t.id in ^tag_ids)
|
tags = Tag |> where([t], t.id in ^tag_ids)
|
||||||
|
@ -384,8 +379,6 @@ defmodule Philomena.Images do
|
||||||
updated_at: now,
|
updated_at: now,
|
||||||
ip: attribution[:ip],
|
ip: attribution[:ip],
|
||||||
fingerprint: attribution[:fingerprint],
|
fingerprint: attribution[:fingerprint],
|
||||||
user_agent: attribution[:user_agent],
|
|
||||||
referrer: attribution[:referrer],
|
|
||||||
added: added
|
added: added
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -521,8 +514,6 @@ defmodule Philomena.Images do
|
||||||
tag_name_cache: tag.name,
|
tag_name_cache: tag.name,
|
||||||
ip: attribution[:ip],
|
ip: attribution[:ip],
|
||||||
fingerprint: attribution[:fingerprint],
|
fingerprint: attribution[:fingerprint],
|
||||||
user_agent: attribution[:user_agent],
|
|
||||||
referrer: attribution[:referrer],
|
|
||||||
added: added
|
added: added
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,6 @@ defmodule Philomena.Images.Image do
|
||||||
use Ecto.Schema
|
use Ecto.Schema
|
||||||
|
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
import Ecto.Query
|
|
||||||
|
|
||||||
alias Philomena.ImageIntensities.ImageIntensity
|
alias Philomena.ImageIntensities.ImageIntensity
|
||||||
alias Philomena.ImageVotes.ImageVote
|
alias Philomena.ImageVotes.ImageVote
|
||||||
|
@ -59,14 +58,11 @@ defmodule Philomena.Images.Image do
|
||||||
field :image_is_animated, :boolean, source: :is_animated
|
field :image_is_animated, :boolean, source: :is_animated
|
||||||
field :ip, EctoNetwork.INET
|
field :ip, EctoNetwork.INET
|
||||||
field :fingerprint, :string
|
field :fingerprint, :string
|
||||||
field :user_agent, :string, default: ""
|
|
||||||
field :referrer, :string, default: ""
|
|
||||||
field :anonymous, :boolean, default: false
|
field :anonymous, :boolean, default: false
|
||||||
field :score, :integer, default: 0
|
field :score, :integer, default: 0
|
||||||
field :faves_count, :integer, default: 0
|
field :faves_count, :integer, default: 0
|
||||||
field :upvotes_count, :integer, default: 0
|
field :upvotes_count, :integer, default: 0
|
||||||
field :downvotes_count, :integer, default: 0
|
field :downvotes_count, :integer, default: 0
|
||||||
field :votes_count, :integer, default: 0
|
|
||||||
field :source_url, :string
|
field :source_url, :string
|
||||||
field :description, :string, default: ""
|
field :description, :string, default: ""
|
||||||
field :image_sha512_hash, :string
|
field :image_sha512_hash, :string
|
||||||
|
@ -88,11 +84,6 @@ defmodule Philomena.Images.Image do
|
||||||
field :hides_count, :integer, default: 0
|
field :hides_count, :integer, default: 0
|
||||||
field :approved, :boolean
|
field :approved, :boolean
|
||||||
|
|
||||||
# todo: can probably remove these now
|
|
||||||
field :tag_list_cache, :string
|
|
||||||
field :tag_list_plus_alias_cache, :string
|
|
||||||
field :file_name_cache, :string
|
|
||||||
|
|
||||||
field :removed_tags, {:array, :any}, default: [], virtual: true
|
field :removed_tags, {:array, :any}, default: [], virtual: true
|
||||||
field :added_tags, {:array, :any}, default: [], virtual: true
|
field :added_tags, {:array, :any}, default: [], virtual: true
|
||||||
field :removed_sources, {:array, :any}, default: [], virtual: true
|
field :removed_sources, {:array, :any}, default: [], virtual: true
|
||||||
|
@ -228,7 +219,6 @@ defmodule Philomena.Images.Image do
|
||||||
|> cast(attrs, [])
|
|> cast(attrs, [])
|
||||||
|> TagDiffer.diff_input(old_tags, new_tags, excluded_tags)
|
|> TagDiffer.diff_input(old_tags, new_tags, excluded_tags)
|
||||||
|> TagValidator.validate_tags()
|
|> TagValidator.validate_tags()
|
||||||
|> cache_changeset()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def locked_tags_changeset(image, attrs, locked_tags) do
|
def locked_tags_changeset(image, attrs, locked_tags) do
|
||||||
|
@ -345,53 +335,6 @@ defmodule Philomena.Images.Image do
|
||||||
|> put_change(:first_seen_at, DateTime.utc_now(:second))
|
|> put_change(:first_seen_at, DateTime.utc_now(:second))
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_changeset(image) do
|
|
||||||
changeset = change(image)
|
|
||||||
image = apply_changes(changeset)
|
|
||||||
|
|
||||||
{tag_list_cache, tag_list_plus_alias_cache, file_name_cache} =
|
|
||||||
create_caches(image.id, image.tags)
|
|
||||||
|
|
||||||
changeset
|
|
||||||
|> put_change(:tag_list_cache, tag_list_cache)
|
|
||||||
|> put_change(:tag_list_plus_alias_cache, tag_list_plus_alias_cache)
|
|
||||||
|> put_change(:file_name_cache, file_name_cache)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp create_caches(image_id, tags) do
|
|
||||||
tags = Tag.display_order(tags)
|
|
||||||
|
|
||||||
tag_list_cache =
|
|
||||||
tags
|
|
||||||
|> Enum.map_join(", ", & &1.name)
|
|
||||||
|
|
||||||
tag_ids = tags |> Enum.map(& &1.id)
|
|
||||||
|
|
||||||
aliases =
|
|
||||||
Tag
|
|
||||||
|> where([t], t.aliased_tag_id in ^tag_ids)
|
|
||||||
|> Repo.all()
|
|
||||||
|
|
||||||
tag_list_plus_alias_cache =
|
|
||||||
(tags ++ aliases)
|
|
||||||
|> Tag.display_order()
|
|
||||||
|> Enum.map_join(", ", & &1.name)
|
|
||||||
|
|
||||||
# Truncate filename to 150 characters, making room for the path + filename on Windows
|
|
||||||
# https://stackoverflow.com/questions/265769/maximum-filename-length-in-ntfs-windows-xp-and-windows-vista
|
|
||||||
file_name_slug_fragment =
|
|
||||||
tags
|
|
||||||
|> Enum.map_join("_", & &1.slug)
|
|
||||||
|> String.to_charlist()
|
|
||||||
|> Enum.filter(&(&1 in ?a..?z or &1 in ~c"0123456789_-"))
|
|
||||||
|> List.to_string()
|
|
||||||
|> String.slice(0..150)
|
|
||||||
|
|
||||||
file_name_cache = "#{image_id}__#{file_name_slug_fragment}"
|
|
||||||
|
|
||||||
{tag_list_cache, tag_list_plus_alias_cache, file_name_cache}
|
|
||||||
end
|
|
||||||
|
|
||||||
defp create_key do
|
defp create_key do
|
||||||
Base.encode16(:crypto.strong_rand_bytes(6), case: :lower)
|
Base.encode16(:crypto.strong_rand_bytes(6), case: :lower)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,20 +3,16 @@ defmodule Philomena.Polls.Poll do
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
|
|
||||||
alias Philomena.Topics.Topic
|
alias Philomena.Topics.Topic
|
||||||
alias Philomena.Users.User
|
|
||||||
alias Philomena.PollOptions.PollOption
|
alias Philomena.PollOptions.PollOption
|
||||||
|
|
||||||
schema "polls" do
|
schema "polls" do
|
||||||
belongs_to :topic, Topic
|
belongs_to :topic, Topic
|
||||||
belongs_to :deleted_by, User
|
|
||||||
has_many :options, PollOption
|
has_many :options, PollOption
|
||||||
|
|
||||||
field :title, :string
|
field :title, :string
|
||||||
field :vote_method, :string
|
field :vote_method, :string
|
||||||
field :active_until, PhilomenaQuery.Ecto.RelativeDate
|
field :active_until, PhilomenaQuery.Ecto.RelativeDate
|
||||||
field :total_votes, :integer, default: 0
|
field :total_votes, :integer, default: 0
|
||||||
field :hidden_from_users, :boolean, default: false
|
|
||||||
field :deletion_reason, :string, default: ""
|
|
||||||
|
|
||||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,15 +15,12 @@ defmodule Philomena.Posts.Post do
|
||||||
field :edit_reason, :string
|
field :edit_reason, :string
|
||||||
field :ip, EctoNetwork.INET
|
field :ip, EctoNetwork.INET
|
||||||
field :fingerprint, :string
|
field :fingerprint, :string
|
||||||
field :user_agent, :string, default: ""
|
|
||||||
field :referrer, :string, default: ""
|
|
||||||
field :topic_position, :integer
|
field :topic_position, :integer
|
||||||
field :hidden_from_users, :boolean, default: false
|
field :hidden_from_users, :boolean, default: false
|
||||||
field :anonymous, :boolean, default: false
|
field :anonymous, :boolean, default: false
|
||||||
field :edited_at, :utc_datetime
|
field :edited_at, :utc_datetime
|
||||||
field :deletion_reason, :string, default: ""
|
field :deletion_reason, :string, default: ""
|
||||||
field :destroyed_content, :boolean, default: false
|
field :destroyed_content, :boolean, default: false
|
||||||
field :name_at_post_time, :string
|
|
||||||
field :approved, :boolean, default: false
|
field :approved, :boolean, default: false
|
||||||
|
|
||||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||||
|
@ -47,7 +44,6 @@ defmodule Philomena.Posts.Post do
|
||||||
|> validate_required([:body])
|
|> validate_required([:body])
|
||||||
|> validate_length(:body, min: 1, max: 300_000, count: :bytes)
|
|> validate_length(:body, min: 1, max: 300_000, count: :bytes)
|
||||||
|> change(attribution)
|
|> change(attribution)
|
||||||
|> put_name_at_post_time(attribution[:user])
|
|
||||||
|> Approval.maybe_put_approval(attribution[:user])
|
|> Approval.maybe_put_approval(attribution[:user])
|
||||||
|> Approval.maybe_strip_images(attribution[:user])
|
|> Approval.maybe_strip_images(attribution[:user])
|
||||||
end
|
end
|
||||||
|
@ -61,7 +57,6 @@ defmodule Philomena.Posts.Post do
|
||||||
|> validate_length(:body, min: 1, max: 300_000, count: :bytes)
|
|> validate_length(:body, min: 1, max: 300_000, count: :bytes)
|
||||||
|> change(attribution)
|
|> change(attribution)
|
||||||
|> change(topic_position: 0)
|
|> change(topic_position: 0)
|
||||||
|> put_name_at_post_time(attribution[:user])
|
|
||||||
|> Approval.maybe_put_approval(attribution[:user])
|
|> Approval.maybe_put_approval(attribution[:user])
|
||||||
|> Approval.maybe_strip_images(attribution[:user])
|
|> Approval.maybe_strip_images(attribution[:user])
|
||||||
end
|
end
|
||||||
|
@ -90,7 +85,4 @@ defmodule Philomena.Posts.Post do
|
||||||
change(post)
|
change(post)
|
||||||
|> put_change(:approved, true)
|
|> put_change(:approved, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp put_name_at_post_time(changeset, nil), do: changeset
|
|
||||||
defp put_name_at_post_time(changeset, user), do: change(changeset, name_at_post_time: user.name)
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,8 +52,8 @@ defmodule Philomena.Posts.SearchIndex do
|
||||||
author: if(!!post.user and !post.anonymous, do: String.downcase(post.user.name)),
|
author: if(!!post.user and !post.anonymous, do: String.downcase(post.user.name)),
|
||||||
subject: post.topic.title,
|
subject: post.topic.title,
|
||||||
ip: post.ip |> to_string(),
|
ip: post.ip |> to_string(),
|
||||||
user_agent: post.user_agent,
|
user_agent: "",
|
||||||
referrer: post.referrer,
|
referrer: "",
|
||||||
fingerprint: post.fingerprint,
|
fingerprint: post.fingerprint,
|
||||||
topic_position: post.topic_position,
|
topic_position: post.topic_position,
|
||||||
forum: post.topic.forum.short_name,
|
forum: post.topic.forum.short_name,
|
||||||
|
|
|
@ -139,9 +139,7 @@ defmodule Philomena.Reports do
|
||||||
attributes = %{
|
attributes = %{
|
||||||
system: true,
|
system: true,
|
||||||
ip: %Postgrex.INET{address: {127, 0, 0, 1}, netmask: 32},
|
ip: %Postgrex.INET{address: {127, 0, 0, 1}, netmask: 32},
|
||||||
fingerprint: "ffff",
|
fingerprint: "ffff"
|
||||||
user_agent:
|
|
||||||
"Mozilla/5.0 (X11; Philomena; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%Report{reportable_type: reportable_type, reportable_id: reportable_id}
|
%Report{reportable_type: reportable_type, reportable_id: reportable_id}
|
||||||
|
|
|
@ -10,8 +10,6 @@ defmodule Philomena.Reports.Report do
|
||||||
|
|
||||||
field :ip, EctoNetwork.INET
|
field :ip, EctoNetwork.INET
|
||||||
field :fingerprint, :string
|
field :fingerprint, :string
|
||||||
field :user_agent, :string, default: ""
|
|
||||||
field :referrer, :string, default: ""
|
|
||||||
field :reason, :string
|
field :reason, :string
|
||||||
field :state, :string, default: "open"
|
field :state, :string, default: "open"
|
||||||
field :open, :boolean, default: true
|
field :open, :boolean, default: true
|
||||||
|
@ -71,8 +69,7 @@ defmodule Philomena.Reports.Report do
|
||||||
:category,
|
:category,
|
||||||
:reason,
|
:reason,
|
||||||
:ip,
|
:ip,
|
||||||
:fingerprint,
|
:fingerprint
|
||||||
:user_agent
|
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,7 @@ defmodule Philomena.Roles.Role do
|
||||||
|
|
||||||
schema "roles" do
|
schema "roles" do
|
||||||
field :name, :string
|
field :name, :string
|
||||||
|
|
||||||
# fixme: rails polymorphic relation
|
|
||||||
field :resource_id, :integer
|
|
||||||
field :resource_type, :string
|
field :resource_type, :string
|
||||||
|
|
||||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc false
|
@doc false
|
||||||
|
|
|
@ -8,8 +8,6 @@ defmodule Philomena.SourceChanges.SourceChange do
|
||||||
|
|
||||||
field :ip, EctoNetwork.INET
|
field :ip, EctoNetwork.INET
|
||||||
field :fingerprint, :string
|
field :fingerprint, :string
|
||||||
field :user_agent, :string, default: ""
|
|
||||||
field :referrer, :string, default: ""
|
|
||||||
field :value, :string
|
field :value, :string
|
||||||
field :added, :boolean
|
field :added, :boolean
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,6 @@ defmodule Philomena.TagChanges.TagChange do
|
||||||
|
|
||||||
field :ip, EctoNetwork.INET
|
field :ip, EctoNetwork.INET
|
||||||
field :fingerprint, :string
|
field :fingerprint, :string
|
||||||
field :user_agent, :string, default: ""
|
|
||||||
field :referrer, :string, default: ""
|
|
||||||
field :added, :boolean
|
field :added, :boolean
|
||||||
field :tag_name_cache, :string, default: ""
|
field :tag_name_cache, :string, default: ""
|
||||||
|
|
||||||
|
|
|
@ -116,8 +116,6 @@ defmodule Philomena.Users.Eraser do
|
||||||
user: user,
|
user: user,
|
||||||
ip: @wipe_ip,
|
ip: @wipe_ip,
|
||||||
fingerprint: @wipe_fp,
|
fingerprint: @wipe_fp,
|
||||||
user_agent: "",
|
|
||||||
referrer: ""
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{:ok, _} = Images.update_sources(source_change.image, attribution, attrs)
|
{:ok, _} = Images.update_sources(source_change.image, attribution, attrs)
|
||||||
|
|
|
@ -109,7 +109,6 @@ defmodule Philomena.Users.User do
|
||||||
field :watched_tag_list, :string, virtual: true
|
field :watched_tag_list, :string, virtual: true
|
||||||
|
|
||||||
# Other stuff
|
# Other stuff
|
||||||
field :last_donation_at, :utc_datetime
|
|
||||||
field :last_renamed_at, :utc_datetime
|
field :last_renamed_at, :utc_datetime
|
||||||
field :deleted_at, :utc_datetime
|
field :deleted_at, :utc_datetime
|
||||||
field :scratchpad, :string
|
field :scratchpad, :string
|
||||||
|
|
|
@ -37,8 +37,6 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do
|
||||||
attributes = %{
|
attributes = %{
|
||||||
ip: attributes[:ip],
|
ip: attributes[:ip],
|
||||||
fingerprint: attributes[:fingerprint],
|
fingerprint: attributes[:fingerprint],
|
||||||
user_agent: attributes[:user_agent],
|
|
||||||
referrer: attributes[:referrer],
|
|
||||||
user_id: attributes[:user].id
|
user_id: attributes[:user].id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,6 @@ defmodule PhilomenaWeb.TagChange.FullRevertController do
|
||||||
attributes = %{
|
attributes = %{
|
||||||
ip: to_string(attributes[:ip]),
|
ip: to_string(attributes[:ip]),
|
||||||
fingerprint: attributes[:fingerprint],
|
fingerprint: attributes[:fingerprint],
|
||||||
referrer: attributes[:referrer],
|
|
||||||
user_agent: attributes[:referrer],
|
|
||||||
user_id: attributes[:user].id,
|
user_id: attributes[:user].id,
|
||||||
batch_size: attributes[:batch_size] || 100
|
batch_size: attributes[:batch_size] || 100
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,6 @@ defmodule PhilomenaWeb.TagChange.RevertController do
|
||||||
attributes = %{
|
attributes = %{
|
||||||
ip: attributes[:ip],
|
ip: attributes[:ip],
|
||||||
fingerprint: attributes[:fingerprint],
|
fingerprint: attributes[:fingerprint],
|
||||||
referrer: attributes[:referrer],
|
|
||||||
user_agent: attributes[:referrer],
|
|
||||||
user_id: attributes[:user].id
|
user_id: attributes[:user].id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,7 @@ defmodule PhilomenaWeb.UserAttributionPlug do
|
||||||
attributes = [
|
attributes = [
|
||||||
ip: remote_ip,
|
ip: remote_ip,
|
||||||
fingerprint: fingerprint(conn, conn.path_info),
|
fingerprint: fingerprint(conn, conn.path_info),
|
||||||
referrer: referrer(conn.assigns.referrer),
|
|
||||||
user: user,
|
user: user,
|
||||||
user_agent: user_agent(conn)
|
|
||||||
]
|
]
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|
@ -47,7 +45,4 @@ defmodule PhilomenaWeb.UserAttributionPlug do
|
||||||
defp fingerprint(conn, _) do
|
defp fingerprint(conn, _) do
|
||||||
conn.cookies["_ses"]
|
conn.cookies["_ses"]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp referrer(nil), do: nil
|
|
||||||
defp referrer(r), do: String.slice(r, 0, 255)
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,11 +23,6 @@ article.block.communication
|
||||||
=> link_to_ip @conn, @report.ip
|
=> link_to_ip @conn, @report.ip
|
||||||
=> link_to_fingerprint @conn, @report.fingerprint
|
=> link_to_fingerprint @conn, @report.fingerprint
|
||||||
|
|
||||||
div
|
|
||||||
' User-Agent:
|
|
||||||
code
|
|
||||||
= @report.user_agent
|
|
||||||
|
|
||||||
= if assigns[:mod_notes] do
|
= if assigns[:mod_notes] do
|
||||||
h4 Mod Notes
|
h4 Mod Notes
|
||||||
= render PhilomenaWeb.Admin.ModNoteView, "_table.html", mod_notes: @mod_notes, conn: @conn
|
= render PhilomenaWeb.Admin.ModNoteView, "_table.html", mod_notes: @mod_notes, conn: @conn
|
||||||
|
|
|
@ -40,8 +40,6 @@ pleb = Repo.get_by!(User, name: "Pleb")
|
||||||
request_attributes = [
|
request_attributes = [
|
||||||
fingerprint: "c1836832948",
|
fingerprint: "c1836832948",
|
||||||
ip: ip,
|
ip: ip,
|
||||||
user_agent: "Hopefully not IE",
|
|
||||||
referrer: "localhost",
|
|
||||||
user_id: pleb.id,
|
user_id: pleb.id,
|
||||||
user: pleb
|
user: pleb
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue