| @@ -111,7 +111,8 @@ class PostsController < ApplicationController | |||||
| original_created_before = params[:original_created_before] | original_created_before = params[:original_created_before] | ||||
| post = Post.find(params[:id].to_i) | post = Post.find(params[:id].to_i) | ||||
| tags = post.tags.where(category: 'nico').to_a + Tag.normalise_tags(tag_names) | |||||
| tags = post.tags.where(category: 'nico').to_a + | |||||
| Tag.normalise_tags(tag_names, with_tagme: false) | |||||
| tags = Tag.expand_parent_tags(tags) | tags = Tag.expand_parent_tags(tags) | ||||
| if post.update(title:, tags:, original_created_from:, original_created_before:) | if post.update(title:, tags:, original_created_from:, original_created_before:) | ||||
| render json: post.as_json(include: { tags: { only: [:id, :name, :category, :post_count] } }), | render json: post.as_json(include: { tags: { only: [:id, :name, :category, :post_count] } }), | ||||
| @@ -6,12 +6,15 @@ class UsersController < ApplicationController | |||||
| end | end | ||||
| def verify | def verify | ||||
| ip_bin = IPAddr.new(request.remote_ip).hton | |||||
| ip_address = IpAddress.find_or_create_by!(ip_address: ip_bin) | |||||
| user = User.find_by(inheritance_code: params[:code]) | user = User.find_by(inheritance_code: params[:code]) | ||||
| render json: if user | |||||
| { valid: true, user: user.slice(:id, :name, :inheritance_code, :role) } | |||||
| else | |||||
| { valid: false } | |||||
| end | |||||
| return render json: { valid: false } unless user | |||||
| UserIp.find_or_create_by!(user:, ip_address:) | |||||
| render json: { valid: true, user: user.slice(:id, :name, :inheritance_code, :role) } | |||||
| end | end | ||||
| def renew | def renew | ||||
| @@ -65,7 +65,7 @@ class Tag < ApplicationRecord | |||||
| end | end | ||||
| end | end | ||||
| end | end | ||||
| tags << Tag.tagme if with_tagme && tags.size < 20 && tags.none?(Tag.tagme) | |||||
| tags << Tag.tagme if with_tagme && tags.size < 10 && tags.none?(Tag.tagme) | |||||
| tags.uniq | tags.uniq | ||||
| end | end | ||||
| @@ -8,7 +8,6 @@ class User < ApplicationRecord | |||||
| has_many :posts | has_many :posts | ||||
| has_many :settings | has_many :settings | ||||
| has_many :ip_addresses | |||||
| has_many :user_ips, dependent: :destroy | has_many :user_ips, dependent: :destroy | ||||
| has_many :ip_addresses, through: :user_ips | has_many :ip_addresses, through: :user_ips | ||||
| has_many :user_post_views, dependent: :destroy | has_many :user_post_views, dependent: :destroy | ||||
| @@ -0,0 +1,5 @@ | |||||
| class RenameIpAdressColumnToIpAddresses < ActiveRecord::Migration[8.0] | |||||
| def change | |||||
| rename_column :ip_addresses, :ip_adress, :ip_address | |||||
| end | |||||
| end | |||||
| @@ -40,7 +40,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_10_09_222200) do | |||||
| end | end | ||||
| create_table "ip_addresses", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| | create_table "ip_addresses", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| | ||||
| t.binary "ip_adress", limit: 16, null: false | |||||
| t.binary "ip_address", limit: 16, null: false | |||||
| t.boolean "banned", default: false, null: false | t.boolean "banned", default: false, null: false | ||||
| t.datetime "created_at", null: false | t.datetime "created_at", null: false | ||||
| t.datetime "updated_at", null: false | t.datetime "updated_at", null: false | ||||
| @@ -70,9 +70,16 @@ ActiveRecord::Schema[8.0].define(version: 2025_10_09_222200) do | |||||
| t.bigint "deleted_user_id" | t.bigint "deleted_user_id" | ||||
| t.datetime "created_at", null: false | t.datetime "created_at", null: false | ||||
| t.datetime "updated_at", null: false | t.datetime "updated_at", null: false | ||||
| t.datetime "discarded_at" | |||||
| t.virtual "is_active", type: :boolean, as: "(`discarded_at` is null)", stored: true | |||||
| t.virtual "active_unique_key", type: :string, as: "(case when (`discarded_at` is null) then concat(`post_id`,_utf8mb4':',`tag_id`) else NULL end)", stored: true | |||||
| t.index ["active_unique_key"], name: "idx_post_tags_active_unique", unique: true | |||||
| t.index ["created_user_id"], name: "index_post_tags_on_created_user_id" | t.index ["created_user_id"], name: "index_post_tags_on_created_user_id" | ||||
| t.index ["deleted_user_id"], name: "index_post_tags_on_deleted_user_id" | t.index ["deleted_user_id"], name: "index_post_tags_on_deleted_user_id" | ||||
| t.index ["discarded_at"], name: "index_post_tags_on_discarded_at" | |||||
| t.index ["post_id", "discarded_at"], name: "index_post_tags_on_post_id_and_discarded_at" | |||||
| t.index ["post_id"], name: "index_post_tags_on_post_id" | t.index ["post_id"], name: "index_post_tags_on_post_id" | ||||
| t.index ["tag_id", "discarded_at"], name: "index_post_tags_on_tag_id_and_discarded_at" | |||||
| t.index ["tag_id"], name: "index_post_tags_on_tag_id" | t.index ["tag_id"], name: "index_post_tags_on_tag_id" | ||||
| end | end | ||||
| @@ -1,12 +0,0 @@ | |||||
| namespace :nico do | |||||
| desc 'ニコタグ連携' | |||||
| task link: :environment do | |||||
| Post.find_each do |post| | |||||
| tags = post.tags.where(category: 'nico') | |||||
| tags.each do |tag| | |||||
| post.tags.concat(tag.linked_tags) if tag.linked_tags.present? | |||||
| end | |||||
| post.tags = post.tags.to_a.uniq | |||||
| end | |||||
| end | |||||
| end | |||||
| @@ -51,7 +51,7 @@ namespace :nico do | |||||
| end | end | ||||
| tags_to_add.concat([tag] + tag.linked_tags) | tags_to_add.concat([tag] + tag.linked_tags) | ||||
| end | end | ||||
| tags_to_add << Tag.tagme if post.tags.size < 20 | |||||
| tags_to_add << Tag.tagme if post.tags.size < 10 | |||||
| tags_to_add << Tag.bot | tags_to_add << Tag.bot | ||||
| post.tags = (post.tags + tags_to_add).uniq | post.tags = (post.tags + tags_to_add).uniq | ||||
| end | end | ||||