forked from tildeverse/tilde.news
rubocop: Layout/MultilineOperationIndentation, 1208
This commit is contained in:
parent
738326d284
commit
a2288d8af9
|
@ -34,7 +34,8 @@ class CommentsController < ApplicationController
|
|||
|
||||
# prevent double-clicks of the post button
|
||||
if params[:preview].blank? &&
|
||||
(pc = Comment.where(:story_id => story.id, :user_id => @user.id,
|
||||
(pc = Comment.where(:story_id => story.id,
|
||||
:user_id => @user.id,
|
||||
:parent_comment_id => comment.parent_comment_id).first)
|
||||
if (Time.now - pc.created_at) < 5.minutes && !@user.is_moderator?
|
||||
comment.errors.add(:comment, "^You have already posted a comment " <<
|
||||
|
|
|
@ -13,8 +13,7 @@ class InvitationsController < ApplicationController
|
|||
|
||||
def index
|
||||
if !@user.can_see_invitation_requests?
|
||||
flash[:error] = "Your account is not permitted to view invitation " <<
|
||||
"requests."
|
||||
flash[:error] = "Your account is not permitted to view invitation requests."
|
||||
return redirect_to "/"
|
||||
end
|
||||
|
||||
|
|
|
@ -105,8 +105,7 @@ class LoginController < ApplicationController
|
|||
|
||||
@found_user.initiate_password_reset_for_ip(request.remote_ip)
|
||||
|
||||
flash.now[:success] = "Password reset instructions have been e-mailed " <<
|
||||
"to you."
|
||||
flash.now[:success] = "Password reset instructions have been e-mailed to you."
|
||||
return index
|
||||
end
|
||||
|
||||
|
|
|
@ -80,7 +80,9 @@ class SettingsController < ApplicationController
|
|||
|
||||
# no option for inline svg, so just strip off leading <?xml> tag
|
||||
qrcode = RQRCode::QRCode.new(totp_url)
|
||||
qr = qrcode.as_svg(offset: 0, color: "000", module_size: 5,
|
||||
qr = qrcode.as_svg(offset: 0,
|
||||
color: "000",
|
||||
module_size: 5,
|
||||
shape_rendering: "crispEdges").gsub(/^<\?xml.*>/, "")
|
||||
|
||||
@qr_svg = "<a href=\"#{totp_url}\">#{qr}</a>"
|
||||
|
@ -111,8 +113,7 @@ class SettingsController < ApplicationController
|
|||
|
||||
session[:u] = @user.session_token
|
||||
|
||||
flash[:success] = "Two-Factor Authentication has been enabled on " <<
|
||||
"your account."
|
||||
flash[:success] = "Two-Factor Authentication has been enabled on your account."
|
||||
session.delete(:totp_secret)
|
||||
return redirect_to "/settings"
|
||||
else
|
||||
|
@ -151,8 +152,7 @@ class SettingsController < ApplicationController
|
|||
end
|
||||
|
||||
if params[:rand].to_s != session[:pushover_rand].to_s
|
||||
raise "rand param #{params[:rand].inspect} != " <<
|
||||
session[:pushover_rand].inspect
|
||||
raise "rand param #{params[:rand].inspect} != #{session[:pushover_rand].inspect}"
|
||||
end
|
||||
|
||||
@user.pushover_user_key = params[:pushover_user_key].to_s
|
||||
|
@ -161,8 +161,7 @@ class SettingsController < ApplicationController
|
|||
if @user.pushover_user_key.present?
|
||||
flash[:success] = "Your account is now setup for Pushover notifications."
|
||||
else
|
||||
flash[:success] = "Your account is no longer setup for Pushover " <<
|
||||
"notifications."
|
||||
flash[:success] = "Your account is no longer setup for Pushover notifications."
|
||||
end
|
||||
|
||||
return redirect_to "/settings"
|
||||
|
@ -174,7 +173,8 @@ class SettingsController < ApplicationController
|
|||
end
|
||||
|
||||
def github_callback
|
||||
if !session[:github_state].present? || !params[:code].present? ||
|
||||
if !session[:github_state].present? ||
|
||||
!params[:code].present? ||
|
||||
(params[:state].to_s != session[:github_state].to_s)
|
||||
flash[:error] = "Invalid OAuth state"
|
||||
return redirect_to "/settings"
|
||||
|
@ -187,8 +187,7 @@ class SettingsController < ApplicationController
|
|||
@user.github_oauth_token = tok
|
||||
@user.github_username = username
|
||||
@user.save!
|
||||
flash[:success] = "Your account has been linked to GitHub user " <<
|
||||
"#{username}."
|
||||
flash[:success] = "Your account has been linked to GitHub user #{username}."
|
||||
else
|
||||
return github_disconnect
|
||||
end
|
||||
|
@ -210,7 +209,7 @@ class SettingsController < ApplicationController
|
|||
end
|
||||
|
||||
def twitter_callback
|
||||
if !session[:twitter_state].present? ||
|
||||
if session[:twitter_state].blank? ||
|
||||
(params[:state].to_s != session[:twitter_state].to_s)
|
||||
flash[:error] = "Invalid OAuth state"
|
||||
return redirect_to "/settings"
|
||||
|
@ -225,8 +224,7 @@ class SettingsController < ApplicationController
|
|||
@user.twitter_oauth_token_secret = sec
|
||||
@user.twitter_username = username
|
||||
@user.save!
|
||||
flash[:success] = "Your account has been linked to Twitter user @" <<
|
||||
"#{username}."
|
||||
flash[:success] = "Your account has been linked to Twitter user @#{username}."
|
||||
else
|
||||
return twitter_disconnect
|
||||
end
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class BanNotification < ActionMailer::Base
|
||||
default :from => "#{Rails.application.name} " <<
|
||||
"<nobody@#{Rails.application.domain}>"
|
||||
default :from => "#{Rails.application.name} <nobody@#{Rails.application.domain}>"
|
||||
|
||||
def notify(user, banner, reason)
|
||||
@banner = banner
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class EmailMessage < ActionMailer::Base
|
||||
default :from => "#{Rails.application.name} " <<
|
||||
"<nobody@#{Rails.application.domain}>"
|
||||
default :from => "#{Rails.application.name} <nobody@#{Rails.application.domain}>"
|
||||
|
||||
def notify(message, user)
|
||||
@message = message
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class EmailReply < ActionMailer::Base
|
||||
default :from => "#{Rails.application.name} " <<
|
||||
"<nobody@#{Rails.application.domain}>"
|
||||
default :from => "#{Rails.application.name} <nobody@#{Rails.application.domain}>"
|
||||
|
||||
def reply(comment, user)
|
||||
@comment = comment
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
class InvitationMailer < ActionMailer::Base
|
||||
default :from => "#{Rails.application.name} " <<
|
||||
"<nobody@#{Rails.application.domain}>"
|
||||
default :from => "#{Rails.application.name} <nobody@#{Rails.application.domain}>"
|
||||
|
||||
def invitation(invitation)
|
||||
@invitation = invitation
|
||||
|
||||
mail(
|
||||
to: invitation.email,
|
||||
subject: "[#{Rails.application.name}] You have been invited to " <<
|
||||
subject: "[#{Rails.application.name}] You are invited to join " <<
|
||||
Rails.application.name
|
||||
)
|
||||
end
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class InvitationRequestMailer < ActionMailer::Base
|
||||
default :from => "#{Rails.application.name} " <<
|
||||
"<nobody@#{Rails.application.domain}>"
|
||||
default :from => "#{Rails.application.name} <nobody@#{Rails.application.domain}>"
|
||||
|
||||
def invitation_request(invitation_request)
|
||||
@invitation_request = invitation_request
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class PasswordReset < ActionMailer::Base
|
||||
default :from => "#{Rails.application.name} " <<
|
||||
"<nobody@#{Rails.application.domain}>"
|
||||
default :from => "#{Rails.application.name} <nobody@#{Rails.application.domain}>"
|
||||
|
||||
def password_reset_link(user, ip)
|
||||
@user = user
|
||||
|
|
|
@ -75,7 +75,7 @@ class Comment < ActiveRecord::Base
|
|||
# from the tree. otherwise they have to stay and a "[deleted]" stub
|
||||
# will be shown
|
||||
if node.is_gone? && # deleted or moderated
|
||||
!children.present? && # don't have child comments
|
||||
children.empty? && # don't have child comments
|
||||
(!user || (!user.is_moderator? && node.user_id != user.id))
|
||||
# admins and authors should be able to see their deleted comments
|
||||
next
|
||||
|
@ -246,7 +246,8 @@ class Comment < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def deliver_reply_notifications
|
||||
if self.parent_comment_id && (u = self.parent_comment.try(:user)) &&
|
||||
if self.parent_comment_id &&
|
||||
(u = self.parent_comment.try(:user)) &&
|
||||
u.id != self.user.id
|
||||
if u.email_replies?
|
||||
begin
|
||||
|
|
|
@ -284,8 +284,7 @@ class Story < ActiveRecord::Base
|
|||
|
||||
self.taggings.each do |t|
|
||||
if !t.tag.valid_for?(u)
|
||||
raise "#{u.username} does not have permission to use privileged " <<
|
||||
"tag #{t.tag.tag}"
|
||||
raise "#{u.username} does not have permission to use privileged tag #{t.tag.tag}"
|
||||
elsif t.tag.inactive? && t.new_record? && !t.marked_for_destruction?
|
||||
# stories can have inactive tags as long as they existed before
|
||||
raise "#{u.username} cannot add inactive tag #{t.tag.tag}"
|
||||
|
@ -444,8 +443,7 @@ class Story < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def is_unavailable=(what)
|
||||
self.unavailable_at = (what.to_i == 1 && !self.is_unavailable ?
|
||||
Time.now : nil)
|
||||
self.unavailable_at = (what.to_i == 1 && !self.is_unavailable ? Time.now : nil)
|
||||
end
|
||||
|
||||
def is_undeletable_by_user?(user)
|
||||
|
@ -460,8 +458,7 @@ class Story < ActiveRecord::Base
|
|||
|
||||
def log_moderation
|
||||
if self.new_record? ||
|
||||
(!self.editing_from_suggestions &&
|
||||
(!self.editor || self.editor.id == self.user_id))
|
||||
(!self.editing_from_suggestions && (!self.editor || self.editor.id == self.user_id))
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -852,7 +849,8 @@ class Story < ActiveRecord::Base
|
|||
site_name = parsed.at_css("meta[property='og:site_name']")
|
||||
.attributes["content"].text
|
||||
|
||||
if site_name.present? && site_name.length < title.length &&
|
||||
if site_name.present? &&
|
||||
site_name.length < title.length &&
|
||||
title[-(site_name.length), site_name.length] == site_name
|
||||
title = title[0, title.length - site_name.length]
|
||||
|
||||
|
@ -869,8 +867,8 @@ class Story < ActiveRecord::Base
|
|||
# now get canonical version of url (though some cms software puts incorrect
|
||||
# urls here, hopefully the user will notice)
|
||||
begin
|
||||
if (cu = parsed.at_css("link[rel='canonical']").attributes["href"]
|
||||
.text).present? && (ucu = URI.parse(cu)) && ucu.scheme.present? &&
|
||||
if (cu = parsed.at_css("link[rel='canonical']").attributes["href"] .text).present? &&
|
||||
(ucu = URI.parse(cu)) && ucu.scheme.present? &&
|
||||
ucu.host.present?
|
||||
@fetched_attributes[:url] = cu
|
||||
end
|
||||
|
|
|
@ -83,8 +83,7 @@ class Sponge
|
|||
|
||||
# check for domain cookies
|
||||
@cookies.keys.each do |dom|
|
||||
if dom.length < host.length &&
|
||||
dom == host[host.length - dom.length .. host.length - 1]
|
||||
if dom.length < host.length && dom == host[host.length - dom.length .. host.length - 1]
|
||||
dputs "adding domain keys from #{dom}"
|
||||
cooks = cooks.merge @cookies[dom]
|
||||
end
|
||||
|
@ -178,8 +177,8 @@ class Sponge
|
|||
|
||||
path.gsub!(/^\/\//, "/")
|
||||
|
||||
dputs "fetching #{url} (#{ip.to_s}) " + (uri.user ? "with http auth " +
|
||||
uri.user + "/" + ("*" * uri.password.length) + " " : "") +
|
||||
dputs "fetching #{url} (#{ip.to_s}) " +
|
||||
(uri.user ? "with http auth " + uri.user + "/" + ("*" * uri.password.length) + " " : "") +
|
||||
"by #{method} with cookies #{cookies(uri.host)}"
|
||||
|
||||
send_headers = {
|
||||
|
@ -190,8 +189,7 @@ class Sponge
|
|||
}.merge(send_headers || {})
|
||||
|
||||
if uri.user
|
||||
send_headers["Authorization"] = "Basic " +
|
||||
["#{uri.user}:#{uri.password}"].pack('m').delete("\r\n")
|
||||
send_headers["Authorization"] = "Basic " + ["#{uri.user}:#{uri.password}"].pack('m').delete("\r\n")
|
||||
end
|
||||
|
||||
res = nil
|
||||
|
|
|
@ -16,8 +16,7 @@ class StoryCacher
|
|||
return nil
|
||||
end
|
||||
|
||||
db_url = "#{DIFFBOT_API_URL}?token=#{@@DIFFBOT_API_KEY}&url=" <<
|
||||
CGI.escape(story.url)
|
||||
db_url = "#{DIFFBOT_API_URL}?token=#{@@DIFFBOT_API_KEY}&url=#{CGI.escape(story.url)}"
|
||||
|
||||
begin
|
||||
s = Sponge.new
|
||||
|
|
|
@ -78,18 +78,15 @@ Story.where("id > ? AND is_expired = ?", last_story_id, false).order(:id).each d
|
|||
end
|
||||
|
||||
domain = Rails.application.domain
|
||||
list = "#{Rails.application.shortname}-#{u.mailing_list_token}@" <<
|
||||
Rails.application.domain
|
||||
list = "#{Rails.application.shortname}-#{u.mailing_list_token}@#{ails.application.domain}"
|
||||
|
||||
IO.popen([{}, "/usr/sbin/sendmail", "-i", "-f", "nobody@#{Rails.application.domain}", u.email], "w") do |mail|
|
||||
mail.puts "From: #{s.user.username} <#{s.user.username}@" <<
|
||||
"#{Rails.application.domain}>"
|
||||
mail.puts "From: #{s.user.username} <#{s.user.username}@#{Rails.application.domain}>"
|
||||
mail.puts "Reply-To: #{list}"
|
||||
mail.puts "To: #{list}"
|
||||
mail.puts "X-BeenThere: #{list}"
|
||||
mail.puts "List-Id: #{Rails.application.name} <#{list}>"
|
||||
mail.puts "List-Unsubscribe: <" <<
|
||||
"#{Rails.application.root_url}settings>"
|
||||
mail.puts "List-Unsubscribe: <#{Rails.application.root_url}settings>"
|
||||
mail.puts "Precedence: list"
|
||||
mail.puts "MIME-Version: 1.0"
|
||||
mail.puts "Content-Type: text/plain; charset=\"utf-8\""
|
||||
|
@ -160,8 +157,7 @@ last_comment_id, false, false).order(:id).each do |c|
|
|||
end
|
||||
|
||||
domain = Rails.application.domain
|
||||
list = "#{Rails.application.shortname}-#{u.mailing_list_token}@" <<
|
||||
Rails.application.domain
|
||||
list = "#{Rails.application.shortname}-#{u.mailing_list_token}@#{Rails.application.domain}"
|
||||
|
||||
IO.popen([{}, "/usr/sbin/sendmail", "-i", "-f", "nobody@#{domain}", u.email], "w") do |mail|
|
||||
from = "From: \"#{c.user.username}"
|
||||
|
@ -174,8 +170,7 @@ last_comment_id, false, false).order(:id).each do |c|
|
|||
mail.puts "Reply-To: #{list}"
|
||||
mail.puts "To: #{list}"
|
||||
mail.puts "List-Id: #{Rails.application.name} <#{list}>"
|
||||
mail.puts "List-Unsubscribe: <" <<
|
||||
"#{Rails.application.root_url}settings>"
|
||||
mail.puts "List-Unsubscribe: <#{Rails.application.root_url}settings>"
|
||||
mail.puts "Precedence: list"
|
||||
mail.puts "MIME-Version: 1.0"
|
||||
mail.puts "Content-Type: text/plain; charset=\"utf-8\""
|
||||
|
|
|
@ -24,17 +24,21 @@ StoriesPaginator.new(StoryRepository.new.hottest).get.first
|
|||
|
||||
via = ""
|
||||
if s.user.twitter_username.present?
|
||||
via = "\n" + (s.user_is_author? ? "by" : "via") +
|
||||
via = "\n" +
|
||||
(s.user_is_author? ? "by" : "via") +
|
||||
" @#{s.user.twitter_username}"
|
||||
end
|
||||
|
||||
tco_status = via + "\n" +
|
||||
tco_status = via +
|
||||
"\n" +
|
||||
("X" * Twitter::TCO_LEN) + tags +
|
||||
(s.url.present?? "\n" + ("X" * Twitter::TCO_LEN) : "")
|
||||
(s.url.present? ? "\n" + ("X" * Twitter::TCO_LEN) : "")
|
||||
|
||||
status = via + "\n" +
|
||||
s.short_id_url + tags +
|
||||
(s.url.present?? "\n" + s.url : "")
|
||||
status = via +
|
||||
"\n" +
|
||||
s.short_id_url +
|
||||
tags +
|
||||
(s.url.present? ? "\n" + s.url : "")
|
||||
|
||||
left_len = Twitter::MAX_TWEET_LEN - tco_status.length
|
||||
|
||||
|
@ -71,14 +75,12 @@ StoriesPaginator.new(StoryRepository.new.hottest).get.first
|
|||
elsif res["errors"].select {|e| e["code"] == 226 || e["code"] == 186 }.any?
|
||||
# twitter is rejecting the content of this message, skip it
|
||||
s.update_column("twitter_id", 0)
|
||||
puts "skipping: failed posting story #{s.id} (#{status.inspect}): " +
|
||||
"#{res.inspect}\n"
|
||||
puts "skipping: failed posting story #{s.id} (#{status.inspect}): #{res.inspect}\n"
|
||||
else
|
||||
raise
|
||||
end
|
||||
rescue => e
|
||||
puts "failed posting story #{s.id} (#{status.inspect}): #{e.inspect}\n" +
|
||||
"#{res.inspect}"
|
||||
puts "failed posting story #{s.id} (#{status.inspect}): #{e.inspect}\n#{res.inspect}"
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user