Merge remote-tracking branch 'upstream/pull/2884'

This commit is contained in:
Tom Hughes 2020-10-15 08:12:21 +01:00
commit ad9f0b6247
37 changed files with 93 additions and 101 deletions

View file

@ -33,7 +33,7 @@ Lint/AssignmentInCondition:
- 'app/controllers/users_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/helpers/browse_tags_helper.rb'
- 'app/mailers/notifier.rb'
- 'app/mailers/user_mailer.rb'
- 'app/models/client_application.rb'
- 'lib/nominatim.rb'
- 'lib/osm.rb'
@ -149,14 +149,6 @@ Rails/HelperInstanceVariable:
Exclude:
- 'app/helpers/title_helper.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: app/mailers/**/*.rb
Rails/MailerName:
Exclude:
- 'app/mailers/notifier.rb'
# Offense count: 5
# Configuration parameters: Include.
# Include: db/migrate/*.rb

View file

@ -32,7 +32,7 @@ module Api
# Notify current subscribers of the new comment
changeset.subscribers.visible.each do |user|
Notifier.changeset_comment_notification(comment, user).deliver_later if current_user != user
UserMailer.changeset_comment_notification(comment, user).deliver_later if current_user != user
end
# Add the commenter to the subscribers if necessary

View file

@ -381,7 +381,7 @@ module Api
comment = note.comments.create!(attributes)
note.comments.map(&:author).uniq.each do |user|
Notifier.note_comment_notification(comment, user).deliver_later if notify && user && user != current_user && user.visible?
UserMailer.note_comment_notification(comment, user).deliver_later if notify && user && user != current_user && user.visible?
end
end
end

View file

@ -81,7 +81,7 @@ class DiaryEntriesController < ApplicationController
# Notify current subscribers of the new comment
@entry.subscribers.visible.each do |user|
Notifier.diary_comment_notification(@diary_comment, user).deliver_later if current_user != user
UserMailer.diary_comment_notification(@diary_comment, user).deliver_later if current_user != user
end
# Add the commenter to the subscribers if necessary

View file

@ -21,7 +21,7 @@ class FriendshipsController < ApplicationController
flash[:warning] = t "friendships.make_friend.already_a_friend", :name => @new_friend.display_name
elsif friendship.save
flash[:notice] = t "friendships.make_friend.success", :name => @new_friend.display_name
Notifier.friendship_notification(friendship).deliver_later
UserMailer.friendship_notification(friendship).deliver_later
else
friendship.add_error(t("friendships.make_friend.failed", :name => @new_friend.display_name))
end

View file

@ -31,7 +31,7 @@ class MessagesController < ApplicationController
render :action => "new"
elsif @message.save
flash[:notice] = t ".message_sent"
Notifier.message_notification(@message).deliver_later
UserMailer.message_notification(@message).deliver_later
redirect_to :action => :inbox
else
@title = t "messages.new.title"

View file

@ -106,7 +106,7 @@ class UsersController < ApplicationController
successful_login(current_user)
else
session[:token] = current_user.tokens.create.token
Notifier.signup_confirm(current_user, current_user.tokens.create(:referer => referer)).deliver_later
UserMailer.signup_confirm(current_user, current_user.tokens.create(:referer => referer)).deliver_later
redirect_to :action => "confirm", :display_name => current_user.display_name
end
else
@ -157,7 +157,7 @@ class UsersController < ApplicationController
if user
token = user.tokens.create
Notifier.lost_password(user, token).deliver_later
UserMailer.lost_password(user, token).deliver_later
flash[:notice] = t "users.lost_password.notice email on way"
redirect_to :action => "login"
else
@ -343,7 +343,7 @@ class UsersController < ApplicationController
if user.nil? || token.nil? || token.user != user
flash[:error] = t "users.confirm_resend.failure", :name => params[:display_name]
else
Notifier.signup_confirm(user, user.tokens.create).deliver_later
UserMailer.signup_confirm(user, user.tokens.create).deliver_later
flash[:notice] = t("users.confirm_resend.success", :email => user.email, :sender => Settings.support_email).html_safe
end
@ -659,7 +659,7 @@ class UsersController < ApplicationController
flash.now[:notice] = t "users.account.flash update success confirm needed"
begin
Notifier.email_confirm(user, user.tokens.create).deliver_later
UserMailer.email_confirm(user, user.tokens.create).deliver_later
rescue StandardError
# Ignore errors sending email
end

