Fix #416 - Generate random unique 14-byte (19 characters) shortcodes
for local attachments, use them in URLs. Check status privacy before redirecting to actual file.
This commit is contained in:
parent
9f21eb6064
commit
7b9f8766e8
4 changed files with 37 additions and 2 deletions
|
@ -0,0 +1,14 @@
|
|||
class AddShortcodeToMediaAttachments < ActiveRecord::Migration[5.0]
|
||||
def up
|
||||
add_column :media_attachments, :shortcode, :string, null: true, default: nil
|
||||
add_index :media_attachments, :shortcode, unique: true
|
||||
|
||||
# Migrate old links
|
||||
MediaAttachment.local.update_all('shortcode = id')
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :media_attachments, :shortcode
|
||||
remove_column :media_attachments, :shortcode
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20161222204147) do
|
||||
ActiveRecord::Schema.define(version: 20170105224407) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -95,6 +95,8 @@ ActiveRecord::Schema.define(version: 20161222204147) do
|
|||
t.integer "account_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "shortcode"
|
||||
t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true, using: :btree
|
||||
t.index ["status_id"], name: "index_media_attachments_on_status_id", using: :btree
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue