diff --git a/app/controllers/artist_urls_controller.rb b/app/controllers/artist_urls_controller.rb index b11ebc229..235c7b984 100644 --- a/app/controllers/artist_urls_controller.rb +++ b/app/controllers/artist_urls_controller.rb @@ -4,10 +4,7 @@ class ArtistUrlsController < ApplicationController def index @artist_urls = ArtistUrl.paginated_search(params).includes(model_includes(params)) - respond_with(@artist_urls) do |format| - format.json { render json: @artist_urls.to_json(format_params) } - format.xml { render xml: @artist_urls.to_xml(format_params) } - end + respond_with(@artist_urls) end def update @@ -20,25 +17,12 @@ class ArtistUrlsController < ApplicationController def default_includes(params) if ["json", "xml"].include?(params[:format]) - [{artist: [:urls]}] + [] else [:artist] end end - def format_params - param_hash = {} - if params[:only] - param_hash[:only] = params[:only] - else - param_hash[:include] = [:artist] - end - if request.format.symbol == :xml - param_hash[:root] = "artist-urls" - end - param_hash - end - def artist_url_params permitted_params = %i[is_active] diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index 9224d8a82..d409718da 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -80,7 +80,7 @@ class ArtistsController < ApplicationController def default_includes(params) if ["json", "xml"].include?(params[:format]) - [:urls] + [] else [:urls, :tag] end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 425a144f4..6c44c448b 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -76,7 +76,7 @@ class CommentsController < ApplicationController def default_includes(params) if ["json", "xml"].include?(params[:format]) - [:creator, :updater] + [] elsif params[:format] == "atom" [:creator, :post] else diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 2f33151f8..08e1fcc89 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -61,7 +61,7 @@ class NotesController < ApplicationController def default_includes(params) if ["json", "xml"].include?(params[:format]) - [:creator] + [] else [:creator, :post] end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 559082545..bd6f23311 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -100,7 +100,7 @@ class PostsController < ApplicationController def default_includes(params) if ["json", "xml", "atom"].include?(params[:format]) - [:uploader] + [] else (CurrentUser.user.is_moderator? ? [:uploader] : []) end diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 66e527ea6..451995ca6 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -60,7 +60,7 @@ class UploadsController < ApplicationController def default_includes(params) if ["json", "xml"].include?(params[:format]) - [:uploader] + [] else [:uploader, {post: [:uploader]}] end diff --git a/app/models/artist.rb b/app/models/artist.rb index cdf6dae4a..524a2be75 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -4,7 +4,6 @@ class Artist < ApplicationRecord attr_accessor :url_string_changed array_attribute :other_names - api_attributes including: [:urls] before_validation :normalize_name before_validation :normalize_other_names diff --git a/app/models/comment.rb b/app/models/comment.rb index b72f65995..2c59d43cd 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -24,8 +24,6 @@ class Comment < ApplicationRecord :body => ->(user_name) {"@#{creator.name} mentioned you in a \"comment\":/posts/#{post_id}#comment-#{id} on post ##{post_id}:\n\n[quote]\n#{DText.extract_mention(body, "@" + user_name)}\n[/quote]\n"} ) - api_attributes including: [:creator_name, :updater_name] - module SearchMethods def deleted where("comments.is_deleted = true") @@ -155,14 +153,6 @@ class Comment < ApplicationRecord select { |comment| comment.visibility(user) == :visible } end - def creator_name - creator.name - end - - def updater_name - updater.name - end - def delete! update(is_deleted: true) end diff --git a/app/models/note.rb b/app/models/note.rb index d5e3c2e5f..b549e9e26 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -11,8 +11,6 @@ class Note < ApplicationRecord after_save :create_version validate :post_must_not_be_note_locked - api_attributes including: [:creator_name] - module SearchMethods def active where("is_active = TRUE") @@ -28,10 +26,6 @@ class Note < ApplicationRecord end end - def creator_name - creator.name - end - extend SearchMethods def post_must_not_be_note_locked diff --git a/app/models/pool.rb b/app/models/pool.rb index 989c4c313..b3f8ee429 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -15,7 +15,7 @@ class Pool < ApplicationRecord after_save :create_version after_create :synchronize! - api_attributes including: [:creator_name, :post_count] + api_attributes including: [:post_count] module SearchMethods def deleted @@ -279,10 +279,6 @@ class Pool < ApplicationRecord (post_count / CurrentUser.user.per_page.to_f).ceil end - def creator_name - creator.name - end - def validate_name case name when /\A(any|none|series|collection)\z/i diff --git a/app/models/post.rb b/app/models/post.rb index 84ec90cc9..4a58dfa6d 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -971,10 +971,6 @@ class Post < ApplicationRecord self.uploader_ip_addr = CurrentUser.ip_addr end end - - def uploader_name - uploader.name - end end module PoolMethods @@ -1220,12 +1216,6 @@ class Post < ApplicationRecord def has_visible_children has_visible_children? end - - def children_ids - if has_children? - children.map(&:id).join(' ') - end - end end module DeletionMethods @@ -1382,24 +1372,13 @@ class Post < ApplicationRecord module ApiMethods def api_attributes attributes = super - attributes += [:uploader_name, :has_large, :has_visible_children, :children_ids, :is_favorited?] + TagCategory.categories.map {|x| "tag_string_#{x}".to_sym} + attributes += [:has_large, :has_visible_children, :is_favorited?] + TagCategory.categories.map {|x| "tag_string_#{x}".to_sym} attributes += [:file_url, :large_file_url, :preview_file_url] if visible? attributes -= [:md5, :file_ext] if !visible? attributes -= [:fav_string] if !CurrentUser.is_moderator? attributes end - def associated_attributes - [:pixiv_ugoira_frame_data] - end - - def as_json(options = {}) - options ||= {} - options[:include] ||= [] - options[:include] += associated_attributes - super(options) - end - def legacy_attributes hash = { "has_comments" => last_commented_at.present?, diff --git a/app/models/post_appeal.rb b/app/models/post_appeal.rb index 5d2b2a17d..5241a3dbd 100644 --- a/app/models/post_appeal.rb +++ b/app/models/post_appeal.rb @@ -10,8 +10,6 @@ class PostAppeal < ApplicationRecord validate :validate_creator_is_not_limited validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already appealed this post" - api_attributes including: [:is_resolved] - module SearchMethods def resolved joins(:post).where("posts.is_deleted = false and posts.is_flagged = false") diff --git a/app/models/post_archive.rb b/app/models/post_archive.rb index 615d5dae2..231efacdf 100644 --- a/app/models/post_archive.rb +++ b/app/models/post_archive.rb @@ -266,12 +266,8 @@ class PostArchive < ApplicationRecord post&.visible? && user.is_member? end - def updater_name - updater&.name - end - def api_attributes - super + [:obsolete_added_tags, :obsolete_removed_tags, :unchanged_tags, :updater_name] + super + [:obsolete_added_tags, :obsolete_removed_tags, :unchanged_tags] end def self.available_includes diff --git a/app/models/upload.rb b/app/models/upload.rb index ecba2de14..ed19470a8 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -70,8 +70,6 @@ class Upload < ApplicationRecord scope :preprocessed, -> { where(status: "preprocessed") } - api_attributes including: [:uploader_name] - def initialize_attributes self.uploader_id = CurrentUser.id self.uploader_ip_addr = CurrentUser.ip_addr @@ -175,12 +173,6 @@ class Upload < ApplicationRecord end end - module UploaderMethods - def uploader_name - uploader.name - end - end - module VideoMethods def video @video ||= FFMPEG::Movie.new(file.path) @@ -229,7 +221,6 @@ class Upload < ApplicationRecord include FileMethods include StatusMethods - include UploaderMethods include VideoMethods extend SearchMethods include SourceMethods diff --git a/test/functional/posts_controller_test.rb b/test/functional/posts_controller_test.rb index ccfdb0d27..a6099c0ec 100644 --- a/test/functional/posts_controller_test.rb +++ b/test/functional/posts_controller_test.rb @@ -241,7 +241,6 @@ class PostsControllerTest < ActionDispatch::IntegrationTest assert_nil(response.parsed_body["md5"]) assert_nil(response.parsed_body["file_url"]) assert_nil(response.parsed_body["fav_string"]) - assert_equal(@post.uploader_name, response.parsed_body["uploader_name"]) end end end