View file

@ -1,4 +1,4 @@
module NotifierHelper
module UserMailerHelper
def fp(text)
format_paragraph(text, 72, 0)
end

View file

@ -5,15 +5,15 @@ class TraceImporterJob < ApplicationJob
gpx = trace.import
if gpx.actual_points.positive?
Notifier.gpx_success(trace, gpx.actual_points).deliver
UserMailer.gpx_success(trace, gpx.actual_points).deliver
else
Notifier.gpx_failure(trace, "0 points parsed ok. Do they all have lat,lng,alt,timestamp?").deliver
UserMailer.gpx_failure(trace, "0 points parsed ok. Do they all have lat,lng,alt,timestamp?").deliver
trace.destroy
end
rescue StandardError => e
logger.info e.to_s
e.backtrace.each { |l| logger.info l }
Notifier.gpx_failure(trace, e.to_s + "\n" + e.backtrace.join("\n")).deliver
UserMailer.gpx_failure(trace, e.to_s + "\n" + e.backtrace.join("\n")).deliver
trace.destroy
end
end

View file

@ -1,4 +1,4 @@
class Notifier < ApplicationMailer
class UserMailer < ApplicationMailer
include ActionView::Helpers::AssetUrlHelper
self.delivery_job = ActionMailer::MailDeliveryJob
@ -17,7 +17,7 @@ class Notifier < ApplicationMailer
:confirm_string => token.token)
mail :to => user.email,
:subject => I18n.t("notifier.signup_confirm.subject")
:subject => I18n.t("user_mailer.signup_confirm.subject")
end
end
@ -28,7 +28,7 @@ class Notifier < ApplicationMailer
:confirm_string => token.token)
mail :to => user.new_email,
:subject => I18n.t("notifier.email_confirm.subject")
:subject => I18n.t("user_mailer.email_confirm.subject")
end
end
@ -38,7 +38,7 @@ class Notifier < ApplicationMailer
:token => token.token)
mail :to => user.email,
:subject => I18n.t("notifier.lost_password.subject")
:subject => I18n.t("user_mailer.lost_password.subject")
end
end
@ -51,7 +51,7 @@ class Notifier < ApplicationMailer
@possible_points = possible_points
mail :to => trace.user.email,
:subject => I18n.t("notifier.gpx_notification.success.subject")
:subject => I18n.t("user_mailer.gpx_notification.success.subject")
end
end
@ -63,7 +63,7 @@ class Notifier < ApplicationMailer
@error = error
mail :to => trace.user.email,
:subject => I18n.t("notifier.gpx_notification.failure.subject")
:subject => I18n.t("user_mailer.gpx_notification.failure.subject")
end
end
@ -81,7 +81,7 @@ class Notifier < ApplicationMailer
mail :from => from_address(message.sender.display_name, "m", message.id, message.digest),
:to => message.recipient.email,
:subject => I18n.t("notifier.message_notification.subject_header", :subject => message.title)
:subject => I18n.t("user_mailer.message_notification.subject_header", :subject => message.title)
end
end
@ -102,7 +102,7 @@ class Notifier < ApplicationMailer
mail :from => from_address(comment.user.display_name, "c", comment.id, comment.digest, recipient.id),
:to => recipient.email,
:subject => I18n.t("notifier.diary_comment_notification.subject", :user => comment.user.display_name)
:subject => I18n.t("user_mailer.diary_comment_notification.subject", :user => comment.user.display_name)
end
end
@ -115,7 +115,7 @@ class Notifier < ApplicationMailer
attach_user_avatar(@friendship.befriender)
mail :to => friendship.befriendee.email,
:subject => I18n.t("notifier.friendship_notification.subject", :user => friendship.befriender.display_name)
:subject => I18n.t("user_mailer.friendship_notification.subject", :user => friendship.befriender.display_name)
end
end
@ -130,7 +130,7 @@ class Notifier < ApplicationMailer
@commenter = if comment.author
comment.author.display_name
else
I18n.t("notifier.note_comment_notification.anonymous")
I18n.t("user_mailer.note_comment_notification.anonymous")
end
@author = @commenter
@ -139,9 +139,9 @@ class Notifier < ApplicationMailer
set_references("note", comment.note)
subject = if @owner
I18n.t("notifier.note_comment_notification.#{@event}.subject_own", :commenter => @commenter)
I18n.t("user_mailer.note_comment_notification.#{@event}.subject_own", :commenter => @commenter)
else
I18n.t("notifier.note_comment_notification.#{@event}.subject_other", :commenter => @commenter)
I18n.t("user_mailer.note_comment_notification.#{@event}.subject_other", :commenter => @commenter)
end
mail :to => recipient.email, :subject => subject
@ -161,9 +161,9 @@ class Notifier < ApplicationMailer
@author = @commenter
subject = if @owner
I18n.t("notifier.changeset_comment_notification.commented.subject_own", :commenter => @commenter)
I18n.t("user_mailer.changeset_comment_notification.commented.subject_own", :commenter => @commenter)
else
I18n.t("notifier.changeset_comment_notification.commented.subject_other", :commenter => @commenter)
I18n.t("user_mailer.changeset_comment_notification.commented.subject_other", :commenter => @commenter)
end
attach_user_avatar(comment.author)

