|
|
@ -402,13 +402,8 @@ class Attachment < ActiveRecord::Base
|
|
|
|
|
|
|
|
|
|
|
|
# Finds an attachment that matches the given token and that has no container
|
|
|
|
# Finds an attachment that matches the given token and that has no container
|
|
|
|
def self.find_by_token(token)
|
|
|
|
def self.find_by_token(token)
|
|
|
|
if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/
|
|
|
|
attachment = find_by_token_only(token)
|
|
|
|
attachment_id, attachment_digest = $1, $2
|
|
|
|
attachment if attachment.container.nil?
|
|
|
|
attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first
|
|
|
|
|
|
|
|
if attachment && attachment.container.nil?
|
|
|
|
|
|
|
|
attachment
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Finds an attachment that matches the given token
|
|
|
|
# Finds an attachment that matches the given token
|
|
|
@ -416,9 +411,6 @@ class Attachment < ActiveRecord::Base
|
|
|
|
if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/
|
|
|
|
if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/
|
|
|
|
attachment_id, attachment_digest = $1, $2
|
|
|
|
attachment_id, attachment_digest = $1, $2
|
|
|
|
attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first
|
|
|
|
attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first
|
|
|
|
if attachment
|
|
|
|
|
|
|
|
attachment
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|