mirror of
https://github.com/diaspora/diaspora.git
synced 2026-01-09 15:18:11 -05:00
Merge branch 'develop' into use-yarn-for-assets
This commit is contained in:
@@ -36,6 +36,7 @@ Although the chat was never enabled per default and was marked as experimental,
|
||||
* For pods running PostgreSQL, make sure that no upper-case/mixed-case tags exist, and create a `lower(name)` index on tags to speed up ActsAsTaggableOn [#8206](https://github.com/diaspora/diaspora/pull/8206)
|
||||
* Allow podmins/moderators to see all local public posts to improve moderation [#8232](https://github.com/diaspora/diaspora/pull/8232) [#8320](https://github.com/diaspora/diaspora/pull/8320)
|
||||
* Add support for directly paste images to upload them [#8237](https://github.com/diaspora/diaspora/pull/8237)
|
||||
* Add support for webp images and convert new png/jpg to webp to save space and bandwidth [#8358](https://github.com/diaspora/diaspora/pull/8358)
|
||||
|
||||
# 0.7.18.0
|
||||
|
||||
@@ -45,10 +46,14 @@ Although the chat was never enabled per default and was marked as experimental,
|
||||
* Fix deprecation warnings for sidekiq 7.0 [#8359](https://github.com/diaspora/diaspora/pull/8359)
|
||||
* Remove entypo-rails dependency to prepare for rails 6 [#8361](https://github.com/diaspora/diaspora/pull/8361)
|
||||
* Remove compass-rails dependency which is not supported anymore [#8362](https://github.com/diaspora/diaspora/pull/8362)
|
||||
* Remove markerb dependency which doesn't exist anymore [#8365](https://github.com/diaspora/diaspora/pull/8365)
|
||||
|
||||
## Bug fixes
|
||||
* Fix that no mails were sent after photo export [#8365](https://github.com/diaspora/diaspora/pull/8365)
|
||||
* Fix people with quotes in the name causing issues with mail sender [#8365](https://github.com/diaspora/diaspora/pull/8365)
|
||||
|
||||
## Features
|
||||
* Render posts and comments as HTML in HTML mails [#8365](https://github.com/diaspora/diaspora/pull/8365)
|
||||
|
||||
# 0.7.17.0
|
||||
|
||||
|
||||
4
Gemfile
4
Gemfile
@@ -101,10 +101,6 @@ gem "http_accept_language", "2.1.1"
|
||||
gem "i18n-inflector-rails", "1.0.7"
|
||||
gem "rails-i18n", "5.1.3"
|
||||
|
||||
# Mail
|
||||
|
||||
gem "markerb", "1.1.0"
|
||||
|
||||
# Map
|
||||
gem "leaflet-rails", "1.7.0"
|
||||
|
||||
|
||||
@@ -381,7 +381,6 @@ GEM
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (1.0.2)
|
||||
markerb (1.1.0)
|
||||
memoizable (0.4.2)
|
||||
thread_safe (~> 0.3, >= 0.3.1)
|
||||
method_source (1.0.0)
|
||||
@@ -787,7 +786,6 @@ DEPENDENCIES
|
||||
leaflet-rails (= 1.7.0)
|
||||
listen (= 3.7.1)
|
||||
logging-rails (= 0.6.0)
|
||||
markerb (= 1.1.0)
|
||||
mini_magick (= 4.11.0)
|
||||
minitest (= 5.15.0)
|
||||
mobile-fu (= 1.4.0)
|
||||
|
||||
@@ -59,8 +59,8 @@ Diaspora.PostPhotoUploader = class {
|
||||
promptForName: true
|
||||
},
|
||||
validation: {
|
||||
acceptFiles: "image/png, image/jpeg, image/gif",
|
||||
allowedExtensions: ["jpg", "jpeg", "png", "gif"],
|
||||
acceptFiles: "image/png, image/jpeg, image/gif, image/webp",
|
||||
allowedExtensions: ["jpg", "jpeg", "png", "gif", "webp"],
|
||||
sizeLimit: (window.Promise && qq.supportedFeatures.scaling ? null : this.sizeLimit)
|
||||
},
|
||||
messages: {
|
||||
|
||||
@@ -11,8 +11,8 @@ Diaspora.ProfilePhotoUploader.prototype = {
|
||||
new qq.FineUploaderBasic({
|
||||
element: document.getElementById("file-upload"),
|
||||
validation: {
|
||||
acceptFiles: "image/png, image/jpeg, image/gif",
|
||||
allowedExtensions: ["jpg", "jpeg", "png"],
|
||||
acceptFiles: "image/png, image/jpeg, image/gif, image/webp",
|
||||
allowedExtensions: ["png", "jpg", "jpeg", "gif", "webp"],
|
||||
sizeLimit: 4194304
|
||||
},
|
||||
request: {
|
||||
|
||||
@@ -4,21 +4,19 @@ module NotifierHelper
|
||||
include PostsHelper
|
||||
|
||||
# @param post [Post] The post object.
|
||||
# @param opts [Hash] Optional hash. Accepts :length parameters.
|
||||
# @param opts [Hash] Optional hash. Accepts :html parameter.
|
||||
# @return [String] The formatted post.
|
||||
def post_message(post, opts={})
|
||||
if post.respond_to? :message
|
||||
post.message.try(:plain_text_without_markdown).presence || post_page_title(post)
|
||||
else
|
||||
I18n.translate "notifier.a_post_you_shared"
|
||||
end
|
||||
rendered = opts[:html] ? post.message&.markdownified_for_mail : post.message&.plain_text_without_markdown
|
||||
rendered.presence || post_page_title(post)
|
||||
end
|
||||
|
||||
# @param comment [Comment] The comment to process.
|
||||
# @param opts [Hash] Optional hash. Accepts :html parameter.
|
||||
# @return [String] The formatted comment.
|
||||
def comment_message(comment, opts={})
|
||||
if comment.post.public?
|
||||
comment.message.plain_text_without_markdown
|
||||
opts[:html] ? comment.message.markdownified_for_mail : comment.message.plain_text_without_markdown
|
||||
else
|
||||
I18n.translate "notifier.a_limited_post_comment"
|
||||
end
|
||||
|
||||
@@ -27,10 +27,10 @@ module PeopleHelper
|
||||
|
||||
def person_link(person, opts={})
|
||||
css_class = person_link_class(person, opts[:class])
|
||||
remote_or_hovercard_link = Rails.application.routes.url_helpers.person_path(person).html_safe
|
||||
"<a data-hovercard='#{remote_or_hovercard_link}' href='#{remote_or_hovercard_link}' class='#{css_class}'>"\
|
||||
"#{html_escape_once(opts[:display_name] || person.name)}</a>"\
|
||||
.html_safe
|
||||
remote_or_hovercard_link = person_path(person)
|
||||
tag.a('data-hovercard': remote_or_hovercard_link, href: remote_or_hovercard_link, class: css_class) do
|
||||
opts[:display_name] || person.name
|
||||
end
|
||||
end
|
||||
|
||||
def person_image_tag(person, size = :thumb_small)
|
||||
@@ -44,15 +44,12 @@ module PeopleHelper
|
||||
if opts[:to] == :photos
|
||||
link_to person_image_tag(person, opts[:size]), person_photos_path(person)
|
||||
else
|
||||
css_class = person_link_class(person, opts[:class])
|
||||
remote_or_hovercard_link = Rails.application.routes.url_helpers.person_path(person).html_safe
|
||||
"<a href='#{remote_or_hovercard_link}' class='#{css_class}' #{('target=' + opts[:target]) if opts[:target]}>
|
||||
#{person_image_tag(person, opts[:size])}
|
||||
</a>".html_safe
|
||||
tag.a(href: person_path(person), class: person_link_class(person, opts[:class])) do
|
||||
person_image_tag(person, opts[:size])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Rails.application.routes.url_helpers is needed since this is indirectly called from a model
|
||||
def local_or_remote_person_path(person, opts={})
|
||||
opts.merge!(:protocol => AppConfig.pod_uri.scheme, :host => AppConfig.pod_uri.authority)
|
||||
absolute = opts.delete(:absolute)
|
||||
@@ -61,19 +58,11 @@ module PeopleHelper
|
||||
username = person.username
|
||||
unless username.include?('.')
|
||||
opts.merge!(:username => username)
|
||||
if absolute
|
||||
return Rails.application.routes.url_helpers.user_profile_url(opts)
|
||||
else
|
||||
return Rails.application.routes.url_helpers.user_profile_path(opts)
|
||||
end
|
||||
return absolute ? user_profile_url(opts) : user_profile_path(opts)
|
||||
end
|
||||
end
|
||||
|
||||
if absolute
|
||||
return Rails.application.routes.url_helpers.person_url(person, opts)
|
||||
else
|
||||
return Rails.application.routes.url_helpers.person_path(person, opts)
|
||||
end
|
||||
absolute ? person_url(person, opts) : person_path(person, opts)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -2,38 +2,31 @@
|
||||
|
||||
class ExportMailer < ApplicationMailer
|
||||
def export_complete_for(user)
|
||||
@user = user
|
||||
|
||||
mail(to: @user.email, subject: I18n.t('notifier.export_email.subject', name: @user.name)) do |format|
|
||||
format.html { render 'users/export_email' }
|
||||
format.text { render 'users/export_email' }
|
||||
end
|
||||
send_mail(user, I18n.t("notifier.export_email.subject", name: user.name),
|
||||
I18n.t("notifier.export_email.body", url: download_profile_user_url, name: user.first_name))
|
||||
end
|
||||
|
||||
def export_failure_for(user)
|
||||
@user = user
|
||||
|
||||
mail(to: @user.email, subject: I18n.t('notifier.export_failure_email.subject', name: @user.name)) do |format|
|
||||
format.html { render 'users/export_failure_email' }
|
||||
format.text { render 'users/export_failure_email' }
|
||||
end
|
||||
send_mail(user, I18n.t("notifier.export_failure_email.subject", name: user.name),
|
||||
I18n.t("notifier.export_failure_email.body", name: user.first_name))
|
||||
end
|
||||
|
||||
def export_photos_complete_for(user)
|
||||
@user = user
|
||||
|
||||
mail(to: @user.email, subject: I18n.t('notifier.export_photos_email.subject', name: @user.name)) do |format|
|
||||
format.html { render 'users/export_photos_email' }
|
||||
format.text { render 'users/export_photos_email' }
|
||||
end
|
||||
send_mail(user, I18n.t("notifier.export_photos_email.subject", name: user.name),
|
||||
I18n.t("notifier.export_photos_email.body", url: download_photos_user_url, name: user.first_name))
|
||||
end
|
||||
|
||||
def export_photos_failure_for(user)
|
||||
@user = user
|
||||
send_mail(user, I18n.t("notifier.export_photos_failure_email.subject", name: user.name),
|
||||
I18n.t("notifier.export_photos_failure_email.body", name: user.first_name))
|
||||
end
|
||||
|
||||
mail(to: @user.email, subject: I18n.t('notifier.export_photos_failure_email.subject', name: @user.name)) do |format|
|
||||
format.html { render 'users/export_photos_failure_email' }
|
||||
format.text { render 'users/export_photos_failure_email' }
|
||||
private
|
||||
|
||||
def send_mail(user, subject, body)
|
||||
mail(to: user.email, subject: subject) do |format|
|
||||
format.html { render "notifier/plain_markdown_email", locals: {body: body} }
|
||||
format.text { render "notifier/plain_markdown_email", locals: {body: body} }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
|
||||
class Maintenance < ApplicationMailer
|
||||
def account_removal_warning(user)
|
||||
@user = user
|
||||
@login_url = new_user_session_url
|
||||
@pod_url = AppConfig.environment.url
|
||||
@after_days = AppConfig.settings.maintenance.remove_old_users.after_days.to_s
|
||||
@remove_after = @user.remove_after
|
||||
|
||||
I18n.with_locale(@user.language) do
|
||||
mail(to: @user.email, subject: I18n.t("notifier.remove_old_user.subject")) do |format|
|
||||
format.text
|
||||
format.html
|
||||
I18n.with_locale(user.language) do
|
||||
body = I18n.t("notifier.remove_old_user.body",
|
||||
pod_url: AppConfig.environment.url,
|
||||
login_url: new_user_session_url,
|
||||
after_days: AppConfig.settings.maintenance.remove_old_users.after_days.to_s,
|
||||
remove_after: user.remove_after)
|
||||
mail(to: user.email, subject: I18n.t("notifier.remove_old_user.subject")) do |format|
|
||||
format.text { render "notifier/plain_markdown_email", locals: {body: body} }
|
||||
format.html { render "notifier/plain_markdown_email", locals: {body: body} }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,16 +35,13 @@ module NotificationMailers
|
||||
private
|
||||
|
||||
def default_headers
|
||||
headers = {
|
||||
from: "\"#{AppConfig.settings.pod_name}\" <#{AppConfig.mail.sender_address}>",
|
||||
host: "#{AppConfig.pod_uri.host}",
|
||||
from_name = AppConfig.settings.pod_name
|
||||
from_name += " (#{@sender.profile.full_name.empty? ? @sender.username : @sender.name})" if @sender.present?
|
||||
|
||||
{
|
||||
from: name_and_address(from_name, AppConfig.mail.sender_address),
|
||||
to: name_and_address(@recipient.name, @recipient.email)
|
||||
}
|
||||
return headers if @sender.blank?
|
||||
sender_in_header = @sender.profile.full_name.empty? ? @sender.username : @sender.name
|
||||
headers[:from] = "\"#{AppConfig.settings.pod_name} (#{sender_in_header})\" <#{AppConfig.mail.sender_address}>"
|
||||
|
||||
headers
|
||||
end
|
||||
|
||||
def with_recipient_locale(&block)
|
||||
|
||||
@@ -24,33 +24,28 @@ class Notifier < ApplicationMailer
|
||||
}
|
||||
end
|
||||
|
||||
unless subject
|
||||
subject = I18n.t('notifier.single_admin.subject')
|
||||
end
|
||||
subject ||= I18n.t("notifier.single_admin.subject")
|
||||
|
||||
default_opts = {:to => @receiver.email,
|
||||
:from => AppConfig.mail.sender_address,
|
||||
:subject => subject, :host => AppConfig.pod_uri.host}
|
||||
default_opts = {to: @receiver.email, from: AppConfig.mail.sender_address, subject: subject}
|
||||
default_opts.merge!(opts)
|
||||
|
||||
mail(default_opts) do |format|
|
||||
format.text
|
||||
format.html
|
||||
end
|
||||
mail(default_opts)
|
||||
end
|
||||
|
||||
def invite(email, inviter, invitation_code, locale)
|
||||
@inviter = inviter
|
||||
@invitation_code = invitation_code
|
||||
|
||||
I18n.with_locale(locale) do
|
||||
mail_opts = {to: email, from: "\"#{AppConfig.settings.pod_name}\" <#{AppConfig.mail.sender_address}>",
|
||||
subject: I18n.t("notifier.invited_you", name: @inviter.name),
|
||||
host: AppConfig.pod_uri.host}
|
||||
subject: I18n.t("notifier.invited_you", name: inviter.name)}
|
||||
name = inviter.full_name.empty? ? inviter.diaspora_handle : "#{inviter.name} (#{inviter.diaspora_handle})"
|
||||
body = I18n.t("notifier.invite.message",
|
||||
invite_url: invite_code_url(invitation_code),
|
||||
diasporafoundation_url: "https://diasporafoundation.org/",
|
||||
user: name,
|
||||
diaspora_id: inviter.diaspora_handle)
|
||||
|
||||
mail(mail_opts) do |format|
|
||||
format.text { render :layout => nil }
|
||||
format.html { render :layout => nil }
|
||||
format.text { render "notifier/plain_markdown_email", layout: nil, locals: {body: body} }
|
||||
format.html { render "notifier/plain_markdown_email", layout: nil, locals: {body: body} }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,9 +26,10 @@ class ReportMailer < ApplicationMailer
|
||||
private
|
||||
|
||||
def format(resource)
|
||||
body = I18n.t("notifier.report_email.body", resource)
|
||||
mail(to: resource[:email], subject: I18n.t("notifier.report_email.subject", type: resource[:type])) do |format|
|
||||
format.html { render "report/report_email", locals: {resource: resource} }
|
||||
format.text { render "report/report_email", locals: {resource: resource} }
|
||||
format.html { render "notifier/plain_markdown_email", locals: {body: body} }
|
||||
format.text { render "notifier/plain_markdown_email", locals: {body: body} }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,6 +38,7 @@ class Photo < ApplicationRecord
|
||||
|
||||
mount_uploader :processed_image, ProcessedImage
|
||||
mount_uploader :unprocessed_image, UnprocessedImage
|
||||
attr_accessor :keep_original_format
|
||||
|
||||
belongs_to :status_message, foreign_key: :status_message_guid, primary_key: :guid, optional: true
|
||||
validates_associated :status_message
|
||||
@@ -50,7 +51,6 @@ class Photo < ApplicationRecord
|
||||
|
||||
after_commit on: :create do
|
||||
queue_processing_job if author.local?
|
||||
|
||||
end
|
||||
|
||||
scope :on_statuses, ->(post_guids) {
|
||||
|
||||
@@ -74,6 +74,7 @@ class ImportService
|
||||
def store_and_process_photo(photo, uploaded_file, random_string)
|
||||
File.open(uploaded_file) do |file|
|
||||
photo.random_string = random_string
|
||||
photo.keep_original_format = true
|
||||
photo.unprocessed_image.store! file
|
||||
photo.update_remote_path
|
||||
photo.save(touch: false)
|
||||
|
||||
@@ -12,7 +12,7 @@ class ProcessedImage < CarrierWave::Uploader::Base
|
||||
end
|
||||
|
||||
def extension_allowlist
|
||||
%w[jpg jpeg png gif]
|
||||
%w[jpg jpeg png gif webp]
|
||||
end
|
||||
|
||||
def filename
|
||||
|
||||
@@ -18,20 +18,34 @@ class UnprocessedImage < CarrierWave::Uploader::Base
|
||||
end
|
||||
|
||||
def extension_allowlist
|
||||
%w[jpg jpeg png gif]
|
||||
%w[jpg jpeg png gif webp]
|
||||
end
|
||||
|
||||
def filename
|
||||
model.random_string + File.extname(@filename) if @filename
|
||||
model.random_string + extension if @filename
|
||||
end
|
||||
|
||||
def extension
|
||||
needs_converting? ? ".webp" : File.extname(@filename)
|
||||
end
|
||||
|
||||
def needs_converting?
|
||||
extname = File.extname(@filename)
|
||||
%w[.webp .gif].exclude?(extname) && !model.keep_original_format
|
||||
end
|
||||
|
||||
process :basic_process
|
||||
|
||||
def basic_process
|
||||
manipulate! do |img|
|
||||
img.auto_orient
|
||||
img.strip if strip_exif
|
||||
img.combine_options do |i|
|
||||
i.auto_orient
|
||||
i.strip if strip_exif
|
||||
end
|
||||
|
||||
img = yield(img) if block_given?
|
||||
|
||||
img.format("webp") if needs_converting?
|
||||
img
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
%p
|
||||
= t("devise.mailer.welcome", username: @resource.username)
|
||||
%p
|
||||
= t(".you_can_confirm")
|
||||
%p
|
||||
= link_to t(".confirm"), confirmation_url(@resource, confirmation_token: @token)
|
||||
@@ -1,7 +0,0 @@
|
||||
<%= t('devise.mailer.welcome', username: @resource.username) %>
|
||||
|
||||
<%= t('.you_can_confirm') %>
|
||||
|
||||
[<%= t('.confirm') %>][1]
|
||||
|
||||
[1]: <%= confirmation_url(@resource, confirmation_token: @token) %>
|
||||
@@ -0,0 +1,4 @@
|
||||
<%= t("devise.mailer.welcome", username: @resource.username) %>
|
||||
|
||||
<%= t(".you_can_confirm") %>
|
||||
<%= confirmation_url(@resource, confirmation_token: @token) %>
|
||||
@@ -1 +0,0 @@
|
||||
<%= t('.message', :invite_url => invite_code_url(@invitation_code)) %>
|
||||
@@ -0,0 +1,12 @@
|
||||
%p
|
||||
= t("devise.mailer.hello", username: @resource.username)
|
||||
%p
|
||||
= t(".someone_requested")
|
||||
%p
|
||||
= link_to t(".change"), edit_password_url(@resource, reset_password_token: @token)
|
||||
%p
|
||||
= t(".then_connect", username: @resource.username)
|
||||
%p
|
||||
= t(".wont_change")
|
||||
%p
|
||||
= t(".ignore")
|
||||
@@ -1,13 +0,0 @@
|
||||
<%= t('devise.mailer.hello', username: @resource.username) %>
|
||||
|
||||
<%= t('.someone_requested') %>
|
||||
|
||||
[<%= t('.change') %>][1]
|
||||
|
||||
[1]: <%= edit_password_url(@resource, reset_password_token: @token) %>
|
||||
|
||||
<%= t('.then_connect', username: @resource.username) %>
|
||||
|
||||
<%= t('.wont_change') %>
|
||||
|
||||
<%= t('.ignore') %>
|
||||
11
app/views/devise/mailer/reset_password_instructions.text.erb
Normal file
11
app/views/devise/mailer/reset_password_instructions.text.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<%= t("devise.mailer.hello", username: @resource.username) %>
|
||||
|
||||
<%= t(".someone_requested") %>
|
||||
|
||||
<%= t(".change") %>: <%= edit_password_url(@resource, reset_password_token: @token) %>
|
||||
|
||||
<%= t(".then_connect", username: @resource.username) %>
|
||||
|
||||
<%= t(".wont_change") %>
|
||||
|
||||
<%= t(".ignore") %>
|
||||
8
app/views/devise/mailer/unlock_instructions.html.haml
Normal file
8
app/views/devise/mailer/unlock_instructions.html.haml
Normal file
@@ -0,0 +1,8 @@
|
||||
%p
|
||||
= t("devise.mailer.hello", username: @resource.username)
|
||||
%p
|
||||
= t(".account_locked")
|
||||
%p
|
||||
= t(".click_to_unlock")
|
||||
%p
|
||||
= link_to t(".unlock"), unlock_url(@resource, unlock_token: @token)
|
||||
@@ -1,9 +0,0 @@
|
||||
<%= t('devise.mailer.hello', username: @resource.username) %>
|
||||
|
||||
<%= t('.account_locked') %>
|
||||
|
||||
<%= t('.click_to_unlock') %>
|
||||
|
||||
[<%= t('.unlock') %>][1]
|
||||
|
||||
[1]: <%= unlock_url(@resource, unlock_token: @token) %>
|
||||
6
app/views/devise/mailer/unlock_instructions.text.erb
Normal file
6
app/views/devise/mailer/unlock_instructions.text.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<%= t("devise.mailer.hello", username: @resource.username) %>
|
||||
|
||||
<%= t(".account_locked") %>
|
||||
|
||||
<%= t(".click_to_unlock") %>
|
||||
<%= unlock_url(@resource, unlock_token: @token) %>
|
||||
@@ -1,7 +1,7 @@
|
||||
%table{cellspacing: 0, cellpadding: 0, border: 0,
|
||||
style: "font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px"}
|
||||
%tr
|
||||
- if @notification.try(:sender)
|
||||
- if @notification&.sender.present?
|
||||
%td{width: "60px", style: "vertical-align: top"}>
|
||||
%div{style: "background-color: #eee; height: 50px; width: 50px"}
|
||||
= image_tag @notification.sender.profile.image_url(size: :thumb_small), alt: @notification.sender.name,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
!= yield
|
||||
|
||||
!= "-- "
|
||||
!= t("notifier.email_sent_by_diaspora", pod_name: pod_name)
|
||||
!= t("notifier.to_change_your_notification_settings")
|
||||
!= edit_user_url
|
||||
!= "#{t('notifier.to_change_your_notification_settings')}: #{edit_user_url}"
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
<%= t('notifier.remove_old_user.body', pod_url: @pod_url, login_url: @login_url, after_days: @after_days, remove_after: @remove_after) %>
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
:css
|
||||
body{
|
||||
width:600px;
|
||||
font-family: 'Helvetica',sans-serif;
|
||||
}
|
||||
#container{
|
||||
}
|
||||
header{
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
p{
|
||||
padding:5px;
|
||||
}
|
||||
p.small{
|
||||
font-size:smaller;
|
||||
color:#999;
|
||||
font-style:italic;
|
||||
}
|
||||
a{
|
||||
color:#107FC9;
|
||||
font-weight:bold;
|
||||
}
|
||||
a:hover{
|
||||
color: #22AAE0;
|
||||
}
|
||||
a:active{
|
||||
color: #005D9C;
|
||||
}
|
||||
4
app/views/notifier/also_commented.html.haml
Normal file
4
app/views/notifier/also_commented.html.haml
Normal file
@@ -0,0 +1,4 @@
|
||||
= comment_message(@notification.comment, html: true)
|
||||
%p
|
||||
= link_to t("notifier.comment_on_post.reply", name: @notification.comment.post.author_first_name),
|
||||
post_url(@notification.comment.post, anchor: @notification.comment.guid)
|
||||
@@ -1,5 +0,0 @@
|
||||
<%= comment_message(@notification.comment, :process_newlines => true) %>
|
||||
|
||||
[<%= t('notifier.comment_on_post.reply', :name => @notification.comment_post.author_first_name) %>][1]
|
||||
|
||||
[1]: <%= post_url(@notification.comment_post, anchor: @notification.comment.guid) %>
|
||||
4
app/views/notifier/also_commented.text.erb
Normal file
4
app/views/notifier/also_commented.text.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<%= comment_message(@notification.comment) %>
|
||||
|
||||
<%= t("notifier.comment_on_post.reply", name: @notification.comment.post.author_first_name) %>
|
||||
<%= post_url(@notification.comment.post, anchor: @notification.comment.guid) %>
|
||||
4
app/views/notifier/comment_on_post.html.haml
Normal file
4
app/views/notifier/comment_on_post.html.haml
Normal file
@@ -0,0 +1,4 @@
|
||||
= comment_message(@notification.comment, html: true)
|
||||
%p
|
||||
= link_to t("notifier.comment_on_post.reply", name: @notification.comment.post.author_first_name),
|
||||
post_url(@notification.comment.post, anchor: @notification.comment.guid)
|
||||
@@ -1,5 +0,0 @@
|
||||
<%= comment_message(@notification.comment, :process_newlines => true) %>
|
||||
|
||||
[<%= t('notifier.comment_on_post.reply', :name => @notification.comment.parent_author_name) %>][1]
|
||||
|
||||
[1]: <%= post_url(@notification.comment.post, anchor: @notification.comment.guid) %>
|
||||
4
app/views/notifier/comment_on_post.text.erb
Normal file
4
app/views/notifier/comment_on_post.text.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<%= comment_message(@notification.comment) %>
|
||||
|
||||
<%= t("notifier.comment_on_post.reply", name: @notification.comment.post.author_first_name) %>
|
||||
<%= post_url(@notification.comment.post, anchor: @notification.comment.guid) %>
|
||||
6
app/views/notifier/confirm_email.html.haml
Normal file
6
app/views/notifier/confirm_email.html.haml
Normal file
@@ -0,0 +1,6 @@
|
||||
%p
|
||||
= t("notifier.hello", name: @notification.recipient_first_name)
|
||||
%p
|
||||
= t("notifier.confirm_email.click_link", unconfirmed_email: @notification.recipient_unconfirmed_email)
|
||||
%p
|
||||
= link_to nil, confirm_email_url(token: @notification.recipient_confirm_email_token)
|
||||
@@ -1,5 +0,0 @@
|
||||
<%= t('notifier.hello', :name => @notification.recipient_first_name) %>
|
||||
|
||||
<%= t('notifier.confirm_email.click_link', :unconfirmed_email => @notification.recipient_unconfirmed_email) %>
|
||||
|
||||
<<%= confirm_email_url(:token => @notification.recipient_confirm_email_token) %>>
|
||||
5
app/views/notifier/confirm_email.text.erb
Normal file
5
app/views/notifier/confirm_email.text.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<%= t("notifier.hello", name: @notification.recipient_first_name) %>
|
||||
|
||||
<%= t("notifier.confirm_email.click_link", unconfirmed_email: @notification.recipient_unconfirmed_email) %>
|
||||
|
||||
<%= confirm_email_url(token: @notification.recipient_confirm_email_token) %>
|
||||
5
app/views/notifier/contacts_birthday.html.haml
Normal file
5
app/views/notifier/contacts_birthday.html.haml
Normal file
@@ -0,0 +1,5 @@
|
||||
%p
|
||||
= t(".birthday", name: @notification.person.name)
|
||||
%p
|
||||
= link_to t(".view_profile", name: @notification.person.first_name),
|
||||
local_or_remote_person_path(@notification.person, absolute: true)
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
<%= t(".birthday", name: @notification.person.name) %>
|
||||
|
||||
[<%= t(".view_profile", name: @notification.person.name) %>][1]
|
||||
|
||||
[1]: <%= local_or_remote_person_path(@notification.person, absolute: true) %>
|
||||
4
app/views/notifier/contacts_birthday.text.erb
Normal file
4
app/views/notifier/contacts_birthday.text.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<%= t(".birthday", name: @notification.person.name) %>
|
||||
|
||||
<%= t(".view_profile", name: @notification.person.first_name) %>
|
||||
<%= local_or_remote_person_path(@notification.person, absolute: true) %>
|
||||
4
app/views/notifier/csrf_token_fail.html.haml
Normal file
4
app/views/notifier/csrf_token_fail.html.haml
Normal file
@@ -0,0 +1,4 @@
|
||||
- message = t("notifier.csrf_token_fail.body",
|
||||
name: @notification.recipient_first_name,
|
||||
link: "https://owasp.org/www-community/attacks/csrf")
|
||||
!= Redcarpet::Markdown.new(Diaspora::Markdownify::Email).render(message)
|
||||
@@ -1 +0,0 @@
|
||||
<%= t("notifier.csrf_token_fail.body", name: @notification.recipient_first_name, link: "https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)") %>
|
||||
3
app/views/notifier/csrf_token_fail.text.erb
Normal file
3
app/views/notifier/csrf_token_fail.text.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<%= t("notifier.csrf_token_fail.body",
|
||||
name: @notification.recipient_first_name,
|
||||
link: "https://owasp.org/www-community/attacks/csrf") %>
|
||||
@@ -1,6 +0,0 @@
|
||||
<%= t('.message',
|
||||
invite_url: invite_code_url(@invitation_code),
|
||||
diasporafoundation_url: 'https://diasporafoundation.org/',
|
||||
user: @inviter.try(:full_name).empty? ? @inviter.try(:diaspora_handle) : "#{@inviter.name} (#{@inviter.diaspora_handle})",
|
||||
diaspora_id: @inviter.try(:diaspora_handle))
|
||||
%>
|
||||
10
app/views/notifier/liked.html.haml
Normal file
10
app/views/notifier/liked.html.haml
Normal file
@@ -0,0 +1,10 @@
|
||||
- if @notification.like_target.public?
|
||||
%p
|
||||
#{t('.liked', name: @notification.sender_name)}:
|
||||
= post_message(@notification.like_target, html: true)
|
||||
- else
|
||||
%p
|
||||
#{t('notifier.liked.limited_post', name: @notification.sender_name)}.
|
||||
|
||||
%p
|
||||
= link_to t(".view_post"), post_url(@notification.like_target)
|
||||
@@ -1,11 +0,0 @@
|
||||
<% if @notification.like_target.public? %>
|
||||
<%= "#{t('.liked', :name => "#{@notification.sender_name}")}:" %>
|
||||
|
||||
<%= post_message(@notification.like_target, :process_newlines => true) %>
|
||||
<% else %>
|
||||
<%= "#{t('notifier.liked.limited_post', :name => "#{@notification.sender_name}")}." %>
|
||||
<% end %>
|
||||
|
||||
[<%= t('.view_post') %>][1]
|
||||
|
||||
[1]: <%= post_url(@notification.like_target) %>
|
||||
10
app/views/notifier/liked.text.erb
Normal file
10
app/views/notifier/liked.text.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<% if @notification.like_target.public? %>
|
||||
<%= "#{t(".liked", name: @notification.sender_name)}:" %>
|
||||
|
||||
<%= post_message(@notification.like_target) %>
|
||||
<% else %>
|
||||
<%= "#{t("notifier.liked.limited_post", name: @notification.sender_name)}." %>
|
||||
<% end %>
|
||||
|
||||
<%= t(".view_post") %>
|
||||
<%= post_url(@notification.like_target) %>
|
||||
9
app/views/notifier/mentioned.html.haml
Normal file
9
app/views/notifier/mentioned.html.haml
Normal file
@@ -0,0 +1,9 @@
|
||||
- if @notification.post.public?
|
||||
= post_message(@notification.post, html: true)
|
||||
- else
|
||||
%p
|
||||
= t("notifier.mentioned.limited_post")
|
||||
|
||||
%p
|
||||
= link_to t("notifier.comment_on_post.reply", name: @notification.post.author_first_name),
|
||||
post_url(@notification.post)
|
||||
@@ -1,9 +0,0 @@
|
||||
<% if @notification.post.public? %>
|
||||
<%= post_message(@notification.post, :process_newlines => true) %>
|
||||
<% else %>
|
||||
<%= t('notifier.mentioned.limited_post') %>
|
||||
<% end %>
|
||||
|
||||
[<%= t("notifier.comment_on_post.reply", name: @notification.post_author_name) %>][1]
|
||||
|
||||
[1]: <%= post_url(@notification.post) %>
|
||||
8
app/views/notifier/mentioned.text.erb
Normal file
8
app/views/notifier/mentioned.text.erb
Normal file
@@ -0,0 +1,8 @@
|
||||
<% if @notification.post.public? %>
|
||||
<%= post_message(@notification.post) %>
|
||||
<% else %>
|
||||
<%= t("notifier.mentioned.limited_post") %>
|
||||
<% end %>
|
||||
|
||||
<%= t("notifier.comment_on_post.reply", name: @notification.post.author_first_name) %>
|
||||
<%= post_url(@notification.post) %>
|
||||
9
app/views/notifier/mentioned_in_comment.html.haml
Normal file
9
app/views/notifier/mentioned_in_comment.html.haml
Normal file
@@ -0,0 +1,9 @@
|
||||
- if @notification.comment.public?
|
||||
= @notification.comment.message.markdownified_for_mail
|
||||
- else
|
||||
%p
|
||||
= t("notifier.mentioned_in_comment.limited_post")
|
||||
|
||||
%p
|
||||
= link_to t("notifier.mentioned_in_comment.reply"),
|
||||
post_url(@notification.comment.post, anchor: @notification.comment.guid)
|
||||
@@ -4,6 +4,5 @@
|
||||
<%= t("notifier.mentioned_in_comment.limited_post") %>
|
||||
<% end %>
|
||||
|
||||
[<%= t("notifier.mentioned_in_comment.reply") %>][1]
|
||||
|
||||
[1]: <%= post_url(@notification.comment.parent, anchor: @notification.comment.guid) %>
|
||||
<%= t("notifier.mentioned_in_comment.reply") %>
|
||||
<%= post_url(@notification.comment.parent, anchor: @notification.comment.guid) %>
|
||||
2
app/views/notifier/plain_markdown_email.html.haml
Normal file
2
app/views/notifier/plain_markdown_email.html.haml
Normal file
@@ -0,0 +1,2 @@
|
||||
%div{style: "font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px"}
|
||||
!= Redcarpet::Markdown.new(Diaspora::Markdownify::Email).render(body)
|
||||
1
app/views/notifier/plain_markdown_email.text.haml
Normal file
1
app/views/notifier/plain_markdown_email.text.haml
Normal file
@@ -0,0 +1 @@
|
||||
!= body
|
||||
4
app/views/notifier/private_message.html.haml
Normal file
4
app/views/notifier/private_message.html.haml
Normal file
@@ -0,0 +1,4 @@
|
||||
%p
|
||||
= t("notifier.a_private_message")
|
||||
%p
|
||||
= link_to t(".reply_to_or_view"), conversations_url(conversation_id: @notification.conversation)
|
||||
@@ -1,5 +0,0 @@
|
||||
<%= t('notifier.a_private_message') %>
|
||||
|
||||
[<%= t('.reply_to_or_view') %>][1]
|
||||
|
||||
[1]: <%= conversations_url(:conversation_id => @notification.conversation) %>
|
||||
4
app/views/notifier/private_message.text.erb
Normal file
4
app/views/notifier/private_message.text.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<%= t("notifier.a_private_message") %>
|
||||
|
||||
<%= t(".reply_to_or_view") %>
|
||||
<%= conversations_url(conversation_id: @notification.conversation) %>
|
||||
5
app/views/notifier/reshared.html.haml
Normal file
5
app/views/notifier/reshared.html.haml
Normal file
@@ -0,0 +1,5 @@
|
||||
%p
|
||||
#{t('.reshared', name: @notification.sender_name)}:
|
||||
= post_message(@notification.reshare_root, html: true)
|
||||
%p
|
||||
= link_to t(".view_post"), post_url(@notification.reshare)
|
||||
@@ -1,7 +0,0 @@
|
||||
<%= "#{t('.reshared', :name => "#{@notification.sender_name}")}:" %>
|
||||
|
||||
<%= post_message(@notification.reshare_root, :process_newlines => true) %>
|
||||
|
||||
[<%= t('.view_post') %>][1]
|
||||
|
||||
[1]: <%= post_url(@notification.reshare) %>
|
||||
6
app/views/notifier/reshared.text.erb
Normal file
6
app/views/notifier/reshared.text.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<%= "#{t(".reshared", name: @notification.sender_name)}:" %>
|
||||
|
||||
<%= post_message(@notification.reshare_root) %>
|
||||
|
||||
<%= t(".view_post") %>
|
||||
<%= post_url(@notification.reshare) %>
|
||||
8
app/views/notifier/single_admin.html.haml
Normal file
8
app/views/notifier/single_admin.html.haml
Normal file
@@ -0,0 +1,8 @@
|
||||
%p
|
||||
= t("notifier.hello", name: @receiver.username)
|
||||
%p
|
||||
= @string
|
||||
%p
|
||||
= t("notifier.thanks")
|
||||
%br/
|
||||
= t("notifier.single_admin.admin")
|
||||
@@ -1,7 +0,0 @@
|
||||
<%= t('notifier.hello', :name => @receiver.username) %>
|
||||
|
||||
<%= @string %>
|
||||
|
||||
<%= t('notifier.thanks') %>
|
||||
|
||||
<%= t('notifier.single_admin.admin') %>
|
||||
6
app/views/notifier/single_admin.text.erb
Normal file
6
app/views/notifier/single_admin.text.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<%= t("notifier.hello", name: @receiver.username) %>
|
||||
|
||||
<%= @string %>
|
||||
|
||||
<%= t("notifier.thanks") %>
|
||||
<%= t("notifier.single_admin.admin") %>
|
||||
7
app/views/notifier/started_sharing.html.haml
Normal file
7
app/views/notifier/started_sharing.html.haml
Normal file
@@ -0,0 +1,7 @@
|
||||
%p
|
||||
= @notification.sender_name
|
||||
= t(".sharing")
|
||||
|
||||
%p
|
||||
= link_to t(".view_profile", name: @notification.sender_first_name),
|
||||
local_or_remote_person_path(@notification.sender, absolute: true)
|
||||
@@ -1,5 +0,0 @@
|
||||
<%= @notification.sender_name %> <%= t('.sharing') %>
|
||||
|
||||
[<%= t('.view_profile', :name => @notification.sender_first_name) %>][1]
|
||||
|
||||
[1]: <%= local_or_remote_person_path(@notification.sender, :absolute => true) %>
|
||||
4
app/views/notifier/started_sharing.text.erb
Normal file
4
app/views/notifier/started_sharing.text.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<%= @notification.sender_name %> <%= t(".sharing") %>
|
||||
|
||||
<%= t(".view_profile", name: @notification.sender_first_name) %>
|
||||
<%= local_or_remote_person_path(@notification.sender, absolute: true) %>
|
||||
@@ -1,5 +0,0 @@
|
||||
<%= t("notifier.report_email.body",
|
||||
url: resource[:url],
|
||||
type: resource[:type],
|
||||
id: resource[:id],
|
||||
reason: resource[:reason]) %>
|
||||
@@ -1 +0,0 @@
|
||||
<%= t('notifier.export_email.body', url: download_profile_user_url, name: @user.first_name) %>
|
||||
@@ -1 +0,0 @@
|
||||
<%= t('notifier.export_failure_email.body', name: @user.first_name) %>
|
||||
@@ -1 +0,0 @@
|
||||
<%= t('notifier.export_photos_email.body', url: download_photos_user_url, name: @user.first_name) %>
|
||||
@@ -1 +0,0 @@
|
||||
<%= t('notifier.export_photos_failure_email.body', name: @user.first_name) %>
|
||||
@@ -4,7 +4,6 @@
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
|
||||
module Workers
|
||||
class ExportPhotos < Base
|
||||
sidekiq_options queue: :low
|
||||
@@ -14,9 +13,9 @@ module Workers
|
||||
@user.perform_export_photos!
|
||||
|
||||
if @user.reload.exported_photos_file.present?
|
||||
ExportMailer.export_photos_complete_for(@user)
|
||||
ExportMailer.export_photos_complete_for(@user).deliver_now
|
||||
else
|
||||
ExportMailer.export_photos_failure_for(@user)
|
||||
ExportMailer.export_photos_failure_for(@user).deliver_now
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Rails.application.config.markerb.renderer = Diaspora::Markdownify::Email
|
||||
@@ -741,7 +741,7 @@ en:
|
||||
started_sharing:
|
||||
subject: "%{name} started sharing with you on diaspora*"
|
||||
sharing: "has started sharing with you!"
|
||||
view_profile: "View %{name}’s profile"
|
||||
view_profile: "View %{name}’s profile >"
|
||||
comment_on_post:
|
||||
limited_subject: "There's a new comment on one of your posts"
|
||||
reply: "Reply or view %{name}’s post >"
|
||||
@@ -766,7 +766,7 @@ en:
|
||||
contacts_birthday:
|
||||
subject: "%{name} has their birthday today"
|
||||
birthday: "%{name} has their birthday today. Wish them 'Happy Birthday'!"
|
||||
view_profile: "View %{name}’s profile"
|
||||
view_profile: "View %{name}’s profile >"
|
||||
confirm_email:
|
||||
subject: "Please activate your new email address %{unconfirmed_email}"
|
||||
click_link: "To activate your new email address %{unconfirmed_email}, please follow this link:"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Diaspora::Mentionable
|
||||
@@ -55,8 +54,9 @@ module Diaspora::Mentionable
|
||||
#
|
||||
# @param [String] message text
|
||||
# @param [Array] allowed_people ids of people that are allowed to stay
|
||||
# @param [Boolean] absolute_links (false) render mentions with absolute links
|
||||
# @return [String] message text with filtered mentions
|
||||
def self.filter_people(msg_text, allowed_people)
|
||||
def self.filter_people(msg_text, allowed_people, absolute_links: false)
|
||||
mentioned_ppl = people_from_string(msg_text)
|
||||
|
||||
msg_text.to_s.gsub(REGEX) {|match_str|
|
||||
@@ -66,7 +66,7 @@ module Diaspora::Mentionable
|
||||
if person && allowed_people.include?(person.id)
|
||||
match_str
|
||||
else
|
||||
"@#{MentionsInternal.profile_link(person, name, diaspora_id)}"
|
||||
"@#{MentionsInternal.profile_link(person, name, diaspora_id, absolute: absolute_links)}"
|
||||
end
|
||||
}
|
||||
end
|
||||
@@ -79,7 +79,7 @@ module Diaspora::Mentionable
|
||||
|
||||
# inline module for namespacing
|
||||
module MentionsInternal
|
||||
extend ::PeopleHelper
|
||||
extend ERB::Util
|
||||
|
||||
# output a formatted mention link as defined by the given arguments.
|
||||
# if the display name is blank, falls back to the person's name.
|
||||
@@ -91,10 +91,15 @@ module Diaspora::Mentionable
|
||||
def self.mention_link(person, display_name, diaspora_id, opts)
|
||||
return display_name || diaspora_id unless person.present?
|
||||
|
||||
display_name ||= person.name
|
||||
if opts[:plain_text]
|
||||
display_name || person.name
|
||||
display_name
|
||||
else
|
||||
person_link(person, class: PERSON_HREF_CLASS, display_name: display_name)
|
||||
# rubocop:disable Rails/OutputSafety
|
||||
remote_or_hovercard_link = Rails.application.routes.url_helpers.person_path(person).html_safe
|
||||
"<a data-hovercard=\"#{remote_or_hovercard_link}\" href=\"#{remote_or_hovercard_link}\" " \
|
||||
"class=\"#{PERSON_HREF_CLASS}\">#{html_escape_once(display_name)}</a>".html_safe
|
||||
# rubocop:enable Rails/OutputSafety
|
||||
end
|
||||
end
|
||||
|
||||
@@ -103,11 +108,14 @@ module Diaspora::Mentionable
|
||||
#
|
||||
# @param [Person] AR Person
|
||||
# @param [String] display name
|
||||
# @param [String] diaspora_id
|
||||
# @param [Boolean] absolute (false) render absolute link
|
||||
# @return [String] markdown person link
|
||||
def self.profile_link(person, display_name, diaspora_id)
|
||||
def self.profile_link(person, display_name, diaspora_id, absolute: false)
|
||||
return display_name || diaspora_id unless person.present?
|
||||
|
||||
"[#{display_name || person.name}](#{local_or_remote_person_path(person)})"
|
||||
url_helper = Rails.application.routes.url_helpers
|
||||
"[#{display_name || person.name}](#{absolute ? url_helper.person_url(person) : url_helper.person_path(person)})"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -56,8 +56,8 @@ module Diaspora
|
||||
@message = renderer.render(message).strip
|
||||
end
|
||||
|
||||
def markdownify
|
||||
renderer = Diaspora::Markdownify::HTML.new options[:markdown_render_options]
|
||||
def markdownify(renderer_class=Diaspora::Markdownify::HTML)
|
||||
renderer = renderer_class.new options[:markdown_render_options]
|
||||
markdown = Redcarpet::Markdown.new renderer, options[:markdown_options]
|
||||
|
||||
@message = markdown.render message
|
||||
@@ -76,8 +76,8 @@ module Diaspora
|
||||
@message = Diaspora::Mentionable.format message, options[:mentioned_people]
|
||||
end
|
||||
|
||||
if options[:disable_hovercards] || options[:link_all_mentions]
|
||||
@message = Diaspora::Mentionable.filter_people message, []
|
||||
if options[:disable_hovercards]
|
||||
@message = Diaspora::Mentionable.filter_people(message, [], absolute_links: true)
|
||||
else
|
||||
make_mentions_plain_text
|
||||
end
|
||||
@@ -108,7 +108,6 @@ module Diaspora
|
||||
end
|
||||
|
||||
DEFAULTS = {mentioned_people: [],
|
||||
link_all_mentions: false,
|
||||
disable_hovercards: false,
|
||||
truncate: false,
|
||||
append: nil,
|
||||
@@ -137,12 +136,8 @@ module Diaspora
|
||||
# @param [Hash] opts Global options affecting output
|
||||
# @option opts [Array<Person>] :mentioned_people ([]) List of people
|
||||
# allowed to mention
|
||||
# @option opts [Boolean] :link_all_mentions (false) Whether to link
|
||||
# all mentions. This makes plain links to profiles for people not in
|
||||
# :mentioned_people
|
||||
# @option opts [Boolean] :disable_hovercards (true) Render all mentions
|
||||
# as profile links. This implies :link_all_mentions and ignores
|
||||
# :mentioned_people
|
||||
# as absolute profile links. This ignores :mentioned_people
|
||||
# @option opts [#to_i, Boolean] :truncate (false) Truncate message to
|
||||
# the specified length
|
||||
# @option opts [String] :append (nil) Append text to the end of
|
||||
@@ -205,7 +200,7 @@ module Diaspora
|
||||
render_tags
|
||||
squish
|
||||
append_and_truncate
|
||||
}.html_safe
|
||||
}.html_safe # rubocop:disable Rails/OutputSafety
|
||||
end
|
||||
|
||||
# @param [Hash] opts Override global output options, see {#initialize}
|
||||
@@ -220,7 +215,20 @@ module Diaspora
|
||||
render_tags
|
||||
squish
|
||||
append_and_truncate
|
||||
}.html_safe
|
||||
}.html_safe # rubocop:disable Rails/OutputSafety
|
||||
end
|
||||
|
||||
def markdownified_for_mail
|
||||
process(disable_hovercards: true) {
|
||||
process_newlines
|
||||
normalize
|
||||
diaspora_links
|
||||
camo_urls if AppConfig.privacy.camo.proxy_markdown_images?
|
||||
render_mentions
|
||||
markdownify(Diaspora::Markdownify::Email)
|
||||
squish
|
||||
append_and_truncate
|
||||
}.html_safe # rubocop:disable Rails/OutputSafety
|
||||
end
|
||||
|
||||
# Get a short summary of the message
|
||||
|
||||
BIN
spec/fixtures/autumn_1440x960.heic
vendored
Normal file
BIN
spec/fixtures/autumn_1440x960.heic
vendored
Normal file
Binary file not shown.
@@ -5,18 +5,23 @@
|
||||
# the COPYRIGHT file.
|
||||
|
||||
describe NotifierHelper, :type => :helper do
|
||||
describe '#post_message' do
|
||||
describe "#post_message" do
|
||||
before do
|
||||
# post for markdown test
|
||||
@markdown_post = FactoryBot.create(:status_message,
|
||||
text: "[link](http://diasporafoundation.org) **bold text** *other text*", public: true)
|
||||
@striped_markdown_post = "link (http://diasporafoundation.org) bold text other text"
|
||||
text: "[link](https://diasporafoundation.org) **bold text** *other text*",
|
||||
public: true)
|
||||
@striped_markdown_post = "link (https://diasporafoundation.org) bold text other text"
|
||||
end
|
||||
|
||||
it 'strip markdown in the post' do
|
||||
it "strip markdown in the post" do
|
||||
expect(post_message(@markdown_post)).to eq(@striped_markdown_post)
|
||||
end
|
||||
|
||||
it "renders markdown as html" do
|
||||
expect(post_message(@markdown_post, html: true)).to include("<a href=\"https://diasporafoundation.org\">link</a>")
|
||||
end
|
||||
|
||||
it "falls back to the title if the post has no text" do
|
||||
photo = FactoryBot.build(:photo, public: true)
|
||||
photo_post = FactoryBot.build(:status_message, author: photo.author, text: "", photos: [photo], public: true)
|
||||
@@ -32,13 +37,13 @@ describe NotifierHelper, :type => :helper do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#comment_message' do
|
||||
describe "#comment_message" do
|
||||
before do
|
||||
# comment for markdown test
|
||||
@markdown_comment = FactoryBot.create(:comment)
|
||||
@markdown_comment.post.public = true
|
||||
@markdown_comment.text = "[link](http://diasporafoundation.org) **bold text** *other text*"
|
||||
@striped_markdown_comment = "link (http://diasporafoundation.org) bold text other text"
|
||||
@markdown_comment.text = "[link](https://diasporafoundation.org) **bold text** *other text*"
|
||||
@striped_markdown_comment = "link (https://diasporafoundation.org) bold text other text"
|
||||
|
||||
# comment for limited post
|
||||
@limited_comment = FactoryBot.create(:comment)
|
||||
@@ -46,11 +51,16 @@ describe NotifierHelper, :type => :helper do
|
||||
@limited_comment.text = "This is top secret comment. Shhhhhhhh!!!"
|
||||
end
|
||||
|
||||
it 'strip markdown in the comment' do
|
||||
it "strip markdown in the comment" do
|
||||
expect(comment_message(@markdown_comment)).to eq(@striped_markdown_comment)
|
||||
end
|
||||
|
||||
it 'hides the private content' do
|
||||
it "renders markdown as html" do
|
||||
expect(comment_message(@markdown_comment, html: true))
|
||||
.to include("<a href=\"https://diasporafoundation.org\">link</a>")
|
||||
end
|
||||
|
||||
it "hides the private content" do
|
||||
expect(comment_message(@limited_comment)).not_to include("secret comment")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -75,7 +75,7 @@ describe PeopleHelper, :type => :helper do
|
||||
end
|
||||
|
||||
it 'links by id for a local user' do
|
||||
expect(person_link(@user.person)).to include "href='#{person_path(@user.person)}'"
|
||||
expect(person_link(@user.person)).to include "href=\"#{person_path(@user.person)}\""
|
||||
end
|
||||
|
||||
it "recognizes the 'display_name' option" do
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe Diaspora::Mentionable do
|
||||
include PeopleHelper
|
||||
|
||||
let(:people) { [alice, bob, eve].map(&:person) }
|
||||
let(:names) { %w(Alice\ A Bob\ B "Eve>\ E) }
|
||||
|
||||
@@ -41,7 +39,9 @@ STR
|
||||
end
|
||||
|
||||
describe ".format" do
|
||||
context "html output" do
|
||||
context "html output", type: :helper do
|
||||
include PeopleHelper
|
||||
|
||||
it "adds the links to the formatted message" do
|
||||
fmt_msg = Diaspora::Mentionable.format(test_text_with_names, people)
|
||||
|
||||
@@ -75,7 +75,7 @@ STR
|
||||
fmt_msg = Diaspora::Mentionable.format(test_txt, people)
|
||||
|
||||
expect(fmt_msg).not_to include(name)
|
||||
expect(fmt_msg).to include(">", "<", "'") # ">", "<", "'"
|
||||
expect(fmt_msg).to include("</a><script>alert('h')</script>")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -184,7 +184,7 @@ STR
|
||||
user_a.aspects.where(name: "generic").first.contacts.map(&:person_id)
|
||||
)
|
||||
|
||||
expect(txt).to include("@[user C](#{local_or_remote_person_path(user_c.person)}")
|
||||
expect(txt).to include("@[user C](#{Rails.application.routes.url_helpers.person_path(user_c.person)}")
|
||||
expect(txt).not_to include("href")
|
||||
expect(txt).not_to include(mention)
|
||||
end
|
||||
|
||||
@@ -78,12 +78,6 @@ describe Diaspora::MessageRenderer do
|
||||
end
|
||||
|
||||
context 'linking all mentions' do
|
||||
it 'makes plain links for people not in the post aspects' do
|
||||
message = message("@{Bob; #{bob.person.diaspora_handle}}", link_all_mentions: true).html
|
||||
expect(message).to_not include 'hovercard'
|
||||
expect(message).to include '/u/bob'
|
||||
end
|
||||
|
||||
it "makes no hovercards if they're disabled" do
|
||||
message = message(
|
||||
"@{Bob; #{bob.person.diaspora_handle}}",
|
||||
@@ -91,7 +85,7 @@ describe Diaspora::MessageRenderer do
|
||||
disable_hovercards: true
|
||||
).html
|
||||
expect(message).to_not include 'hovercard'
|
||||
expect(message).to include '/u/bob'
|
||||
expect(message).to include AppConfig.url_to("/people/#{bob.person.guid}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -121,10 +121,6 @@ describe Notifier, type: :mailer do
|
||||
it "has the post text in the body" do
|
||||
expect(@mail.body.encoded).to include(@post.text)
|
||||
end
|
||||
|
||||
it "should not include translation fallback" do
|
||||
expect(@mail.body.encoded).not_to include(I18n.translate "notifier.a_post_you_shared")
|
||||
end
|
||||
end
|
||||
|
||||
describe ".mentioned_in_comment" do
|
||||
@@ -180,10 +176,6 @@ describe Notifier, type: :mailer do
|
||||
it "has the post text not in the body" do
|
||||
expect(@mail.body.encoded).not_to include(@post.text)
|
||||
end
|
||||
|
||||
it "should not include translation fallback" do
|
||||
expect(@mail.body.encoded).not_to include(I18n.translate "notifier.a_post_you_shared")
|
||||
end
|
||||
end
|
||||
|
||||
describe ".liked" do
|
||||
@@ -205,10 +197,6 @@ describe Notifier, type: :mailer do
|
||||
expect(@mail.body.encoded).to include(@like.author.name)
|
||||
end
|
||||
|
||||
it "should not include translation fallback" do
|
||||
expect(@mail.body.encoded).not_to include(I18n.translate "notifier.a_post_you_shared")
|
||||
end
|
||||
|
||||
it "can handle a reshare" do
|
||||
reshare = FactoryBot.create(:reshare)
|
||||
like = reshare.likes.create!(author: bob.person)
|
||||
@@ -247,10 +235,6 @@ describe Notifier, type: :mailer do
|
||||
it "BODY: contains the name of person liking" do
|
||||
expect(@mail.body.encoded).to include(@reshare.author.name)
|
||||
end
|
||||
|
||||
it "should not include translation fallback" do
|
||||
expect(@mail.body.encoded).not_to include(I18n.translate "notifier.a_post_you_shared")
|
||||
end
|
||||
end
|
||||
|
||||
describe ".private_message" do
|
||||
@@ -294,10 +278,6 @@ describe Notifier, type: :mailer do
|
||||
it "BODY: does not contain the message text" do
|
||||
expect(@mail.body.encoded).not_to include(@cnv.messages.first.text)
|
||||
end
|
||||
|
||||
it "should not include translation fallback" do
|
||||
expect(@mail.body.encoded).not_to include(I18n.translate "notifier.a_post_you_shared")
|
||||
end
|
||||
end
|
||||
|
||||
context "comments" do
|
||||
@@ -334,10 +314,6 @@ describe Notifier, type: :mailer do
|
||||
it "contains the original post's link with comment anchor" do
|
||||
expect(comment_mail.body.encoded).to include("#{comment.post.id}##{comment.guid}")
|
||||
end
|
||||
|
||||
it "should not include translation fallback" do
|
||||
expect(comment_mail.body.encoded).not_to include(I18n.translate "notifier.a_post_you_shared")
|
||||
end
|
||||
end
|
||||
|
||||
[:reshare].each do |post_type|
|
||||
@@ -380,10 +356,6 @@ describe Notifier, type: :mailer do
|
||||
it "contains the original post's link with comment anchor" do
|
||||
expect(comment_mail.body.encoded).to include("#{comment.post.id}##{comment.guid}")
|
||||
end
|
||||
|
||||
it "should not include translation fallback" do
|
||||
expect(comment_mail.body.encoded).not_to include(I18n.translate "notifier.a_post_you_shared")
|
||||
end
|
||||
end
|
||||
[:reshare].each do |post_type|
|
||||
context post_type.to_s do
|
||||
@@ -490,10 +462,6 @@ describe Notifier, type: :mailer do
|
||||
it "BODY: contains the name of person liking" do
|
||||
expect(mail.body.encoded).to include(bob.name)
|
||||
end
|
||||
|
||||
it "should not include translation fallback" do
|
||||
expect(mail.body.encoded).not_to include(I18n.translate "notifier.a_post_you_shared")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -580,16 +548,16 @@ describe Notifier, type: :mailer do
|
||||
|
||||
it "has some informative text in the body" do
|
||||
email.body.parts.each do |part|
|
||||
expect(part.decoded).to include("https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)")
|
||||
expect(part.decoded).to include("https://owasp.org/www-community/attacks/csrf")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "hashtags" do
|
||||
it "escapes hashtags" do
|
||||
mails = Notifier.admin("#Welcome to bureaucracy!", [bob])
|
||||
expect(mails.length).to eq(1)
|
||||
mail = mails.first
|
||||
status = FactoryBot.create(:status_message, author: alice.person, text: "#Welcome to bureaucracy!", public: true)
|
||||
like = status.likes.create!(author: bob.person)
|
||||
mail = Notifier.send_notification("liked", alice.id, like.author.id, like.id)
|
||||
expect(mail.body.encoded).to match(
|
||||
"<p><a href=\"#{AppConfig.url_to(tag_path('welcome'))}\">#Welcome</a> to bureaucracy!</p>"
|
||||
)
|
||||
|
||||
@@ -17,12 +17,13 @@ describe Photo, :type => :model do
|
||||
@aspect = @user.aspects.first
|
||||
|
||||
@fixture_filename = 'button.png'
|
||||
|
||||
@fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', @fixture_filename)
|
||||
@fail_fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', 'msg.xml')
|
||||
|
||||
@photo = @user.build_post(:photo, :user_file => File.open(@fixture_name), :to => @aspect.id)
|
||||
@photo2 = @user.build_post(:photo, :user_file => File.open(@fixture_name), :to => @aspect.id)
|
||||
@saved_photo = @user.build_post(:photo, :user_file => File.open(@fixture_name), :to => @aspect.id)
|
||||
@photo = @user.build_post(:photo, user_file: File.open(@fixture_name), to: @aspect.id)
|
||||
@photo2 = @user.build_post(:photo, user_file: File.open(@fixture_name), to: @aspect.id)
|
||||
@saved_photo = @user.build_post(:photo, user_file: File.open(@fixture_name), to: @aspect.id)
|
||||
@saved_photo.save
|
||||
end
|
||||
|
||||
@@ -90,7 +91,7 @@ describe Photo, :type => :model do
|
||||
@photo.update_remote_path
|
||||
|
||||
expect(@photo.remote_photo_path).to include("http")
|
||||
expect(@photo.remote_photo_name).to include(".png")
|
||||
expect(@photo.remote_photo_name).to include(".webp")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -182,7 +183,15 @@ describe Photo, :type => :model do
|
||||
@photo.unprocessed_image.store! file
|
||||
}.to raise_error CarrierWave::IntegrityError
|
||||
end
|
||||
end
|
||||
|
||||
describe "converting files" do
|
||||
it "convert to webp" do
|
||||
with_carrierwave_processing do
|
||||
@photo.unprocessed_image.store! File.open(@fixture_name)
|
||||
end
|
||||
expect(@photo.remote_photo_name).to include(".webp")
|
||||
end
|
||||
end
|
||||
|
||||
describe "remote photos" do
|
||||
|
||||
@@ -12,8 +12,8 @@ describe Workers::ResetPassword do
|
||||
Workers::ResetPassword.new.perform(alice.id)
|
||||
mail = Devise.mailer.deliveries.last
|
||||
expect(mail.to).to eq([alice.email])
|
||||
expect(mail.body).to include("change your password")
|
||||
expect(mail.body).to include(alice.username)
|
||||
expect(mail.body.encoded).to include("change your password")
|
||||
expect(mail.body.encoded).to include(alice.username)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user