View file

@ -1,12 +0,0 @@
<%= t "notifier.gpx_notification.your_gpx_file" %>
<strong><%= @trace_name %></strong>
<%= t "notifier.gpx_notification.with_description" %>
<em><%= @trace_description %></em>
<% if @trace_tags.length>0 %>
<%= t "notifier.gpx_notification.and_the_tags" %>
<em><% @trace_tags.each do |tag| %>
<%= tag.tag.rstrip %>
<% end %></em>
<% else %>
<%= t "notifier.gpx_notification.and_no_tags" %>
<% end %>

View file

@ -1,7 +0,0 @@
<p><%= t "notifier.email_confirm_html.greeting" %></p>
<p><%= t "notifier.email_confirm_html.hopefully_you", :server_url => Settings.server_url, :new_address => @address %></p>
<p><%= t "notifier.email_confirm_html.click_the_link" %></p>
<p><a href="<%= @url %>"><%= @url %></a></p>

View file

@ -1,7 +0,0 @@
<%= t 'notifier.email_confirm_plain.greeting' %>
<%= word_wrap(t 'notifier.email_confirm_plain.hopefully_you', :server_url => Settings.server_url, :new_address => @address) %>
<%= t 'notifier.email_confirm_plain.click_the_link' %>
<%= @url %>

View file

@ -1,16 +0,0 @@
<p><%= t "notifier.gpx_notification.greeting" %></p>
<p>
<%= render :partial => "gpx_description" %>
<%= t "notifier.gpx_notification.failure.failed_to_import" %>
</p>
<blockquote>
<%= @error %>
</blockquote>
<p>
<%= t "notifier.gpx_notification.failure.more_info_1" %>
<%= t "notifier.gpx_notification.failure.more_info_2" %>
<%= t "notifier.gpx_notification.failure.import_failures_url" %>
</p>

View file

@ -1,7 +0,0 @@
<p><%= t "notifier.lost_password_html.greeting" %></p>
<p><%= t "notifier.lost_password_html.hopefully_you" %></p>
<p><%= t "notifier.lost_password_html.click_the_link" %></p>
<p><a href="<%= @url %>"><%= @url %></a></p>

View file

@ -1,7 +0,0 @@
<%= t 'notifier.lost_password_plain.greeting' %>
<%= word_wrap(t 'notifier.lost_password_plain.hopefully_you') %>
<%= t 'notifier.lost_password_plain.click_the_link' %>
<%= @url %>

View file

@ -0,0 +1,12 @@
<%= t "user_mailer.gpx_notification.your_gpx_file" %>
<strong><%= @trace_name %></strong>
<%= t "user_mailer.gpx_notification.with_description" %>
<em><%= @trace_description %></em>
<% if @trace_tags.length>0 %>
<%= t "user_mailer.gpx_notification.and_the_tags" %>
<em><% @trace_tags.each do |tag| %>
<%= tag.tag.rstrip %>
<% end %></em>
<% else %>
<%= t "user_mailer.gpx_notification.and_no_tags" %>
<% end %>

