From 9c1efbf0473342571f1d47cb1c3dbf87d6b8866c Mon Sep 17 00:00:00 2001 From: miteruzo Date: Mon, 7 Jul 2025 08:28:51 +0900 Subject: [PATCH] #12 --- backend/app/controllers/preview_controller.rb | 2 +- backend/app/controllers/users_controller.rb | 7 ++++ backend/db/schema.rb | 36 +++++++++++++++++-- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/backend/app/controllers/preview_controller.rb b/backend/app/controllers/preview_controller.rb index 0c80354..f823228 100644 --- a/backend/app/controllers/preview_controller.rb +++ b/backend/app/controllers/preview_controller.rb @@ -20,7 +20,7 @@ class PreviewController < ApplicationController return head :unauthorized unless current_user url = params[:url] - return head :bad_request unless url.present? + return head :bad_request if url.blank? path = Rails.root.join('tmp', "thumb_#{ SecureRandom.hex }.png") system("node #{ Rails.root }/lib/screenshot.js #{ Shellwords.escape(url) } #{ path }") diff --git a/backend/app/controllers/users_controller.rb b/backend/app/controllers/users_controller.rb index 35b9160..1cecf50 100644 --- a/backend/app/controllers/users_controller.rb +++ b/backend/app/controllers/users_controller.rb @@ -14,6 +14,13 @@ class UsersController < ApplicationController end end + def renew + user = current_user + user.inheritance_code = SecureRandom.uuid + user.save! + render json: { code: user.inheritance_code } + end + def me user = User.find_by(inheritance_code: params[:code]) render(if user diff --git a/backend/db/schema.rb b/backend/db/schema.rb index c05d7ec..fb6ae14 100644 --- a/backend/db/schema.rb +++ b/backend/db/schema.rb @@ -10,7 +10,35 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_02_27_214100) do +ActiveRecord::Schema[8.0].define(version: 2025_06_29_140234) do + create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "name", null: false + t.string "record_type", null: false + t.bigint "record_id", null: false + t.bigint "blob_id", null: false + t.datetime "created_at", null: false + t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" + t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true + end + + create_table "active_storage_blobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "key", null: false + t.string "filename", null: false + t.string "content_type" + t.text "metadata" + t.string "service_name", null: false + t.bigint "byte_size", null: false + t.string "checksum" + t.datetime "created_at", null: false + t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true + end + + create_table "active_storage_variant_records", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.bigint "blob_id", null: false + t.string "variation_digest", null: false + t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true + end + create_table "ip_addresses", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.binary "ip_adress", limit: 16, null: false t.boolean "banned", default: false, null: false @@ -41,8 +69,8 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_27_214100) do end create_table "posts", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "title", null: false t.string "url", limit: 2000, null: false - t.string "thumbnail", null: false t.string "thumbnail_base", limit: 2000, null: false t.bigint "parent_id" t.bigint "uploaded_user_id" @@ -74,6 +102,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_27_214100) do t.string "category", default: "general", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.integer "post_count", default: 0, null: false end create_table "user_ips", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| @@ -88,7 +117,6 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_27_214100) do create_table "user_post_views", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.bigint "user_id", null: false t.bigint "post_id", null: false - t.boolean "viewed", default: false, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["post_id"], name: "index_user_post_views_on_post_id" @@ -116,6 +144,8 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_27_214100) do t.index ["updated_user_id"], name: "index_wiki_pages_on_updated_user_id" end + add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" + add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "nico_tag_relations", "tags" add_foreign_key "nico_tag_relations", "tags", column: "nico_tag_id" add_foreign_key "post_tags", "posts"