View file

@ -0,0 +1,7 @@
<p><%= t "user_mailer.email_confirm_html.greeting" %></p>
<p><%= t "user_mailer.email_confirm_html.hopefully_you", :server_url => Settings.server_url, :new_address => @address %></p>
<p><%= t "user_mailer.email_confirm_html.click_the_link" %></p>
<p><a href="<%= @url %>"><%= @url %></a></p>

View file

@ -0,0 +1,7 @@
<%= t 'user_mailer.email_confirm_plain.greeting' %>
<%= word_wrap(t 'user_mailer.email_confirm_plain.hopefully_you', :server_url => Settings.server_url, :new_address => @address) %>
<%= t 'user_mailer.email_confirm_plain.click_the_link' %>
<%= @url %>

View file

@ -0,0 +1,16 @@
<p><%= t "user_mailer.gpx_notification.greeting" %></p>
<p>
<%= render :partial => "gpx_description" %>
<%= t "user_mailer.gpx_notification.failure.failed_to_import" %>
</p>
<blockquote>
<%= @error %>
</blockquote>
<p>
<%= t "user_mailer.gpx_notification.failure.more_info_1" %>
<%= t "user_mailer.gpx_notification.failure.more_info_2" %>
<%= t "user_mailer.gpx_notification.failure.import_failures_url" %>
</p>

View file

@ -1,7 +1,7 @@
<p><%= t "notifier.gpx_notification.greeting" %></p>
<p><%= t "user_mailer.gpx_notification.greeting" %></p>
<p>
<%= render :partial => "gpx_description" %>
<%= t("notifier.gpx_notification.success.loaded_successfully",
<%= t("user_mailer.gpx_notification.success.loaded_successfully",
:trace_points => @trace_points, :possible_points => @possible_points, :count => @possible_points) %>
</p>

View file

@ -0,0 +1,7 @@
<p><%= t "user_mailer.lost_password_html.greeting" %></p>
<p><%= t "user_mailer.lost_password_html.hopefully_you" %></p>
<p><%= t "user_mailer.lost_password_html.click_the_link" %></p>
<p><a href="<%= @url %>"><%= @url %></a></p>

View file

@ -0,0 +1,7 @@
<%= t 'user_mailer.lost_password_plain.greeting' %>
<%= word_wrap(t 'user_mailer.lost_password_plain.hopefully_you') %>
<%= t 'user_mailer.lost_password_plain.click_the_link' %>
<%= @url %>

View file

@ -1411,7 +1411,7 @@ en:
text: Make a Donation
learn_more: "Learn More"
more: More
notifier:
user_mailer:
diary_comment_notification:
subject: "[OpenStreetMap] %{user} commented on a diary entry"
hi: "Hi %{to_user},"
@ -1639,7 +1639,7 @@ en:
full <a href="https://opendatacommons.org/licenses/odbl/1.0/">legal
code</a> explains your rights and responsibilities.
intro_3_1_html: |
Our documentation is licensed under the
Our documentation is licensed under the
<a href="https://creativecommons.org/licenses/by-sa/2.0/">Creative
Commons Attribution-ShareAlike 2.0</a> license (CC BY-SA 2.0).
credit_title_html: How to credit OpenStreetMap
@ -1656,11 +1656,11 @@ en:
direct your readers to openstreetmap.org (perhaps by expanding
'OpenStreetMap' to this full address) and to opendatacommons.org.
credit_3_1_html: |
The map tiles in the &ldquo;standard style&rdquo; at www.openstreetmap.org are a
Produced Work by the OpenStreetMap Foundation using OpenStreetMap data
under the Open Database License. If you are using these tiles please use
the following attribution:
&ldquo;Base map and data from OpenStreetMap and OpenStreetMap Foundation&rdquo;.
The map tiles in the &ldquo;standard style&rdquo; at www.openstreetmap.org are a
Produced Work by the OpenStreetMap Foundation using OpenStreetMap data
under the Open Database License. If you are using these tiles please use
the following attribution:
&ldquo;Base map and data from OpenStreetMap and OpenStreetMap Foundation&rdquo;.
credit_4_html: |
For a browsable electronic map, the credit should appear in the corner of the map.
For example: