From d1aef17f9ad0074458ad0b390ac73db228928f07 Mon Sep 17 00:00:00 2001 From: ThibG Date: Fri, 4 May 2018 20:17:01 +0200 Subject: Do not render first page of following and followers collections unless explicitly asked to (#7357) --- app/controllers/follower_accounts_controller.rb | 30 +++++++++++++----------- app/controllers/following_accounts_controller.rb | 30 +++++++++++++----------- 2 files changed, 32 insertions(+), 28 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/follower_accounts_controller.rb b/app/controllers/follower_accounts_controller.rb index 2d2315034..ac0d4c54e 100644 --- a/app/controllers/follower_accounts_controller.rb +++ b/app/controllers/follower_accounts_controller.rb @@ -4,11 +4,10 @@ class FollowerAccountsController < ApplicationController include AccountControllerConcern def index - @follows = Follow.where(target_account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:account) - respond_to do |format| format.html do - @relationships = AccountRelationshipsPresenter.new(@follows.map(&:account_id), current_user.account_id) if user_signed_in? + follows + @relationships = AccountRelationshipsPresenter.new(follows.map(&:account_id), current_user.account_id) if user_signed_in? end format.json do @@ -22,28 +21,31 @@ class FollowerAccountsController < ApplicationController private + def follows + @follows ||= Follow.where(target_account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:account) + end + def page_url(page) account_followers_url(@account, page: page) unless page.nil? end def collection_presenter - page = ActivityPub::CollectionPresenter.new( - id: account_followers_url(@account, page: params.fetch(:page, 1)), - type: :ordered, - size: @account.followers_count, - items: @follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.account) }, - part_of: account_followers_url(@account), - next: page_url(@follows.next_page), - prev: page_url(@follows.prev_page) - ) if params[:page].present? - page + ActivityPub::CollectionPresenter.new( + id: account_followers_url(@account, page: params.fetch(:page, 1)), + type: :ordered, + size: @account.followers_count, + items: follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.account) }, + part_of: account_followers_url(@account), + next: page_url(follows.next_page), + prev: page_url(follows.prev_page) + ) else ActivityPub::CollectionPresenter.new( id: account_followers_url(@account), type: :ordered, size: @account.followers_count, - first: page + first: page_url(1) ) end end diff --git a/app/controllers/following_accounts_controller.rb b/app/controllers/following_accounts_controller.rb index 169f9057d..974d95c8e 100644 --- a/app/controllers/following_accounts_controller.rb +++ b/app/controllers/following_accounts_controller.rb @@ -4,11 +4,10 @@ class FollowingAccountsController < ApplicationController include AccountControllerConcern def index - @follows = Follow.where(account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:target_account) - respond_to do |format| format.html do - @relationships = AccountRelationshipsPresenter.new(@follows.map(&:target_account_id), current_user.account_id) if user_signed_in? + follows + @relationships = AccountRelationshipsPresenter.new(follows.map(&:target_account_id), current_user.account_id) if user_signed_in? end format.json do @@ -22,28 +21,31 @@ class FollowingAccountsController < ApplicationController private + def follows + @follows ||= Follow.where(account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:target_account) + end + def page_url(page) account_following_index_url(@account, page: page) unless page.nil? end def collection_presenter - page = ActivityPub::CollectionPresenter.new( - id: account_following_index_url(@account, page: params.fetch(:page, 1)), - type: :ordered, - size: @account.following_count, - items: @follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.target_account) }, - part_of: account_following_index_url(@account), - next: page_url(@follows.next_page), - prev: page_url(@follows.prev_page) - ) if params[:page].present? - page + ActivityPub::CollectionPresenter.new( + id: account_following_index_url(@account, page: params.fetch(:page, 1)), + type: :ordered, + size: @account.following_count, + items: follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.target_account) }, + part_of: account_following_index_url(@account), + next: page_url(follows.next_page), + prev: page_url(follows.prev_page) + ) else ActivityPub::CollectionPresenter.new( id: account_following_index_url(@account), type: :ordered, size: @account.following_count, - first: page + first: page_url(1) ) end end -- cgit From c7d1a2e400cd6677057a8af90fff866207576098 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 5 May 2018 23:06:29 +0200 Subject: Improve admin UI for accounts (#7360) * Improve design of account statuses admin UI (consistent with reports) * Make account moderation notes look consistent with report notes * i18n-tasks remove-unused * Fix code style issues * Fix tests --- .../admin/reported_statuses_controller.rb | 19 -------- app/controllers/admin/statuses_controller.rb | 35 +++++---------- app/javascript/styles/mastodon/admin.scss | 3 +- .../_account_moderation_note.html.haml | 15 +++---- app/views/admin/accounts/show.html.haml | 39 +++++++--------- app/views/admin/reports/_status.html.haml | 2 +- app/views/admin/statuses/index.html.haml | 52 +++++++++------------- config/locales/ar.yml | 9 ---- config/locales/ca.yml | 9 ---- config/locales/de.yml | 9 ---- config/locales/en.yml | 11 +---- config/locales/eo.yml | 9 ---- config/locales/es.yml | 9 ---- config/locales/fa.yml | 9 ---- config/locales/fi.yml | 9 ---- config/locales/fr.yml | 9 ---- config/locales/gl.yml | 9 ---- config/locales/he.yml | 6 --- config/locales/hu.yml | 9 ---- config/locales/id.yml | 1 - config/locales/io.yml | 1 - config/locales/it.yml | 9 ---- config/locales/ja.yml | 9 ---- config/locales/ko.yml | 9 ---- config/locales/nl.yml | 9 ---- config/locales/no.yml | 9 ---- config/locales/oc.yml | 9 ---- config/locales/pl.yml | 9 ---- config/locales/pt-BR.yml | 9 ---- config/locales/pt.yml | 9 ---- config/locales/ru.yml | 9 ---- config/locales/sk.yml | 9 ---- config/locales/sr-Latn.yml | 9 ---- config/locales/sr.yml | 9 ---- config/locales/sv.yml | 9 ---- config/locales/th.yml | 1 - config/locales/tr.yml | 1 - config/locales/uk.yml | 1 - config/locales/zh-CN.yml | 9 ---- config/locales/zh-HK.yml | 9 ---- config/locales/zh-TW.yml | 1 - config/routes.rb | 4 +- .../admin/reported_statuses_controller_spec.rb | 49 ++++---------------- spec/controllers/admin/statuses_controller_spec.rb | 48 ++++---------------- 44 files changed, 77 insertions(+), 446 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/reported_statuses_controller.rb b/app/controllers/admin/reported_statuses_controller.rb index 522f68c98..d3c2f5e9e 100644 --- a/app/controllers/admin/reported_statuses_controller.rb +++ b/app/controllers/admin/reported_statuses_controller.rb @@ -3,7 +3,6 @@ module Admin class ReportedStatusesController < BaseController before_action :set_report - before_action :set_status, only: [:update, :destroy] def create authorize :status, :update? @@ -14,20 +13,6 @@ module Admin redirect_to admin_report_path(@report) end - def update - authorize @status, :update? - @status.update!(status_params) - log_action :update, @status - redirect_to admin_report_path(@report) - end - - def destroy - authorize @status, :destroy? - RemovalWorker.perform_async(@status.id) - log_action :destroy, @status - render json: @status - end - private def status_params @@ -51,9 +36,5 @@ module Admin def set_report @report = Report.find(params[:report_id]) end - - def set_status - @status = @report.statuses.find(params[:id]) - end end end diff --git a/app/controllers/admin/statuses_controller.rb b/app/controllers/admin/statuses_controller.rb index d5787acfb..382bfc4a2 100644 --- a/app/controllers/admin/statuses_controller.rb +++ b/app/controllers/admin/statuses_controller.rb @@ -5,7 +5,6 @@ module Admin helper_method :current_params before_action :set_account - before_action :set_status, only: [:update, :destroy] PER_PAGE = 20 @@ -26,40 +25,18 @@ module Admin def create authorize :status, :update? - @form = Form::StatusBatch.new(form_status_batch_params.merge(current_account: current_account)) + @form = Form::StatusBatch.new(form_status_batch_params.merge(current_account: current_account, action: action_from_button)) flash[:alert] = I18n.t('admin.statuses.failed_to_execute') unless @form.save redirect_to admin_account_statuses_path(@account.id, current_params) end - def update - authorize @status, :update? - @status.update!(status_params) - log_action :update, @status - redirect_to admin_account_statuses_path(@account.id, current_params) - end - - def destroy - authorize @status, :destroy? - RemovalWorker.perform_async(@status.id) - log_action :destroy, @status - render json: @status - end - private - def status_params - params.require(:status).permit(:sensitive) - end - def form_status_batch_params params.require(:form_status_batch).permit(:action, status_ids: []) end - def set_status - @status = @account.statuses.find(params[:id]) - end - def set_account @account = Account.find(params[:account_id]) end @@ -72,5 +49,15 @@ module Admin page: page > 1 && page, }.select { |_, value| value.present? } end + + def action_from_button + if params[:nsfw_on] + 'nsfw_on' + elsif params[:nsfw_off] + 'nsfw_off' + elsif params[:delete] + 'delete' + end + end end end diff --git a/app/javascript/styles/mastodon/admin.scss b/app/javascript/styles/mastodon/admin.scss index a6cc8b62b..1948a2a23 100644 --- a/app/javascript/styles/mastodon/admin.scss +++ b/app/javascript/styles/mastodon/admin.scss @@ -336,7 +336,8 @@ } } -.simple_form.new_report_note { +.simple_form.new_report_note, +.simple_form.new_account_moderation_note { max-width: 100%; } diff --git a/app/views/admin/account_moderation_notes/_account_moderation_note.html.haml b/app/views/admin/account_moderation_notes/_account_moderation_note.html.haml index 6761a4319..432fb79a6 100644 --- a/app/views/admin/account_moderation_notes/_account_moderation_note.html.haml +++ b/app/views/admin/account_moderation_notes/_account_moderation_note.html.haml @@ -1,10 +1,7 @@ -%tr - %td +.speech-bubble + .speech-bubble__bubble = simple_format(h(account_moderation_note.content)) - %td - = account_moderation_note.account.acct - %td - %time.formatted{ datetime: account_moderation_note.created_at.iso8601, title: l(account_moderation_note.created_at) } - = l account_moderation_note.created_at - %td - = link_to t('admin.account_moderation_notes.delete'), admin_account_moderation_note_path(account_moderation_note), method: :delete if can?(:destroy, account_moderation_note) + .speech-bubble__owner + = admin_account_link_to account_moderation_note.account + %time.formatted{ datetime: account_moderation_note.created_at.iso8601 }= l account_moderation_note.created_at + = table_link_to 'trash', t('admin.account_moderation_notes.delete'), admin_account_moderation_note_path(account_moderation_note), method: :delete if can?(:destroy, account_moderation_note) diff --git a/app/views/admin/accounts/show.html.haml b/app/views/admin/accounts/show.html.haml index 7312618ee..2e6de1864 100644 --- a/app/views/admin/accounts/show.html.haml +++ b/app/views/admin/accounts/show.html.haml @@ -2,7 +2,7 @@ = @account.acct .table-wrapper - %table.table + %table.table.inline-table %tbody %tr %th= t('admin.accounts.username') @@ -73,17 +73,17 @@ %tr %th= t('admin.accounts.follows') - %td= @account.following_count + %td= number_to_human @account.following_count %tr %th= t('admin.accounts.followers') - %td= @account.followers_count + %td= number_to_human @account.followers_count %tr %th= t('admin.accounts.statuses') - %td= link_to @account.statuses_count, admin_account_statuses_path(@account.id) + %td= link_to number_to_human(@account.statuses_count), admin_account_statuses_path(@account.id) %tr %th= t('admin.accounts.media_attachments') %td - = link_to @account.media_attachments.count, admin_account_statuses_path(@account.id, { media: true }) + = link_to number_to_human(@account.media_attachments.count), admin_account_statuses_path(@account.id, { media: true }) = surround '(', ')' do = number_to_human_size @account.media_attachments.sum('file_file_size') %tr @@ -120,11 +120,12 @@ = link_to t('admin.accounts.perform_full_suspension'), admin_account_suspension_path(@account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') }, class: 'button' if can?(:suspend, @account) - if !@account.local? && @account.hub_url.present? - %hr + %hr.spacer/ + %h3 OStatus .table-wrapper - %table.table + %table.table.inline-table %tbody %tr %th= t('admin.accounts.feed_url') @@ -148,11 +149,12 @@ = link_to t('admin.accounts.unsubscribe'), unsubscribe_admin_account_path(@account.id), method: :post, class: 'button negative' if can?(:unsubscribe, @account) - if !@account.local? && @account.inbox_url.present? - %hr + %hr.spacer/ + %h3 ActivityPub .table-wrapper - %table.table + %table.table.inline-table %tbody %tr %th= t('admin.accounts.inbox_url') @@ -167,24 +169,15 @@ %th= t('admin.accounts.followers_url') %td= link_to @account.followers_url, @account.followers_url -%hr -%h3= t('admin.accounts.moderation_notes') +%hr.spacer/ + += render @moderation_notes = simple_form_for @account_moderation_note, url: admin_account_moderation_notes_path do |f| = render 'shared/error_messages', object: @account_moderation_note - = f.input :content + = f.input :content, placeholder: t('admin.reports.notes.placeholder'), rows: 6 = f.hidden_field :target_account_id .actions - = f.button :button, t('admin.account_moderation_notes.create'), type: :submit - -.table-wrapper - %table.table - %thead - %tr - %th - %th= t('admin.account_moderation_notes.account') - %th= t('admin.account_moderation_notes.created_at') - %tbody - = render @moderation_notes + = f.button :button, t('admin.account_moderation_notes.create'), type: :submit diff --git a/app/views/admin/reports/_status.html.haml b/app/views/admin/reports/_status.html.haml index 137609539..9057e6048 100644 --- a/app/views/admin/reports/_status.html.haml +++ b/app/views/admin/reports/_status.html.haml @@ -7,7 +7,7 @@ %p>< %strong= Formatter.instance.format_spoiler(status) - = Formatter.instance.format(status) + = Formatter.instance.format(status, custom_emojify: true) - unless status.media_attachments.empty? - if status.media_attachments.first.video? diff --git a/app/views/admin/statuses/index.html.haml b/app/views/admin/statuses/index.html.haml index fe2581527..880a24f76 100644 --- a/app/views/admin/statuses/index.html.haml +++ b/app/views/admin/statuses/index.html.haml @@ -3,11 +3,8 @@ - content_for :page_title do = t('admin.statuses.title') - -.back-link - = link_to admin_account_path(@account.id) do - %i.fa.fa-chevron-left.fa-fw - = t('admin.statuses.back_to_account') + \- + = "@#{@account.acct}" .filters .filter-subset @@ -15,33 +12,26 @@ %ul %li= link_to t('admin.statuses.no_media'), admin_account_statuses_path(@account.id, current_params.merge(media: nil)), class: !params[:media] && 'selected' %li= link_to t('admin.statuses.with_media'), admin_account_statuses_path(@account.id, current_params.merge(media: true)), class: params[:media] && 'selected' + .back-link{ style: 'flex: 1 1 auto; text-align: right' } + = link_to admin_account_path(@account.id) do + %i.fa.fa-chevron-left.fa-fw + = t('admin.statuses.back_to_account') + +%hr.spacer/ + += form_for(@form, url: admin_account_statuses_path(@account.id)) do |f| + = hidden_field_tag :page, params[:page] + = hidden_field_tag :media, params[:media] -- if @statuses.empty? - .accounts-grid - = render 'accounts/nothing_here' -- else - = form_for(@form, url: admin_account_statuses_path(@account.id)) do |f| - = hidden_field_tag :page, params[:page] - = hidden_field_tag :media, params[:media] - .batch-form-box - .batch-checkbox-all + .batch-table + .batch-table__toolbar + %label.batch-table__toolbar__select.batch-checkbox-all = check_box_tag :batch_checkbox_all, nil, false - = f.select :action, Form::StatusBatch::ACTION_TYPE.map{|action| [t("admin.statuses.batch.#{action}"), action]} - = f.submit t('admin.statuses.execute'), data: { confirm: t('admin.reports.are_you_sure') }, class: 'button' - .media-spoiler-toggle-buttons - .media-spoiler-show-button.button= t('admin.statuses.media.show') - .media-spoiler-hide-button.button= t('admin.statuses.media.hide') - - @statuses.each do |status| - .account-status{ data: { id: status.id } } - .batch-checkbox - = f.check_box :status_ids, { multiple: true, include_hidden: false }, status.id - .activity-stream.activity-stream-headless - .entry= render 'stream_entries/simple_status', status: status - .account-status__actions - - unless status.media_attachments.empty? - = link_to admin_account_status_path(@account.id, status, current_params.merge(status: { sensitive: !status.sensitive })), method: :patch, class: 'icon-button nsfw-button', title: t("admin.reports.nsfw.#{!status.sensitive}") do - = fa_icon status.sensitive? ? 'eye' : 'eye-slash' - = link_to admin_account_status_path(@account.id, status), method: :delete, class: 'icon-button trash-button', title: t('admin.reports.delete'), data: { confirm: t('admin.reports.are_you_sure') }, remote: true do - = fa_icon 'trash' + .batch-table__toolbar__actions + = f.button safe_join([fa_icon('eye-slash'), t('admin.statuses.batch.nsfw_on')]), name: :nsfw_on, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } + = f.button safe_join([fa_icon('eye'), t('admin.statuses.batch.nsfw_off')]), name: :nsfw_off, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } + = f.button safe_join([fa_icon('trash'), t('admin.statuses.batch.delete')]), name: :delete, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } + .batch-table__body + = render partial: 'admin/reports/status', collection: @statuses, locals: { f: f } = paginate @statuses diff --git a/config/locales/ar.yml b/config/locales/ar.yml index e9ca3038e..a5179ae14 100644 --- a/config/locales/ar.yml +++ b/config/locales/ar.yml @@ -52,9 +52,7 @@ ar: unfollow: إلغاء المتابعة admin: account_moderation_notes: - account: مُشرِف create: إنشاء - created_at: التاريخ created_msg: تم إنشاء ملاحظة الإشراف بنجاح ! delete: حذف destroyed_msg: تم تدمير ملاحظة الإشراف بنجاح ! @@ -241,12 +239,8 @@ ar: are_you_sure: هل أنت متأكد ؟ comment: none: لا شيء - delete: حذف id: معرّف ID mark_as_resolved: إعتبار التقرير كمحلول - nsfw: - 'false': الكشف عن الصور - 'true': إخفاء الوسائط المرفقة report: 'التقرير #%{id}' report_contents: المحتويات reported_account: حساب مُبلّغ عنه @@ -305,11 +299,8 @@ ar: back_to_account: العودة إلى صفحة الحساب batch: delete: حذف - execute: تفعيل failed_to_execute: خطأ في التفعيل media: - hide: إخفاء الوسائط - show: إظهار الوسائط title: الوسائط title: منشورات الحساب with_media: بالوسائط diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 2758bb487..a8c75c32d 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -53,9 +53,7 @@ ca: unfollow: Deixa de seguir admin: account_moderation_notes: - account: Moderador create: Crea - created_at: Data created_msg: La nota de moderació s'ha creat correctament! delete: Suprimeix destroyed_msg: Nota de moderació destruïda amb èxit! @@ -269,7 +267,6 @@ ca: comment: none: Cap created_at: Reportat - delete: Suprimeix id: ID mark_as_resolved: Marca com a resolt mark_as_unresolved: Marcar sense resoldre @@ -279,9 +276,6 @@ ca: create_and_unresolve: Reobrir amb nota delete: Esborrar placeholder: Descriu les accions que s'han pres o qualsevol altra actualització d'aquest informe… - nsfw: - 'false': Mostra els fitxers multimèdia adjunts - 'true': Amaga els fitxers multimèdia adjunts reopen: Reobrir informe report: 'Informe #%{id}' report_contents: Contingut @@ -356,11 +350,8 @@ ca: delete: Suprimeix nsfw_off: Marcar com a no sensible nsfw_on: Marcar com a sensible - execute: Executa failed_to_execute: No s'ha pogut executar media: - hide: Amaga el contingut multimèdia - show: Mostra el contingut multimèdia title: Contingut multimèdia no_media: Sense contingut multimèdia title: Estats del compte diff --git a/config/locales/de.yml b/config/locales/de.yml index 6b2c08735..aa4295c89 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -53,9 +53,7 @@ de: unfollow: Entfolgen admin: account_moderation_notes: - account: Moderator*in create: Erstellen - created_at: Datum created_msg: Moderationsnotiz erfolgreich erstellt! delete: Löschen destroyed_msg: Moderationsnotiz erfolgreich gelöscht! @@ -269,7 +267,6 @@ de: comment: none: Kein created_at: Gemeldet - delete: Löschen id: ID mark_as_resolved: Als gelöst markieren mark_as_unresolved: Als ungelöst markieren @@ -279,9 +276,6 @@ de: create_and_unresolve: Mit Kommentar wieder öffnen delete: Löschen placeholder: Beschreibe, welche Maßnahmen ergriffen wurden oder andere Neuigkeiten zu dieser Meldung… - nsfw: - 'false': Medienanhänge wieder anzeigen - 'true': Medienanhänge verbergen reopen: Meldung wieder öffnen report: 'Meldung #%{id}' report_contents: Inhalt @@ -356,11 +350,8 @@ de: delete: Löschen nsfw_off: Als nicht heikel markieren nsfw_on: Als heikel markieren - execute: Ausführen failed_to_execute: Ausführen fehlgeschlagen media: - hide: Medien verbergen - show: Medien anzeigen title: Medien no_media: Keine Medien title: Beiträge des Kontos diff --git a/config/locales/en.yml b/config/locales/en.yml index f7127f794..7e389b1c2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -53,9 +53,7 @@ en: unfollow: Unfollow admin: account_moderation_notes: - account: Moderator - create: Create - created_at: Date + create: Leave note created_msg: Moderation note successfully created! delete: Delete destroyed_msg: Moderation note successfully destroyed! @@ -269,7 +267,6 @@ en: comment: none: None created_at: Reported - delete: Delete id: ID mark_as_resolved: Mark as resolved mark_as_unresolved: Mark as unresolved @@ -279,9 +276,6 @@ en: create_and_unresolve: Reopen with note delete: Delete placeholder: Describe what actions have been taken, or any other updates to this report… - nsfw: - 'false': Unhide media attachments - 'true': Hide media attachments reopen: Reopen report report: 'Report #%{id}' report_contents: Contents @@ -356,11 +350,8 @@ en: delete: Delete nsfw_off: Mark as not sensitive nsfw_on: Mark as sensitive - execute: Execute failed_to_execute: Failed to execute media: - hide: Hide media - show: Show media title: Media no_media: No media title: Account statuses diff --git a/config/locales/eo.yml b/config/locales/eo.yml index c768d8a03..9c44d0e62 100644 --- a/config/locales/eo.yml +++ b/config/locales/eo.yml @@ -52,9 +52,7 @@ eo: unfollow: Ne plu sekvi admin: account_moderation_notes: - account: Kontrolanto create: Krei - created_at: Dato created_msg: Kontrola noto sukcese kreita! delete: Forigi destroyed_msg: Kontrola noto sukcese detruita! @@ -244,12 +242,8 @@ eo: are_you_sure: Ĉu vi certas? comment: none: Nenio - delete: Forigi id: ID mark_as_resolved: Marki kiel solvita - nsfw: - 'false': Malkaŝi aŭdovidajn kunsendaĵojn - 'true': Kaŝi aŭdovidajn kunsendaĵojn report: 'Signalo #%{id}' report_contents: Enhavo reported_account: Signalita konto @@ -320,11 +314,8 @@ eo: delete: Forigi nsfw_off: Malŝalti NSFW nsfw_on: Ŝalti NSFW - execute: Ekigi failed_to_execute: Ekigo malsukcesa media: - hide: Kaŝi aŭdovidaĵojn - show: Montri aŭdovidaĵojn title: Aŭdovidaĵoj no_media: Neniu aŭdovidaĵo title: Mesaĝoj de la konto diff --git a/config/locales/es.yml b/config/locales/es.yml index cd36e3a97..be7dcd81e 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -53,9 +53,7 @@ es: unfollow: Dejar de seguir admin: account_moderation_notes: - account: Moderador create: Crear - created_at: Fecha created_msg: "¡Nota de moderación creada con éxito!" delete: Borrar destroyed_msg: "¡Nota de moderación destruida con éxito!" @@ -269,7 +267,6 @@ es: comment: none: Ninguno created_at: Denunciado - delete: Eliminar id: ID mark_as_resolved: Marcar como resuelto mark_as_unresolved: Marcar como no resuelto @@ -279,9 +276,6 @@ es: create_and_unresolve: Reabrir con una nota delete: Eliminar placeholder: Especificar qué acciones se han tomado o cualquier otra novedad respecto a esta denuncia… - nsfw: - 'false': Mostrar multimedia - 'true': Ocultar multimedia reopen: Reabrir denuncia report: 'Reportar #%{id}' report_contents: Contenido @@ -356,11 +350,8 @@ es: delete: Eliminar nsfw_off: Marcar contenido como no sensible nsfw_on: Marcar contenido como sensible - execute: Ejecutar failed_to_execute: Falló al ejecutar media: - hide: Ocultar multimedia - show: Mostrar multimedia title: Multimedia no_media: No hay multimedia title: Estado de las cuentas diff --git a/config/locales/fa.yml b/config/locales/fa.yml index a3005547a..3aa40f0b3 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -52,9 +52,7 @@ fa: unfollow: پایان پیگیری admin: account_moderation_notes: - account: مدیر create: نوشتن - created_at: تاریخ created_msg: یادداشت مدیر با موفقیت ساخته شد! delete: پاک کردن destroyed_msg: یادداشت مدیر با موفقیت پاک شد! @@ -244,12 +242,8 @@ fa: are_you_sure: آیا مطمئن هستید؟ comment: none: خالی - delete: پاک‌کردن id: شناسه mark_as_resolved: علامت‌گذاری به عنوان حل‌شده - nsfw: - 'false': نمایش پیوست‌های تصویری - 'true': نهفتن پیوست‌های تصویری report: 'گزارش #%{id}' report_contents: محتوا reported_account: حساب گزارش‌شده @@ -308,11 +302,8 @@ fa: delete: پاک‌کردن nsfw_off: NSFW خاموش nsfw_on: NSFW روشن - execute: اجرا failed_to_execute: اجرا نشد media: - hide: نهفتن رسانه - show: نمایش رسانه title: رسانه no_media: بدون رسانه title: نوشته‌های حساب diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 550ad1805..b313c8723 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -52,9 +52,7 @@ fi: unfollow: Lopeta seuraaminen admin: account_moderation_notes: - account: Moderaattori create: Luo - created_at: Päiväys created_msg: Moderointimerkinnän luonti onnistui! delete: Poista destroyed_msg: Moderointimerkinnän poisto onnistui! @@ -244,12 +242,8 @@ fi: are_you_sure: Oletko varma? comment: none: Ei mitään - delete: Poista id: Tunniste mark_as_resolved: Merkitse ratkaistuksi - nsfw: - 'false': Peru medialiitteiden piilotus - 'true': Piilota medialiitteet report: Raportti nro %{id} report_contents: Sisältö reported_account: Raportoitu tili @@ -320,11 +314,8 @@ fi: delete: Poista nsfw_off: NSFW POIS nsfw_on: NSFW PÄÄLLÄ - execute: Suorita failed_to_execute: Suoritus epäonnistui media: - hide: Piilota media - show: Näytä media title: Media no_media: Ei mediaa title: Tilin tilat diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 462ce7b4b..3b543fdb7 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -53,9 +53,7 @@ fr: unfollow: Ne plus suivre admin: account_moderation_notes: - account: Modérateur·ice create: Créer - created_at: Date created_msg: Note de modération créée avec succès ! delete: Supprimer destroyed_msg: Note de modération supprimée avec succès ! @@ -269,7 +267,6 @@ fr: comment: none: Aucun created_at: Signalé - delete: Supprimer id: ID mark_as_resolved: Marquer comme résolu mark_as_unresolved: Marquer comme non-résolu @@ -279,9 +276,6 @@ fr: create_and_unresolve: Ré-ouvrir avec une note delete: Effacer placeholder: Décrivez quelles actions ont été prises, ou toute autre mise à jour de ce signalement… - nsfw: - 'false': Ré-afficher les médias - 'true': Masquer les médias reopen: Ré-ouvrir le signalement report: 'Signalement #%{id}' report_contents: Contenu @@ -356,11 +350,8 @@ fr: delete: Supprimer nsfw_off: Marquer comme non-sensible nsfw_on: Marquer comme sensible - execute: Exécuter failed_to_execute: Erreur d’exécution media: - hide: Masquer les médias - show: Montrer les médias title: Médias no_media: Aucun média title: État du compte diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 6f2270224..eec1b4e1e 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -53,9 +53,7 @@ gl: unfollow: Deixar de seguir admin: account_moderation_notes: - account: Moderador create: Crear - created_at: Data created_msg: Nota a moderación creada con éxito! delete: Eliminar destroyed_msg: Nota a moderación destruída con éxito! @@ -269,7 +267,6 @@ gl: comment: none: Nada created_at: Reportado - delete: Eliminar id: ID mark_as_resolved: Marcar como resolto mark_as_unresolved: Marcar como non resolto @@ -279,9 +276,6 @@ gl: create_and_unresolve: Voltar a abrir con nota delete: Eliminar placeholder: Describir qué decisións foron tomadas, ou calquer actualización a este informe… - nsfw: - 'false': Non agochar anexos de medios - 'true': Agochar anexos de medios reopen: Voltar a abrir o informe report: 'Informe #%{id}' report_contents: Contidos @@ -356,11 +350,8 @@ gl: delete: Eliminar nsfw_off: Marcar como non sensible nsfw_on: Marcar como sensible - execute: Executar failed_to_execute: Fallou a execución media: - hide: Agochar medios - show: Mostar medios title: Medios no_media: Sen medios title: Estados da conta diff --git a/config/locales/he.yml b/config/locales/he.yml index d641c6e1a..d66d9f034 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -52,9 +52,7 @@ he: unfollow: הפסקת מעקב admin: account_moderation_notes: - account: מנחה דיון create: ליצור - created_at: תאריך created_msg: הודעת מנחה נוצרה בהצלחה! delete: למחוק destroyed_msg: הודעת מנחה נמחקה בהצלחה! @@ -181,12 +179,8 @@ he: are_you_sure: 100% על בטוח? comment: none: ללא - delete: מחיקה id: ID mark_as_resolved: סימון כפתור - nsfw: - 'false': לכל המשפחה - 'true': תוכן רגיש report: 'דווח על #%{id}' report_contents: תוכן reported_account: חשבון מדווח diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 7fe431d37..422c05955 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -52,9 +52,7 @@ hu: unfollow: Követés abbahagyása admin: account_moderation_notes: - account: Moderátor create: Új bejegyzés - created_at: Dátum created_msg: Moderációs bejegyzés létrehozva! delete: Törlés destroyed_msg: Moderációs bejegyzés törölve! @@ -244,12 +242,8 @@ hu: are_you_sure: Biztos vagy benne? comment: none: Egyik sem - delete: Törlés id: ID mark_as_resolved: Megjelölés megoldottként - nsfw: - 'false': Média-csatolmányok rejtésének feloldása - 'true': Média-csatolmányok elrejtése report: "#%{id} számú jelentés" report_contents: Tartalom reported_account: Bejelentett fiók @@ -314,11 +308,8 @@ hu: delete: Törlés nsfw_off: Szenzitív tartalom kikapcsolva nsfw_on: Szenzitív tartalom bekapcsolva - execute: Végrehajt failed_to_execute: Végrehajtás sikertelen media: - hide: Média elrejtése - show: Média megjelenítése title: Média no_media: Nem található médiafájl title: Felhasználó tülkjei diff --git a/config/locales/id.yml b/config/locales/id.yml index 5a63b8038..0476e2848 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -107,7 +107,6 @@ id: reports: comment: none: Tidak ada - delete: Hapus id: ID mark_as_resolved: Tandai telah diseleseikan report: 'Laporkan #%{id}' diff --git a/config/locales/io.yml b/config/locales/io.yml index 7c25acc47..bf15de488 100644 --- a/config/locales/io.yml +++ b/config/locales/io.yml @@ -106,7 +106,6 @@ io: reports: comment: none: None - delete: Delete id: ID mark_as_resolved: Mark as resolved report: 'Report #%{id}' diff --git a/config/locales/it.yml b/config/locales/it.yml index e010be02d..c1ac176c4 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -49,9 +49,7 @@ it: unfollow: Non seguire più admin: account_moderation_notes: - account: Moderatore create: Crea - created_at: Data created_msg: Nota di moderazione creata con successo! delete: Elimina destroyed_msg: Nota di moderazione distrutta con successo! @@ -214,7 +212,6 @@ it: assigned: Moderatore assegnato comment: none: Nessuno - delete: Elimina id: ID mark_as_resolved: Segna come risolto mark_as_unresolved: Segna come non risolto @@ -223,9 +220,6 @@ it: create_and_resolve: Risolvi con nota create_and_unresolve: Riapri con nota delete: Elimina - nsfw: - 'false': Mostra gli allegati multimediali - 'true': Nascondi allegati multimediali report_contents: Contenuti resolved: Risolto silence_account: Silenzia account @@ -266,11 +260,8 @@ it: delete: Elimina nsfw_off: NSFW OFF nsfw_on: NSFW ON - execute: Esegui failed_to_execute: Impossibile eseguire media: - hide: Nascondi media - show: Mostra media title: Media no_media: Nessun media with_media: con media diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 5b3cc5f15..bc48613b9 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -53,9 +53,7 @@ ja: unfollow: フォロー解除 admin: account_moderation_notes: - account: モデレータ create: 書き込む - created_at: 日付 created_msg: モデレーションメモを書き込みました! delete: 削除 destroyed_msg: モデレーションメモを削除しました! @@ -269,7 +267,6 @@ ja: comment: none: なし created_at: レポート日時 - delete: 削除 id: ID mark_as_resolved: 解決済みとしてマーク mark_as_unresolved: 未解決として再び開く @@ -279,9 +276,6 @@ ja: create_and_unresolve: 書き込み、未解決として開く delete: 削除 placeholder: このレポートに取られた措置や、その他の更新を記述してください… - nsfw: - 'false': NSFW オフ - 'true': NSFW オン reopen: 再び開く report: レポート#%{id} report_contents: 内容 @@ -356,11 +350,8 @@ ja: delete: 削除 nsfw_off: 閲覧注意のマークを取り除く nsfw_on: 閲覧注意としてマークする - execute: 実行 failed_to_execute: 実行に失敗しました media: - hide: メディアを隠す - show: メディアを表示 title: メディア no_media: メディアなし title: トゥート一覧 diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 0f3c6483f..bd6717d49 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -53,9 +53,7 @@ ko: unfollow: 팔로우 해제 admin: account_moderation_notes: - account: 모더레이터 create: 작성하기 - created_at: 작성 날짜 created_msg: 모더레이션 기록이 성공적으로 작성되었습니다! delete: 삭제 destroyed_msg: 모더레이션 기록이 성공적으로 삭제되었습니다! @@ -271,7 +269,6 @@ ko: comment: none: 없음 created_at: 리포트 시각 - delete: 삭제 id: ID mark_as_resolved: 해결 완료 처리 mark_as_unresolved: 미해결로 표시 @@ -281,9 +278,6 @@ ko: create_and_unresolve: 노트 작성과 함께 미해결로 표시 delete: 삭제 placeholder: 이 리포트에 대한 조치, 다른 업데이트 사항에 대해 설명합니다… - nsfw: - 'false': NSFW 꺼짐 - 'true': NSFW 켜짐 reopen: 리포트 다시 열기 report: '신고 #%{id}' report_contents: 내용 @@ -358,11 +352,8 @@ ko: delete: 삭제 nsfw_off: NSFW 끄기 nsfw_on: NSFW 켜기 - execute: 실행 failed_to_execute: 실행을 실패하였습니다 media: - hide: 미디어 숨기기 - show: 미디어 보여주기 title: 미디어 no_media: 미디어 없음 title: 계정 툿 diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 7a488bb0f..00f21babd 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -53,9 +53,7 @@ nl: unfollow: Ontvolgen admin: account_moderation_notes: - account: Moderator create: Aanmaken - created_at: Datum created_msg: Aanmaken van opmerking voor moderatoren geslaagd! delete: Verwijderen destroyed_msg: Verwijderen van opmerking voor moderatoren geslaagd! @@ -269,7 +267,6 @@ nl: comment: none: Geen created_at: Gerapporteerd op - delete: Verwijderen id: ID mark_as_resolved: Markeer als opgelost mark_as_unresolved: Markeer als onopgelost @@ -279,9 +276,6 @@ nl: create_and_unresolve: Heropenen met opmerking delete: Verwijderen placeholder: Beschrijf welke acties zijn ondernomen of andere opmerkingen over deze gerapporteerde toot… - nsfw: - 'false': Media tonen - 'true': Media verbergen reopen: Gerapporteerde toot heropenen report: 'Gerapporteerde toot #%{id}' report_contents: Inhoud @@ -356,11 +350,8 @@ nl: delete: Verwijderen nsfw_off: Als niet gevoelig markeren nsfw_on: Als gevoelig markeren - execute: Uitvoeren failed_to_execute: Uitvoeren mislukt media: - hide: Media verbergen - show: Media tonen title: Media no_media: Geen media title: Toots van account diff --git a/config/locales/no.yml b/config/locales/no.yml index 8b84182af..6ce2c0f01 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -52,9 +52,7 @@ unfollow: Slutte følge admin: account_moderation_notes: - account: Moderator create: Lag - created_at: Dato created_msg: Moderasjonsnotat laget uten problem! delete: Slett destroyed_msg: Moderasjonsnotat slettet uten problem! @@ -244,12 +242,8 @@ are_you_sure: Er du sikker? comment: none: Ingen - delete: Slett id: ID mark_as_resolved: Merk som løst - nsfw: - 'false': Vis mediavedlegg - 'true': Skjul mediavedlegg report: 'Rapportér #%{id}' report_contents: Innhold reported_account: Rapportert konto @@ -314,11 +308,8 @@ delete: Slett nsfw_off: NSFW AV nsfw_on: NSFW PÅ - execute: Utfør failed_to_execute: Utføring mislyktes media: - hide: Skjul media - show: Vis media title: Media no_media: Ingen media title: Kontostatuser diff --git a/config/locales/oc.yml b/config/locales/oc.yml index c248ffd85..c11fe614b 100644 --- a/config/locales/oc.yml +++ b/config/locales/oc.yml @@ -53,9 +53,7 @@ oc: unfollow: Quitar de sègre admin: account_moderation_notes: - account: Moderator create: Crear - created_at: Data created_msg: Nòta de moderacion ben creada ! delete: Suprimir destroyed_msg: Nòta de moderacion ben suprimida ! @@ -265,7 +263,6 @@ oc: comment: none: Pas cap created_at: Creacion - delete: Suprimir id: ID mark_as_resolved: Marcar coma resolgut mark_as_unresolved: Marcar coma pas resolgut @@ -274,9 +271,6 @@ oc: create_and_resolve: Resòlvre amb una nòta create_and_unresolve: Tornar dobrir amb una nòta placeholder: Explicatz las accions que son estadas menadas o çò qu’es estat fach per aqueste rapòrt… - nsfw: - 'false': Sens contengut sensible - 'true': Contengut sensible activat reopen: Tornar dobrir lo rapòrt report: 'senhalament #%{id}' report_contents: Contenguts @@ -348,11 +342,8 @@ oc: delete: Suprimir nsfw_off: NSFW OFF nsfw_on: NSFW ON - execute: Lançar failed_to_execute: Fracàs media: - hide: Amagar mèdia - show: Mostrar mèdia title: Mèdia no_media: Cap mèdia title: Estatuts del compte diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 7455df2c0..bd38aa6f7 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -53,9 +53,7 @@ pl: unfollow: Przestań śledzić admin: account_moderation_notes: - account: Autor create: Dodaj - created_at: Data created_msg: Pomyślnie dodano notatkę moderacyjną! delete: Usuń destroyed_msg: Pomyślnie usunięto notatkę moderacyjną! @@ -270,7 +268,6 @@ pl: comment: none: Brak created_at: Zgłoszono - delete: Usuń id: ID mark_as_resolved: Oznacz jako rozwiązane mark_as_unresolved: Oznacz jako nierozwiązane @@ -280,9 +277,6 @@ pl: create_and_unresolve: Cofnij rozwiązanie i pozostaw notatkę delete: Usuń placeholder: Opisz wykonane akcje i inne szczegóły dotyczące tego zgłoszenia… - nsfw: - 'false': Nie oznaczaj jako NSFW - 'true': Oznaczaj jako NSFW reopen: Otwórz ponownie report: 'Zgłoszenie #%{id}' report_contents: Zawartość @@ -357,11 +351,8 @@ pl: delete: Usuń nsfw_off: Cofnij NSFW nsfw_on: Oznacz jako NSFW - execute: Wykonaj failed_to_execute: Nie udało się wykonać media: - hide: Ukryj zawartość multimedialną - show: Pokaż zawartość multimedialną title: Media no_media: Bez zawartości multimedialnej title: Wpisy konta diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 4a574a575..862833d87 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -53,9 +53,7 @@ pt-BR: unfollow: Deixar de seguir admin: account_moderation_notes: - account: Moderador create: Criar - created_at: Data created_msg: Nota de moderação criada com sucesso! delete: Excluir destroyed_msg: Nota de moderação excluída com sucesso! @@ -269,7 +267,6 @@ pt-BR: comment: none: Nenhum created_at: Denunciado - delete: Excluir id: ID mark_as_resolved: Marcar como resolvido mark_as_unresolved: Marcar como não resolvido @@ -279,9 +276,6 @@ pt-BR: create_and_unresolve: Reabrir com nota delete: Excluir placeholder: Descreva que ações foram tomadas, ou quaisquer atualizações sobre esta denúncia… - nsfw: - 'false': Mostrar mídias anexadas - 'true': Esconder mídias anexadas reopen: Reabrir denúncia report: 'Denúncia #%{id}' report_contents: Conteúdos @@ -356,11 +350,8 @@ pt-BR: delete: Deletar nsfw_off: Marcar como não-sensível nsfw_on: Marcar como sensível - execute: Executar failed_to_execute: Falha em executar media: - hide: Esconder mídia - show: Mostrar mídia title: Mídia no_media: Não há mídia title: Postagens da conta diff --git a/config/locales/pt.yml b/config/locales/pt.yml index fb2a6cad1..62a7ef0ec 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -52,9 +52,7 @@ pt: unfollow: Deixar de seguir admin: account_moderation_notes: - account: Moderador create: Criar - created_at: Data created_msg: Nota de moderação criada com sucesso! delete: Eliminar destroyed_msg: Nota de moderação excluída com sucesso! @@ -244,12 +242,8 @@ pt: are_you_sure: Tens a certeza? comment: none: Nenhum - delete: Eliminar id: ID mark_as_resolved: Marcar como resolvido - nsfw: - 'false': Mostrar imagens/vídeos - 'true': Esconder imagens/vídeos report: 'Denúncia #%{id}' report_contents: Conteúdos reported_account: Conta denunciada @@ -314,11 +308,8 @@ pt: delete: Eliminar nsfw_off: NSFW OFF nsfw_on: NSFW ON - execute: Executar failed_to_execute: Falhou ao executar media: - hide: Esconder média - show: Mostrar média title: Média no_media: Não há média title: Estado das contas diff --git a/config/locales/ru.yml b/config/locales/ru.yml index bf4225758..603e1f3ca 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -52,9 +52,7 @@ ru: unfollow: Отписаться admin: account_moderation_notes: - account: Модератор create: Создать - created_at: Дата created_msg: Заметка модератора успешно создана! delete: Удалить destroyed_msg: Заметка модератора успешно удалена! @@ -246,12 +244,8 @@ ru: are_you_sure: Вы уверены? comment: none: Нет - delete: Удалить id: ID mark_as_resolved: Отметить как разрешенную - nsfw: - 'false': Показать мультимедийные вложения - 'true': Скрыть мультимедийные вложения report: 'Жалоба #%{id}' report_contents: Содержимое reported_account: Аккаунт нарушителя @@ -322,11 +316,8 @@ ru: delete: Удалить nsfw_off: Выключить NSFW nsfw_on: Включить NSFW - execute: Выполнить failed_to_execute: Не удалось выполнить media: - hide: Скрыть медиаконтент - show: Показать медиаконтент title: Медиаконтент no_media: Без медиаконтента title: Статусы аккаунта diff --git a/config/locales/sk.yml b/config/locales/sk.yml index fc9e9452c..7fb097f03 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -53,9 +53,7 @@ sk: unfollow: Prestať sledovať admin: account_moderation_notes: - account: Moderátor create: Vytvoriť - created_at: Dátum created_msg: Poznámka moderátora bola úspešne vytvorená! delete: Zmazať destroyed_msg: Poznámka moderátora bola úspešne zmazaná! @@ -268,7 +266,6 @@ sk: comment: none: Žiadne created_at: Nahlásené - delete: Vymazať id: Identifikácia mark_as_resolved: Označiť ako vyriešené mark_as_unresolved: Označ ako nevyriešené @@ -278,9 +275,6 @@ sk: create_and_unresolve: Otvor znovu, s poznámkou delete: Vymaž placeholder: Opíš aké opatrenia boli urobené, alebo akékoľvek iné aktualizácie k tomuto nahláseniu… - nsfw: - 'false': Odkryť mediálne prílohy - 'true': Skryť mediálne prílohy reopen: Znovu otvor report report: Nahlásiť report_contents: Obsah @@ -355,11 +349,8 @@ sk: delete: Vymazať nsfw_off: Obsah nieje chúlostivý nsfw_on: Označ obeah aka chúlostivý - execute: Vykonať failed_to_execute: Nepodarilo sa vykonať media: - hide: Skryť médiá - show: Zobraziť médiá title: Médiá no_media: Žiadné médiá title: Statusy na účte diff --git a/config/locales/sr-Latn.yml b/config/locales/sr-Latn.yml index 742c976d1..dba952917 100644 --- a/config/locales/sr-Latn.yml +++ b/config/locales/sr-Latn.yml @@ -52,9 +52,7 @@ sr-Latn: unfollow: Otprati admin: account_moderation_notes: - account: Moderator create: Napravi - created_at: Datum created_msg: Moderatorska beleška uspešno napravljena! delete: Obriši destroyed_msg: Moderatorska beleška uspešno obrisana! @@ -246,12 +244,8 @@ sr-Latn: are_you_sure: Da li ste sigurni? comment: none: Ništa - delete: Obriši id: ID mark_as_resolved: Označi kao rešen - nsfw: - 'false': Otkrij medijske priloge - 'true': Sakrij medijske priloge report: 'Prijava #%{id}' report_contents: Sadržaj reported_account: Prijavljeni nalog @@ -310,11 +304,8 @@ sr-Latn: delete: Obriši nsfw_off: NSFW isključen nsfw_on: NSFW uključen - execute: Izvrši failed_to_execute: Neuspelo izvršavanje media: - hide: Sakrij multimediju - show: Prikaži multimediju title: Multimedija no_media: Bez multimedije title: Statusi naloga diff --git a/config/locales/sr.yml b/config/locales/sr.yml index 0d55910a6..74abf0323 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -52,9 +52,7 @@ sr: unfollow: Отпрати admin: account_moderation_notes: - account: Модератор create: Направи - created_at: Датум created_msg: Модераторска белешка успешно направљена! delete: Обриши destroyed_msg: Модераторска белешка успешно обрисана! @@ -246,12 +244,8 @@ sr: are_you_sure: Да ли сте сигурни? comment: none: Ништа - delete: Обриши id: ID mark_as_resolved: Означи као решен - nsfw: - 'false': Откриј медијске прилоге - 'true': Сакриј медијске прилоге report: 'Пријава #%{id}' report_contents: Садржај reported_account: Пријављени налог @@ -310,11 +304,8 @@ sr: delete: Обриши nsfw_off: NSFW искључен nsfw_on: NSFW укључен - execute: Изврши failed_to_execute: Неуспело извршавање media: - hide: Сакриј мултимедију - show: Прикажи мултимедију title: Мултимедија no_media: Без мултимедије title: Статуси налога diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 845248652..9e0bb0856 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -53,9 +53,7 @@ sv: unfollow: Sluta följa admin: account_moderation_notes: - account: Moderator create: Skapa - created_at: Datum created_msg: Modereringsnotering skapad utan problem! delete: Ta bort destroyed_msg: Modereringsnotering borttagen utan problem! @@ -269,7 +267,6 @@ sv: comment: none: Ingen created_at: Anmäld - delete: Radera id: ID mark_as_resolved: Markera som löst mark_as_unresolved: Markera som olöst @@ -279,9 +276,6 @@ sv: create_and_unresolve: Återuppta med anteckning delete: Radera placeholder: Beskriv vilka åtgärder som vidtagits eller andra uppdateringar till den här anmälan… - nsfw: - 'false': Visa bifogade mediafiler - 'true': Dölj bifogade mediafiler reopen: Återuppta anmälan report: 'Anmäl #%{id}' report_contents: Innehåll @@ -356,11 +350,8 @@ sv: delete: Radera nsfw_off: Markera som ej känslig nsfw_on: Markera som känslig - execute: Utför failed_to_execute: Misslyckades att utföra media: - hide: Dölj media - show: Visa media title: Media no_media: Ingen media title: Kontostatus diff --git a/config/locales/th.yml b/config/locales/th.yml index 350b93b52..9d93115b0 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -109,7 +109,6 @@ th: reports: comment: none: None - delete: ลบ id: ไอดี mark_as_resolved: ทำเครื่องหมายว่าจัดการแล้ว report: 'Report #%{id}' diff --git a/config/locales/tr.yml b/config/locales/tr.yml index 6e7aeb77e..0d78216b6 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -108,7 +108,6 @@ tr: reports: comment: none: Yok - delete: Sil id: ID mark_as_resolved: Giderildi olarak işaretle report: 'Şikayet #%{id}' diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 44f64b5c9..6fe46b4d9 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -100,7 +100,6 @@ uk: reports: comment: none: Немає - delete: Видалити id: ID mark_as_resolved: Відмітити як вирішену report: 'Скарга #%{id}' diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 78c72bd30..7ea491fd4 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -52,9 +52,7 @@ zh-CN: unfollow: 取消关注 admin: account_moderation_notes: - account: 管理员 create: 新建 - created_at: 日期 created_msg: 管理备忘建立成功! delete: 删除 destroyed_msg: 管理备忘删除成功! @@ -242,12 +240,8 @@ zh-CN: are_you_sure: 你确定吗? comment: none: 没有 - delete: 删除 id: ID mark_as_resolved: 标记为“已处理” - nsfw: - 'false': 取消 NSFW 标记 - 'true': 添加 NSFW 标记 report: '举报 #%{id}' report_contents: 内容 reported_account: 举报用户 @@ -312,11 +306,8 @@ zh-CN: delete: 删除 nsfw_off: 取消 NSFW 标记 nsfw_on: 添加 NSFW 标记 - execute: 执行 failed_to_execute: 执行失败 media: - hide: 隐藏媒体文件 - show: 显示媒体文件 title: 媒体文件 no_media: 不含媒体文件 title: 帐户嘟文 diff --git a/config/locales/zh-HK.yml b/config/locales/zh-HK.yml index a27b0c04c..3f91b7191 100644 --- a/config/locales/zh-HK.yml +++ b/config/locales/zh-HK.yml @@ -53,9 +53,7 @@ zh-HK: unfollow: 取消關注 admin: account_moderation_notes: - account: 管理員 create: 新增 - created_at: 日期 created_msg: 管理記錄已新增 delete: 刪除 destroyed_msg: 管理記錄已被刪除 @@ -268,7 +266,6 @@ zh-HK: comment: none: 沒有 created_at: 日期 - delete: 刪除 id: ID mark_as_resolved: 標示為「已處理」 mark_as_unresolved: 標示為「未處理」 @@ -278,9 +275,6 @@ zh-HK: create_and_unresolve: 建立筆記並標示為「未處理」 delete: 刪除 placeholder: 記錄已執行的動作,或其他更新 - nsfw: - 'false': 取消 NSFW 標記 - 'true': 添加 NSFW 標記 reopen: 重開舉報 report: '舉報 #%{id}' report_contents: 舉報內容 @@ -355,11 +349,8 @@ zh-HK: delete: 刪除 nsfw_off: 取消 NSFW 標記 nsfw_on: 添加 NSFW 標記 - execute: 執行 failed_to_execute: 執行失敗 media: - hide: 隱藏媒體檔案 - show: 顯示媒體檔案 title: 媒體檔案 no_media: 不含媒體檔案 title: 帳戶文章 diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index f69d22d79..d8c0f89a9 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -80,7 +80,6 @@ zh-TW: reports: comment: none: 無 - delete: 刪除 id: ID mark_as_resolved: 標記為已解決 report: '檢舉 #%{id}' diff --git a/config/routes.rb b/config/routes.rb index d959301e9..90f6ac594 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -135,7 +135,7 @@ Rails.application.routes.draw do end resources :reports, only: [:index, :show, :update] do - resources :reported_statuses, only: [:create, :update, :destroy] + resources :reported_statuses, only: [:create] end resources :report_notes, only: [:create, :destroy] @@ -156,7 +156,7 @@ Rails.application.routes.draw do resource :silence, only: [:create, :destroy] resource :suspension, only: [:create, :destroy] resource :confirmation, only: [:create] - resources :statuses, only: [:index, :create, :update, :destroy] + resources :statuses, only: [:index, :create] resource :role do member do diff --git a/spec/controllers/admin/reported_statuses_controller_spec.rb b/spec/controllers/admin/reported_statuses_controller_spec.rb index 29957ed37..7adbf36b9 100644 --- a/spec/controllers/admin/reported_statuses_controller_spec.rb +++ b/spec/controllers/admin/reported_statuses_controller_spec.rb @@ -22,7 +22,7 @@ describe Admin::ReportedStatusesController do let(:sensitive) { true } let!(:media_attachment) { Fabricate(:media_attachment, status: status) } - context 'updates sensitive column to true' do + context 'when action is nsfw_on' do it 'updates sensitive column' do is_expected.to change { status.reload.sensitive @@ -30,7 +30,7 @@ describe Admin::ReportedStatusesController do end end - context 'updates sensitive column to false' do + context 'when action is nsfw_off' do let(:action) { 'nsfw_off' } let(:sensitive) { false } @@ -41,35 +41,13 @@ describe Admin::ReportedStatusesController do end end - it 'redirects to report page' do - subject.call - expect(response).to redirect_to(admin_report_path(report)) - end - end - - describe 'PATCH #update' do - subject do - -> { patch :update, params: { report_id: report, id: status, status: { sensitive: sensitive } } } - end - - let(:status) { Fabricate(:status, sensitive: !sensitive) } - let(:sensitive) { true } - - context 'updates sensitive column to true' do - it 'updates sensitive column' do - is_expected.to change { - status.reload.sensitive - }.from(false).to(true) - end - end + context 'when action is delete' do + let(:action) { 'delete' } - context 'updates sensitive column to false' do - let(:sensitive) { false } - - it 'updates sensitive column' do - is_expected.to change { - status.reload.sensitive - }.from(true).to(false) + it 'removes a status' do + allow(RemovalWorker).to receive(:perform_async) + subject.call + expect(RemovalWorker).to have_received(:perform_async).with(status_ids.first) end end @@ -78,15 +56,4 @@ describe Admin::ReportedStatusesController do expect(response).to redirect_to(admin_report_path(report)) end end - - describe 'DELETE #destroy' do - it 'removes a status' do - allow(RemovalWorker).to receive(:perform_async) - - delete :destroy, params: { report_id: report, id: status } - expect(response).to have_http_status(200) - expect(RemovalWorker). - to have_received(:perform_async).with(status.id) - end - end end diff --git a/spec/controllers/admin/statuses_controller_spec.rb b/spec/controllers/admin/statuses_controller_spec.rb index cbaf39786..6afcc1442 100644 --- a/spec/controllers/admin/statuses_controller_spec.rb +++ b/spec/controllers/admin/statuses_controller_spec.rb @@ -34,13 +34,13 @@ describe Admin::StatusesController do describe 'POST #create' do subject do - -> { post :create, params: { account_id: account.id, form_status_batch: { action: action, status_ids: status_ids } } } + -> { post :create, params: { :account_id => account.id, action => '', :form_status_batch => { status_ids: status_ids } } } end let(:action) { 'nsfw_on' } let(:status_ids) { [media_attached_status.id] } - context 'updates sensitive column to true' do + context 'when action is nsfw_on' do it 'updates sensitive column' do is_expected.to change { media_attached_status.reload.sensitive @@ -48,7 +48,7 @@ describe Admin::StatusesController do end end - context 'updates sensitive column to false' do + context 'when action is nsfw_off' do let(:action) { 'nsfw_off' } let(:sensitive) { false } @@ -59,32 +59,13 @@ describe Admin::StatusesController do end end - it 'redirects to account statuses page' do - subject.call - expect(response).to redirect_to(admin_account_statuses_path(account.id)) - end - end - - describe 'PATCH #update' do - subject do - -> { patch :update, params: { account_id: account.id, id: media_attached_status, status: { sensitive: sensitive } } } - end - - context 'updates sensitive column to true' do - it 'updates sensitive column' do - is_expected.to change { - media_attached_status.reload.sensitive - }.from(false).to(true) - end - end - - context 'updates sensitive column to false' do - let(:sensitive) { false } + context 'when action is delete' do + let(:action) { 'delete' } - it 'updates sensitive column' do - is_expected.to change { - media_attached_status.reload.sensitive - }.from(true).to(false) + it 'removes a status' do + allow(RemovalWorker).to receive(:perform_async) + subject.call + expect(RemovalWorker).to have_received(:perform_async).with(status_ids.first) end end @@ -93,15 +74,4 @@ describe Admin::StatusesController do expect(response).to redirect_to(admin_account_statuses_path(account.id)) end end - - describe 'DELETE #destroy' do - it 'removes a status' do - allow(RemovalWorker).to receive(:perform_async) - - delete :destroy, params: { account_id: account.id, id: status } - expect(response).to have_http_status(200) - expect(RemovalWorker). - to have_received(:perform_async).with(status.id) - end - end end -- cgit From bd10a7e48076c913a652c347b0477496be8813fa Mon Sep 17 00:00:00 2001 From: Shuhei Kitagawa Date: Sun, 6 May 2018 17:59:03 +0900 Subject: Add resend confirmation for admin (#7378) * Add confirmations_controller#resend * Add tests for confirmations_controller#resend * Add translations --- app/controllers/admin/confirmations_controller.rb | 19 +++++++++++++ app/views/admin/accounts/show.html.haml | 10 +++++-- config/locales/ar.yml | 6 +++++ config/locales/ca.yml | 6 +++++ config/locales/de.yml | 6 +++++ config/locales/en.yml | 6 +++++ config/locales/eo.yml | 6 +++++ config/locales/es.yml | 6 +++++ config/locales/fa.yml | 6 +++++ config/locales/fi.yml | 6 +++++ config/locales/fr.yml | 6 +++++ config/locales/gl.yml | 6 +++++ config/locales/he.yml | 6 +++++ config/locales/hu.yml | 6 +++++ config/locales/id.yml | 6 +++++ config/locales/it.yml | 6 +++++ config/locales/ja.yml | 6 +++++ config/locales/ko.yml | 6 +++++ config/locales/nl.yml | 6 +++++ config/locales/no.yml | 6 +++++ config/locales/oc.yml | 6 +++++ config/locales/pl.yml | 6 +++++ config/locales/pt-BR.yml | 6 +++++ config/locales/pt.yml | 6 +++++ config/locales/ru.yml | 6 +++++ config/locales/sk.yml | 6 +++++ config/locales/sr-Latn.yml | 6 +++++ config/locales/sr.yml | 6 +++++ config/locales/sv.yml | 6 +++++ config/locales/th.yml | 6 +++++ config/locales/tr.yml | 6 +++++ config/locales/zh-CN.yml | 6 +++++ config/locales/zh-HK.yml | 6 +++++ config/routes.rb | 9 +++++-- .../admin/confirmations_controller_spec.rb | 31 ++++++++++++++++++++++ 35 files changed, 251 insertions(+), 4 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/confirmations_controller.rb b/app/controllers/admin/confirmations_controller.rb index 34dfb458e..8d3477e66 100644 --- a/app/controllers/admin/confirmations_controller.rb +++ b/app/controllers/admin/confirmations_controller.rb @@ -3,6 +3,7 @@ module Admin class ConfirmationsController < BaseController before_action :set_user + before_action :check_confirmation, only: [:resend] def create authorize @user, :confirm? @@ -11,10 +12,28 @@ module Admin redirect_to admin_accounts_path end + def resend + authorize @user, :confirm? + + @user.resend_confirmation_instructions + + log_action :confirm, @user + + flash[:notice] = I18n.t('admin.accounts.resend_confirmation.success') + redirect_to admin_accounts_path + end + private def set_user @user = Account.find(params[:account_id]).user || raise(ActiveRecord::RecordNotFound) end + + def check_confirmation + if @user.confirmed? + flash[:error] = I18n.t('admin.accounts.resend_confirmation.already_confirmed') + redirect_to admin_accounts_path + end + end end end diff --git a/app/views/admin/accounts/show.html.haml b/app/views/admin/accounts/show.html.haml index 2e6de1864..ed8190af5 100644 --- a/app/views/admin/accounts/show.html.haml +++ b/app/views/admin/accounts/show.html.haml @@ -36,13 +36,19 @@ %th= t('admin.accounts.email') %td = @account.user_email - - if @account.user_confirmed? - = fa_icon('check') = table_link_to 'edit', t('admin.accounts.change_email.label'), admin_account_change_email_path(@account.id) if can?(:change_email, @account.user) - if @account.user_unconfirmed_email.present? %th= t('admin.accounts.unconfirmed_email') %td = @account.user_unconfirmed_email + %tr + %th= t('admin.accounts.email_status') + %td + - if @account.user&.confirmed? + = t('admin.accounts.confirmed') + - else + = t('admin.accounts.confirming') + = table_link_to 'refresh', t('admin.accounts.resend_confirmation.send'), resend_admin_account_confirmation_path(@account.id), method: :post if can?(:confirm, @account.user) %tr %th= t('admin.accounts.login_status') %td diff --git a/config/locales/ar.yml b/config/locales/ar.yml index a5179ae14..eb0127eb5 100644 --- a/config/locales/ar.yml +++ b/config/locales/ar.yml @@ -61,6 +61,7 @@ ar: by_domain: النطاق confirm: تأكيد confirmed: مؤكَّد + confirming: التأكد demote: إنزال الرُتبة الوظيفية disable: تعطيل disable_two_factor_authentication: تعطيل 2FA @@ -69,6 +70,7 @@ ar: domain: النطاق edit: تعديل email: البريد الإلكتروني + email_status: حالة البريد الإلكتروني enable: تفعيل enabled: مفعَّل feed_url: عنوان رابط التغذية @@ -106,6 +108,10 @@ ar: public: عمومي push_subscription_expires: انتهاء الاشتراك ”PuSH“ redownload: تحديث الصورة الرمزية + resend_confirmation: + already_confirmed: هذا المستخدم مؤكد بالفعل + send: أعد إرسال رسالة البريد الالكتروني الخاصة بالتأكيد + success: تم إرسال رسالة التأكيد بنجاح! reset: إعادة التعيين reset_password: إعادة ضبط كلمة السر resubscribe: اشترك مرة أخرى diff --git a/config/locales/ca.yml b/config/locales/ca.yml index a8c75c32d..bdc3f7484 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -70,6 +70,7 @@ ca: title: Canviar adreça de correu de %{username} confirm: Confirma confirmed: Confirmat + confirming: Confirmando demote: Degrada disable: Inhabilita disable_two_factor_authentication: Desactiva 2FA @@ -78,6 +79,7 @@ ca: domain: Domini edit: Edita email: Correu electrònic + email_status: Estado del correo electrónico enable: Habilita enabled: Habilitat feed_url: URL del canal @@ -116,6 +118,10 @@ ca: push_subscription_expires: La subscripció PuSH expira redownload: Actualitza l'avatar remove_avatar: Eliminar avatar + resend_confirmation: + already_confirmed: Este usuario ya está confirmado + send: Reenviar el correo electrónico de confirmación + success: "¡Correo electrónico de confirmación enviado con éxito!" reset: Reinicialitza reset_password: Restableix la contrasenya resubscribe: Torna a subscriure diff --git a/config/locales/de.yml b/config/locales/de.yml index aa4295c89..05d7e01b3 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -70,6 +70,7 @@ de: title: E-Mail-Adresse für %{username} ändern confirm: Bestätigen confirmed: Bestätigt + confirming: Bestätigung demote: Degradieren disable: Ausschalten disable_two_factor_authentication: 2FA abschalten @@ -78,6 +79,7 @@ de: domain: Domain edit: Bearbeiten email: E-Mail + email_status: E-Mail-Status enable: Freischalten enabled: Freigegeben feed_url: Feed-URL @@ -116,6 +118,10 @@ de: push_subscription_expires: PuSH-Abonnement läuft aus redownload: Avatar neu laden remove_avatar: Profilbild entfernen + resend_confirmation: + already_confirmed: Dieser Benutzer wurde bereits bestätigt + send: Bestätigungsmail erneut senden + success: Bestätigungs-E-Mail erfolgreich gesendet! reset: Zurücksetzen reset_password: Passwort zurücksetzen resubscribe: Wieder abonnieren diff --git a/config/locales/en.yml b/config/locales/en.yml index 4f967f9ac..e18354eac 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -70,6 +70,7 @@ en: title: Change Email for %{username} confirm: Confirm confirmed: Confirmed + confirming: Confirming demote: Demote disable: Disable disable_two_factor_authentication: Disable 2FA @@ -78,6 +79,7 @@ en: domain: Domain edit: Edit email: E-mail + email_status: E-mail Status enable: Enable enabled: Enabled feed_url: Feed URL @@ -116,6 +118,10 @@ en: push_subscription_expires: PuSH subscription expires redownload: Refresh avatar remove_avatar: Remove avatar + resend_confirmation: + already_confirmed: This user is already confirmed + send: Resend confirmation email + success: Confirmation email successfully sent! reset: Reset reset_password: Reset password resubscribe: Resubscribe diff --git a/config/locales/eo.yml b/config/locales/eo.yml index 9c44d0e62..47d591993 100644 --- a/config/locales/eo.yml +++ b/config/locales/eo.yml @@ -61,6 +61,7 @@ eo: by_domain: Domajno confirm: Konfirmi confirmed: Konfirmita + confirming: Konfirmante demote: Degradi disable: Malebligi disable_two_factor_authentication: Malebligi 2FA @@ -69,6 +70,7 @@ eo: domain: Domajno edit: Redakti email: Retpoŝto + email_status: Retpoŝto Stato enable: Ebligi enabled: Ebligita feed_url: URL de la fluo @@ -106,6 +108,10 @@ eo: public: Publika push_subscription_expires: Eksvalidiĝo de la abono al PuSH redownload: Aktualigi profilbildon + resend_confirmation: + already_confirmed: Ĉi tiu uzanto jam estas konfirmita + send: Esend konfirmi retpoŝton + success: Konfirma retpoŝto sukcese sendis reset: Restarigi reset_password: Restarigi pasvorton resubscribe: Reaboni diff --git a/config/locales/es.yml b/config/locales/es.yml index be7dcd81e..11bee3239 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -70,6 +70,7 @@ es: title: Cambiar el correo electrónico de %{username} confirm: Confirmar confirmed: Confirmado + confirming: Confirmando demote: Degradar disable: Deshabilitar disable_two_factor_authentication: Desactivar autenticación de dos factores @@ -78,6 +79,7 @@ es: domain: Dominio edit: Editar email: E-mail + email_status: E-mail Status enable: Habilitar enabled: Habilitada feed_url: URL de notificaciones @@ -116,6 +118,10 @@ es: push_subscription_expires: Expiración de la suscripción PuSH redownload: Refrescar avatar remove_avatar: Eliminar el avatar + resend_confirmation: + already_confirmed: Este usuario ya está confirmado + send: Reenviar el correo electrónico de confirmación + success: "¡Correo electrónico de confirmación enviado con éxito" reset: Reiniciar reset_password: Reiniciar contraseña resubscribe: Re-suscribir diff --git a/config/locales/fa.yml b/config/locales/fa.yml index 3aa40f0b3..5255e0e38 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -61,6 +61,7 @@ fa: by_domain: دامین confirm: تأیید confirmed: تأیید شد + confirming: تأیید demote: تنزل‌دادن disable: غیرفعال disable_two_factor_authentication: غیرفعال‌سازی ورود دومرحله‌ای @@ -69,6 +70,7 @@ fa: domain: دامین edit: ویرایش email: ایمیل + email_status: وضعیت ایمیل enable: فعال enabled: فعال feed_url: نشانی فید @@ -106,6 +108,10 @@ fa: public: عمومی push_subscription_expires: عضویت از راه PuSH منقضی شد redownload: به‌روزرسانی تصویر نمایه + resend_confirmation: + already_confirmed: این کاربر قبلا تایید شده است + send: ایمیل تایید را دوباره بفرستید + success: ایمیل تایید با موفقیت ارسال شد reset: بازنشانی reset_password: بازنشانی رمز resubscribe: اشتراک دوباره diff --git a/config/locales/fi.yml b/config/locales/fi.yml index b313c8723..fca58cc0f 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -61,6 +61,7 @@ fi: by_domain: Verkko-osoite confirm: Vahvista confirmed: Vahvistettu + confirming: Vahvistavat demote: Alenna disable: Poista käytöstä disable_two_factor_authentication: Poista 2FA käytöstä @@ -69,6 +70,7 @@ fi: domain: Verkko-osoite edit: Muokkaa email: Sähköposti + email_status: Sähköpostin tila enable: Ota käyttöön enabled: Käytössä feed_url: Syötteen URL @@ -106,6 +108,10 @@ fi: public: Julkinen push_subscription_expires: PuSH-tilaus vanhenee redownload: Päivitä profiilikuva + resend_confirmation: + already_confirmed: Tämä käyttäjä on jo vahvistettu + send: Lähetä varmistusviesti uudelleen + success: Vahvistusviesti lähetettiin onnistuneesti reset: Palauta reset_password: Palauta salasana resubscribe: Tilaa uudelleen diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 3b543fdb7..e7142f3fd 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -70,6 +70,7 @@ fr: title: Modifier le courriel pour %{username} confirm: Confirmer confirmed: Confirmé + confirming: Confirmant demote: Rétrograder disable: Désactiver disable_two_factor_authentication: Désactiver l’authentification à deux facteurs @@ -78,6 +79,7 @@ fr: domain: Domaine edit: Éditer email: Courriel + email_status: État de la messagerie enable: Activer enabled: Activé feed_url: URL du flux @@ -116,6 +118,10 @@ fr: push_subscription_expires: Expiration de l’abonnement PuSH redownload: Rafraîchir les avatars remove_avatar: Supprimer l'avatar + resend_confirmation: + already_confirmed: Cet utilisateur est déjà confirmé + send: Renvoyer un courriel de confirmation + success: Email de confirmation envoyé avec succès ! reset: Réinitialiser reset_password: Réinitialiser le mot de passe resubscribe: Se réabonner diff --git a/config/locales/gl.yml b/config/locales/gl.yml index eec1b4e1e..e00c4b433 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -70,6 +70,7 @@ gl: title: Cambiar o correo-e de %{username} confirm: Confirmar confirmed: Confirmado + confirming: Confirmar demote: Degradar disable: Deshabilitar disable_two_factor_authentication: Deshabilitar 2FA @@ -78,6 +79,7 @@ gl: domain: Dominio edit: Editar email: E-mail + email_status: Estado del correo electrónico enable: Habilitar enabled: Habilitado feed_url: URL fonte @@ -116,6 +118,10 @@ gl: push_subscription_expires: A suscrición PuSH caduca redownload: Actualizar avatar remove_avatar: Eliminar avatar + resend_confirmation: + already_confirmed: Este usuario ya está confirmado + send: Reenviar el correo electrónico de confirmación + success: "¡Correo electrónico de confirmación enviado con éxito!" reset: Restablecer reset_password: Restablecer contrasinal resubscribe: Voltar a suscribir diff --git a/config/locales/he.yml b/config/locales/he.yml index d66d9f034..c127db385 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -61,6 +61,7 @@ he: by_domain: שם מתחם confirm: אישור confirmed: אושר + confirming: המאשר demote: הורדה בדרגה disable: לחסום disable_two_factor_authentication: ביטול הזדהות דו-שלבית @@ -69,6 +70,7 @@ he: domain: תחום edit: עריכה email: דוא"ל + email_status: סטטוס דוא"ל enable: לאפשר enabled: מאופשר feed_url: כתובת פיד @@ -106,6 +108,10 @@ he: public: פומבי push_subscription_expires: הרשמה להודעות בדחיפה פגה redownload: לקריאה מחדש של האווטאר + resend_confirmation: + already_confirmed: משתמש זה כבר אושר + send: שלח מחדש דוא"ל אימות + success: הודעת האימייל נשלחה בהצלחה! reset: איפוס reset_password: אתחול סיסמא resubscribe: להרשם מחדש diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 422c05955..0cd0021c1 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -61,6 +61,7 @@ hu: by_domain: Domain confirm: Megerősítés confirmed: Megerősítve + confirming: Megerősítve demote: Lefokozás disable: Kikapcsolás disable_two_factor_authentication: Kétlépcsős azonosítás kikapcsolása @@ -69,6 +70,7 @@ hu: domain: Domain edit: Szerkesztés email: E-mail + email_status: E-mail állapot enable: Engedélyezés enabled: Engedélyezve feed_url: Hírcsatorna URL @@ -106,6 +108,10 @@ hu: public: Nyilvános push_subscription_expires: A PuSH feliratkozás elévül redownload: Profilkép frissítése + resend_confirmation: + already_confirmed: Ezt a felhasználót már megerősítették + send: Küldd újra a megerősítő email-t + success: A megerősítő e-mail sikeresen elküldve! reset: Visszaállítás reset_password: Jelszó visszaállítása resubscribe: Feliratkozás ismét diff --git a/config/locales/id.yml b/config/locales/id.yml index 0476e2848..4fb75f2b0 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -29,10 +29,12 @@ id: are_you_sure: Anda yakin? confirm: Konfirmasi confirmed: Dikonfirmasi + confirming: Mengkonfirmasi display_name: Nama domain: Domain edit: Ubah email: E-mail + email_status: Status Email feed_url: URL Feed followers: Pengikut follows: Mengikut @@ -58,6 +60,10 @@ id: profile_url: URL profil public: Publik push_subscription_expires: Langganan PuSH telah kadaluarsa + resend_confirmation: + already_confirmed: Pengguna ini sudah dikonfirmasi + send: Kirim ulang email konfirmasi + success: Email konfirmasi berhasil dikirim! reset_password: Reset kata sandi salmon_url: URL Salmon show: diff --git a/config/locales/it.yml b/config/locales/it.yml index c1ac176c4..eafe6b2a1 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -66,6 +66,7 @@ it: title: Cambia email per %{username} confirm: Conferma confirmed: Confermato + confirming: Confermando demote: Declassa disable: Disabilita disable_two_factor_authentication: Disabilita 2FA @@ -74,6 +75,7 @@ it: domain: Dominio edit: Modifica email: Email + email_status: Stato email enable: Abilita enabled: Abilitato feed_url: URL Feed @@ -111,6 +113,10 @@ it: public: Pubblico redownload: Aggiorna avatar remove_avatar: Rimuovi avatar + resend_confirmation: + already_confirmed: Questo utente è già confermato + send: Reinvia email di conferma + success: Email di conferma inviata con successo! reset: Reimposta reset_password: Reimposta password resubscribe: Riscriversi diff --git a/config/locales/ja.yml b/config/locales/ja.yml index bc48613b9..c7025fc18 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -70,6 +70,7 @@ ja: title: "%{username} さんのメールアドレスを変更" confirm: 確認 confirmed: 確認済み + confirming: 確認中 demote: 降格 disable: 無効化 disable_two_factor_authentication: 二段階認証を無効にする @@ -78,6 +79,7 @@ ja: domain: ドメイン edit: 編集 email: メールアドレス + email_status: メールアドレスの状態 enable: 有効化 enabled: 有効 feed_url: フィードURL @@ -116,6 +118,10 @@ ja: push_subscription_expires: PuSH購読期限 redownload: アバターの更新 remove_avatar: アイコンを削除 + resend_confirmation: + already_confirmed: メールアドレスは確認済みです。 + send: 確認メールを再送 + success: 確認メールを再送信しました! reset: リセット reset_password: パスワード再設定 resubscribe: 再講読 diff --git a/config/locales/ko.yml b/config/locales/ko.yml index bd6717d49..92e99ce50 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -70,6 +70,7 @@ ko: title: "%{username}의 이메일 주소 변경" confirm: 확인 confirmed: 확인됨 + confirming: 확인 중 demote: 모더레이터 강등 disable: 비활성화 disable_two_factor_authentication: 2단계 인증을 비활성화 @@ -78,6 +79,7 @@ ko: domain: 도메인 edit: 편집 email: E-mail + email_status: 이메일 상태 enable: 활성화 enabled: 활성화된 feed_url: 피드 URL @@ -116,6 +118,10 @@ ko: push_subscription_expires: PuSH 구독 기간 만료 redownload: 아바타 업데이트 remove_avatar: 아바타 지우기 + resend_confirmation: + already_confirmed: 이 사용자는 이미 확인되었습니다. + send: 다시 확인 이메일 + success: 확인 이메일이 전송되었습니다. reset: 초기화 reset_password: 비밀번호 초기화 resubscribe: 다시 구독 diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 00f21babd..6ca81b375 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -70,6 +70,7 @@ nl: title: E-mailadres veranderen voor %{username} confirm: Bevestigen confirmed: Bevestigd + confirming: Bevestiging demote: Degraderen disable: Uitschakelen disable_two_factor_authentication: 2FA uitschakelen @@ -78,6 +79,7 @@ nl: domain: Domein edit: Bewerken email: E-mail + email_status: E-mail Status enable: Inschakelen enabled: Ingeschakeld feed_url: Feed-URL @@ -116,6 +118,10 @@ nl: push_subscription_expires: PuSH-abonnement verloopt op redownload: Avatar vernieuwen remove_avatar: Avatar verwijderen + resend_confirmation: + already_confirmed: Deze gebruiker is al bevestigd + send: Verzend bevestigingsmail opnieuw + success: Bevestigingsmail succesvol verzonden! reset: Opnieuw reset_password: Wachtwoord opnieuw instellen resubscribe: Opnieuw abonneren diff --git a/config/locales/no.yml b/config/locales/no.yml index 6ce2c0f01..837042f85 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -61,6 +61,7 @@ by_domain: Domene confirm: Bekreft confirmed: Bekreftet + confirming: Bekrefte demote: Degrader disable: Deaktiver disable_two_factor_authentication: Skru av 2FA @@ -69,6 +70,7 @@ domain: Domene edit: Redigér email: E-post + email_status: E-poststatus enable: Aktiver enabled: Aktivert feed_url: Feed-URL @@ -106,6 +108,10 @@ public: Offentlig push_subscription_expires: PuSH-abonnent utløper redownload: Oppdater avatar + resend_confirmation: + already_confirmed: Denne brukeren er allerede bekreftet + send: Send bekreftelses-epost på nytt + success: Bekreftelses e-post er vellykket sendt! reset: Tilbakestill reset_password: Nullstill passord resubscribe: Abonner på nytt diff --git a/config/locales/oc.yml b/config/locales/oc.yml index c11fe614b..e61f7ebd0 100644 --- a/config/locales/oc.yml +++ b/config/locales/oc.yml @@ -70,6 +70,7 @@ oc: title: Cambiar l’adreça a %{username} confirm: Confirmar confirmed: Confirmat + confirming: Confirmando demote: Retrogradar disable: Desactivar disable_two_factor_authentication: Desactivar 2FA @@ -78,6 +79,7 @@ oc: domain: Domeni edit: Modificar email: Corrièl + email_status: Estado del correo electrónico enable: Activar enabled: Activat feed_url: Flux URL @@ -116,6 +118,10 @@ oc: push_subscription_expires: Fin de l’abonament PuSH redownload: Actualizar los avatars remove_avatar: Supriir l’avatar + resend_confirmation: + already_confirmed: Este usuario ya está confirmado + send: Reenviar el correo electrónico de confirmación + success: "¡Correo electrónico de confirmación enviado con éxito!" reset: Reïnicializar reset_password: Reïnicializar lo senhal resubscribe: Se tornar abonar diff --git a/config/locales/pl.yml b/config/locales/pl.yml index bd38aa6f7..1fbe0d5c8 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -70,6 +70,7 @@ pl: title: Zmień adres e-mail dla %{username} confirm: Potwierdź confirmed: Potwierdzono + confirming: Potwierdzam demote: Degraduj disable: Dezaktywuj disable_two_factor_authentication: Wyłącz uwierzytelnianie dwuetapowe @@ -78,6 +79,7 @@ pl: domain: Domena edit: Edytuj email: Adres e-mail + email_status: Status e-maila enable: Aktywuj enabled: Aktywowano feed_url: Adres kanału @@ -116,6 +118,10 @@ pl: push_subscription_expires: Subskrypcja PuSH wygasa redownload: Odśwież awatar remove_avatar: Usun awatar + resend_confirmation: + already_confirmed: Ten użytkownik jest już potwierdzony + send: Wyślij ponownie email potwierdzający + success: E-mail z potwierdzeniem został wysłany! reset: Resetuj reset_password: Resetuj hasło resubscribe: Ponów subskrypcję diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 862833d87..37abeffd9 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -70,6 +70,7 @@ pt-BR: title: Mudar e-mail para %{username} confirm: Confirmar confirmed: Confirmado + confirming: Confirmando demote: Rebaixar disable: Desativar disable_two_factor_authentication: Desativar 2FA @@ -78,6 +79,7 @@ pt-BR: domain: Domínio edit: Editar email: E-mail + email_status: Estado del correo electrónico enable: Ativar enabled: Ativado feed_url: URL do feed @@ -116,6 +118,10 @@ pt-BR: push_subscription_expires: Inscrição PuSH expira redownload: Atualizar avatar remove_avatar: Remover avatar + resend_confirmation: + already_confirmed: Este usuario ya está confirmado + send: Reenviar el correo electrónico de confirmación + success: "¡Correo electrónico de confirmación enviado con éxito!" reset: Anular reset_password: Modificar senha resubscribe: Reinscrever-se diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 62a7ef0ec..7c10124ff 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -61,6 +61,7 @@ pt: by_domain: Domínio confirm: Confirme confirmed: Confirmado + confirming: Confirmer demote: Rebaixar disable: Desativar disable_two_factor_authentication: Desativar 2FA @@ -69,6 +70,7 @@ pt: domain: Domínio edit: Editar email: E-mail + email_status: État de la messagerie enable: Ativar enabled: Ativado feed_url: URL do Feed @@ -106,6 +108,10 @@ pt: public: Público push_subscription_expires: A Inscrição PuSH expira redownload: Atualizar avatar + resend_confirmation: + already_confirmed: Cet utilisateur est déjà confirmé + send: Renvoyer un courriel de confirmation + success: Email de confirmation envoyé avec succès! reset: Restaurar reset_password: Reset palavra-passe resubscribe: Reinscrever diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 603e1f3ca..99825a765 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -61,6 +61,7 @@ ru: by_domain: Домен confirm: Подтвердить confirmed: Подтверждено + confirming: подтверждающий demote: Разжаловать disable: Отключить disable_two_factor_authentication: Отключить 2FA @@ -69,6 +70,7 @@ ru: domain: Домен edit: Изменить email: E-mail + email_status: Статус электронной почты enable: Включить enabled: Включен feed_url: URL фида @@ -106,6 +108,10 @@ ru: public: Публичный push_subscription_expires: Подписка PuSH истекает redownload: Обновить аватар + resend_confirmation: + already_confirmed: Этот пользователь уже подтвержден + send: Повторно отправить подтверждение по электронной почте + success: Письмо с подтверждением успешно отправлено! reset: Сбросить reset_password: Сбросить пароль resubscribe: Переподписаться diff --git a/config/locales/sk.yml b/config/locales/sk.yml index 7fb097f03..ef756b474 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -70,6 +70,7 @@ sk: title: Zmeň email pre %{username} confirm: Potvrdiť confirmed: Potvrdený + confirming: Potvrdzujúci demote: Degradovať disable: Zablokovať disable_two_factor_authentication: Zakázať 2FA @@ -78,6 +79,7 @@ sk: domain: Doména edit: Upraviť email: Email + email_status: Stav Email enable: Povoliť enabled: Povolený feed_url: URL časovej osi @@ -116,6 +118,10 @@ sk: push_subscription_expires: PuSH odoberanie expiruje redownload: Obnoviť avatar remove_avatar: Odstrániť avatár + resend_confirmation: + already_confirmed: Tento používateľ už bol potvrdený + send: Znova odoslať potvrdzovací e-mail + success: Potvrdený e-mail bol úspešne odoslaný! reset: Reset reset_password: Obnoviť heslo resubscribe: Znovu odoberať diff --git a/config/locales/sr-Latn.yml b/config/locales/sr-Latn.yml index dba952917..0c7756c53 100644 --- a/config/locales/sr-Latn.yml +++ b/config/locales/sr-Latn.yml @@ -61,6 +61,7 @@ sr-Latn: by_domain: Domen confirm: Potvrdi confirmed: Potvrđeno + confirming: Potvrđujući demote: Ražaluj disable: Isključi disable_two_factor_authentication: Isključi 2FA @@ -69,6 +70,7 @@ sr-Latn: domain: Domen edit: Izmeni email: E-pošta + email_status: Status e-pošte enable: Uključi enabled: Uključeno feed_url: Adresa dovoda @@ -106,6 +108,10 @@ sr-Latn: public: Javno push_subscription_expires: PuSH subscription expires redownload: Osveži avatar + resend_confirmation: + already_confirmed: Ovaj korisnik je već potvrđen + send: Ponovo pošaljite e-poruku za potvrdu + success: E-mail potvrde je uspešno poslat! reset: Resetuj reset_password: Resetuj lozinku resubscribe: Ponovo se pretplati diff --git a/config/locales/sr.yml b/config/locales/sr.yml index 74abf0323..1cb87ff30 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -61,6 +61,7 @@ sr: by_domain: Домен confirm: Потврди confirmed: Потврђено + confirming: Потврдување demote: Ражалуј disable: Искључи disable_two_factor_authentication: Искључи 2FA @@ -69,6 +70,7 @@ sr: domain: Домен edit: Измени email: Е-пошта + email_status: Е-пошта статус enable: Укључи enabled: Укључено feed_url: Адреса довода @@ -106,6 +108,10 @@ sr: public: Јавно push_subscription_expires: PuSH subscription expires redownload: Освежи аватар + resend_confirmation: + already_confirmed: Овој корисник е веќе потврден + send: Препрати го е-мајлот за потврда + success: Е-пошта за потврда успешно испратена! reset: Ресетуј reset_password: Ресетуј лозинку resubscribe: Поново се претплати diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 9e0bb0856..1b0965655 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -70,6 +70,7 @@ sv: title: Byt E-postadress för %{username} confirm: Bekräfta confirmed: Bekräftad + confirming: Bekräftande demote: Degradera disable: inaktivera disable_two_factor_authentication: Inaktivera 2FA @@ -78,6 +79,7 @@ sv: domain: Domän edit: Redigera email: E-post + email_status: E-poststatus enable: Aktivera enabled: Aktiverad feed_url: Flödes URL @@ -116,6 +118,10 @@ sv: push_subscription_expires: PuSH-prenumerationen löper ut redownload: Uppdatera avatar remove_avatar: Ta bort avatar + resend_confirmation: + already_confirmed: Den här användaren är redan bekräftad + send: Skicka om e-postbekräftelse + success: Bekräftelsemeddelande skickas framgångsrikt! reset: Återställ reset_password: Återställ lösenord resubscribe: Starta en ny prenumeration diff --git a/config/locales/th.yml b/config/locales/th.yml index 9d93115b0..6804dbd13 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -29,11 +29,13 @@ th: are_you_sure: แน่ใจนะ? confirm: ยืนยัน confirmed: ยึนยันแล้ว + confirming: ยืนยัน disable_two_factor_authentication: Disable 2FA display_name: ชื่อสำหรับดีสเพล domain: โดแมน edit: แก้ไข email: อีเมล์ + email_status: สถานะอีเมล feed_url: Feed URL followers: ผู้ติดตาม follows: ติดตาม @@ -59,6 +61,10 @@ th: profile_url: Profile URL public: สาธารณะ push_subscription_expires: PuSH subscription expires + resend_confirmation: + already_confirmed: ผู้ใช้รายนี้ได้รับการยืนยันแล้ว + send: ส่งอีเมลยืนยันอีกครั้ง + success: ยืนยันอีเมลเรียบร้อยแล้ว! reset_password: รีเซ็ตรหัสผ่าน salmon_url: Salmon URL show: diff --git a/config/locales/tr.yml b/config/locales/tr.yml index 0d78216b6..8bafbface 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -29,10 +29,12 @@ tr: are_you_sure: Emin misiniz? confirm: Onayla confirmed: Onaylandı + confirming: Onaylama display_name: Görünen adınız domain: Sunucu edit: Düzenle email: E-posta + email_status: Email Durumu feed_url: Besleme linki followers: Takipçiler follows: Takip edilen @@ -58,6 +60,10 @@ tr: profile_url: Profil linki public: Herkese açık push_subscription_expires: PuSH aboneliği dolumu + resend_confirmation: + already_confirmed: Bu kullanıcı zaten onaylandı + send: Doğrulama epostasını yeniden gönder + success: Onay e-postası başarıyla gönderildi! reset_password: Parolayı değiştir salmon_url: Salmon Linki show: diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 7ea491fd4..5eca9e6a5 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -61,6 +61,7 @@ zh-CN: by_domain: 域名 confirm: 确认 confirmed: 已确认 + confirming: 确认 demote: 降任 disable: 停用 disable_two_factor_authentication: 停用双重认证 @@ -69,6 +70,7 @@ zh-CN: domain: 域名 edit: 编辑 email: 电子邮件地址 + email_status: 电子邮件状态 enable: 启用 enabled: 已启用 feed_url: 订阅 URL @@ -106,6 +108,10 @@ zh-CN: public: 公开页面 push_subscription_expires: PuSH 订阅过期时间 redownload: 刷新头像 + resend_confirmation: + already_confirmed: 该用户已被确认 + send: 重发确认邮件 + success: 确认电子邮件成功发送! reset: 重置 reset_password: 重置密码 resubscribe: 重新订阅 diff --git a/config/locales/zh-HK.yml b/config/locales/zh-HK.yml index 3f91b7191..c5d8c8696 100644 --- a/config/locales/zh-HK.yml +++ b/config/locales/zh-HK.yml @@ -70,6 +70,7 @@ zh-HK: title: 改變 %{username} 的電郵 confirm: 確定 confirmed: 已確定 + confirming: 確定 demote: 降任 disable: 停用 disable_two_factor_authentication: 停用雙重認證 @@ -78,6 +79,7 @@ zh-HK: domain: 域名 edit: 編輯 email: 電郵地址 + email_status: 电子邮件状态 enable: 啟用 enabled: 已啟用 feed_url: Feed URL @@ -116,6 +118,10 @@ zh-HK: push_subscription_expires: PuSH 訂閱過期 redownload: 更新頭像 remove_avatar: 取消頭像 + resend_confirmation: + already_confirmed: 该用户已被确认 + send: 重发确认邮件 + success: 确认电子邮件成功发送! reset: 重設 reset_password: 重設密碼 resubscribe: 重新訂閱 diff --git a/config/routes.rb b/config/routes.rb index 90f6ac594..4c920cf74 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -155,8 +155,13 @@ Rails.application.routes.draw do resource :reset, only: [:create] resource :silence, only: [:create, :destroy] resource :suspension, only: [:create, :destroy] - resource :confirmation, only: [:create] - resources :statuses, only: [:index, :create] + resources :statuses, only: [:index, :create, :update, :destroy] + + resource :confirmation, only: [:create] do + collection do + post :resend + end + end resource :role do member do diff --git a/spec/controllers/admin/confirmations_controller_spec.rb b/spec/controllers/admin/confirmations_controller_spec.rb index 7c8034964..eec2b2f5c 100644 --- a/spec/controllers/admin/confirmations_controller_spec.rb +++ b/spec/controllers/admin/confirmations_controller_spec.rb @@ -30,4 +30,35 @@ RSpec.describe Admin::ConfirmationsController, type: :controller do expect(response).to have_http_status(404) end end + + describe 'POST #resernd' do + subject { post :resend, params: { account_id: account.id } } + + let(:account) { Fabricate(:account) } + let!(:user) { Fabricate(:user, confirmed_at: confirmed_at, account: account) } + + before do + allow(UserMailer).to receive(:confirmation_instructions) { double(:email, deliver_later: nil) } + end + + context 'when email is not confirmed' do + let(:confirmed_at) { nil } + + it 'resends confirmation mail' do + expect(subject).to redirect_to admin_accounts_path + expect(flash[:notice]).to eq I18n.t('admin.accounts.resend_confirmation.success') + expect(UserMailer).to have_received(:confirmation_instructions).once + end + end + + context 'when email is confirmed' do + let(:confirmed_at) { Time.zone.now } + + it 'does not resend confirmation mail' do + expect(subject).to redirect_to admin_accounts_path + expect(flash[:error]).to eq I18n.t('admin.accounts.resend_confirmation.already_confirmed') + expect(UserMailer).not_to have_received(:confirmation_instructions) + end + end + end end -- cgit From db012b57c2c3e65cfbd7d9b51e0c3081ed883400 Mon Sep 17 00:00:00 2001 From: abcang Date: Mon, 7 May 2018 16:30:18 +0900 Subject: Fix distribute_add_activity and distribute_remove_activity (#7393) --- app/controllers/api/v1/statuses/pins_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/api/v1/statuses/pins_controller.rb b/app/controllers/api/v1/statuses/pins_controller.rb index bba6a6f48..54f8be667 100644 --- a/app/controllers/api/v1/statuses/pins_controller.rb +++ b/app/controllers/api/v1/statuses/pins_controller.rb @@ -39,7 +39,7 @@ class Api::V1::Statuses::PinsController < Api::BaseController adapter: ActivityPub::Adapter ).as_json - ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), current_account) + ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), current_account.id) end def distribute_remove_activity! @@ -49,6 +49,6 @@ class Api::V1::Statuses::PinsController < Api::BaseController adapter: ActivityPub::Adapter ).as_json - ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), current_account) + ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), current_account.id) end end -- cgit From 42cd363542abf0a12a4e877b3ad26024f24577ef Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 7 May 2018 09:31:07 +0200 Subject: Bot nameplates (#7391) * Store actor type in database * Add bot nameplate to web UI, add setting to preferences, API, AP Fix #7365 * Fix code style issues --- app/controllers/api/v1/accounts/credentials_controller.rb | 2 +- app/controllers/settings/profiles_controller.rb | 2 +- app/javascript/mastodon/features/account/components/header.js | 4 ++++ app/javascript/styles/mastodon/components.scss | 6 ++++++ app/javascript/styles/mastodon/forms.scss | 4 ++++ app/models/account.rb | 11 +++++++++++ app/serializers/activitypub/actor_serializer.rb | 2 +- app/serializers/rest/account_serializer.rb | 2 +- app/services/activitypub/process_account_service.rb | 1 + app/views/accounts/_header.html.haml | 6 +++++- app/views/settings/profiles/show.html.haml | 3 +++ config/locales/en.yml | 1 + config/locales/simple_form.en.yml | 2 ++ db/migrate/20180506221944_add_actor_type_to_accounts.rb | 5 +++++ db/schema.rb | 3 ++- 15 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20180506221944_add_actor_type_to_accounts.rb (limited to 'app/controllers') diff --git a/app/controllers/api/v1/accounts/credentials_controller.rb b/app/controllers/api/v1/accounts/credentials_controller.rb index a3c4008e6..259d07be8 100644 --- a/app/controllers/api/v1/accounts/credentials_controller.rb +++ b/app/controllers/api/v1/accounts/credentials_controller.rb @@ -21,7 +21,7 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController private def account_params - params.permit(:display_name, :note, :avatar, :header, :locked, fields_attributes: [:name, :value]) + params.permit(:display_name, :note, :avatar, :header, :locked, :bot, fields_attributes: [:name, :value]) end def user_settings_params diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb index 5d81668de..1b01fc75f 100644 --- a/app/controllers/settings/profiles_controller.rb +++ b/app/controllers/settings/profiles_controller.rb @@ -27,7 +27,7 @@ class Settings::ProfilesController < ApplicationController private def account_params - params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, fields_attributes: [:name, :value]) + params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :bot, fields_attributes: [:name, :value]) end def set_account diff --git a/app/javascript/mastodon/features/account/components/header.js b/app/javascript/mastodon/features/account/components/header.js index 47915e6fb..7358053da 100644 --- a/app/javascript/mastodon/features/account/components/header.js +++ b/app/javascript/mastodon/features/account/components/header.js @@ -131,6 +131,7 @@ export default class Header extends ImmutablePureComponent { const content = { __html: account.get('note_emojified') }; const displayNameHtml = { __html: account.get('display_name_html') }; const fields = account.get('fields'); + const badge = account.get('bot') ? (
) : null; return (
@@ -139,6 +140,9 @@ export default class Header extends ImmutablePureComponent { @{account.get('acct')} {lockedIcon} + + {badge} +
{fields.size > 0 && ( diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 3e2a1ae10..158bf6851 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -5159,6 +5159,12 @@ noscript { } } +.account__header .roles { + margin-top: 20px; + margin-bottom: 20px; + padding: 0 15px; +} + .account__header .account__header__fields { font-size: 14px; line-height: 20px; diff --git a/app/javascript/styles/mastodon/forms.scss b/app/javascript/styles/mastodon/forms.scss index f97890187..de16784a8 100644 --- a/app/javascript/styles/mastodon/forms.scss +++ b/app/javascript/styles/mastodon/forms.scss @@ -87,6 +87,10 @@ code { align-items: flex-start; } + &.file .label_input { + flex-wrap: nowrap; + } + &.select .label_input { align-items: initial; } diff --git a/app/models/account.rb b/app/models/account.rb index 4467d1512..2b3ef5cdc 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -45,6 +45,7 @@ # moved_to_account_id :bigint(8) # featured_collection_url :string # fields :jsonb +# actor_type :string # class Account < ApplicationRecord @@ -149,6 +150,16 @@ class Account < ApplicationRecord moved_to_account_id.present? end + def bot? + %w(Application Service).include? actor_type + end + + alias bot bot? + + def bot=(val) + self.actor_type = ActiveModel::Type::Boolean.new.cast(val) ? 'Service' : 'Person' + end + def acct local? ? username : "#{username}@#{domain}" end diff --git a/app/serializers/activitypub/actor_serializer.rb b/app/serializers/activitypub/actor_serializer.rb index fcf3bdf17..41c9aa44e 100644 --- a/app/serializers/activitypub/actor_serializer.rb +++ b/app/serializers/activitypub/actor_serializer.rb @@ -37,7 +37,7 @@ class ActivityPub::ActorSerializer < ActiveModel::Serializer end def type - 'Person' + object.bot? ? 'Service' : 'Person' end def following diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index 8761bbb5e..6adcd7039 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -3,7 +3,7 @@ class REST::AccountSerializer < ActiveModel::Serializer include RoutingHelper - attributes :id, :username, :acct, :display_name, :locked, :created_at, + attributes :id, :username, :acct, :display_name, :locked, :bot, :created_at, :note, :url, :avatar, :avatar_static, :header, :header_static, :followers_count, :following_count, :statuses_count diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index f67ebb443..cc416b671 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -71,6 +71,7 @@ class ActivityPub::ProcessAccountService < BaseService @account.note = @json['summary'] || '' @account.locked = @json['manuallyApprovesFollowers'] || false @account.fields = property_values || {} + @account.actor_type = @json['type'] end def set_fetchable_attributes! diff --git a/app/views/accounts/_header.html.haml b/app/views/accounts/_header.html.haml index 13dcaf616..4098d6778 100644 --- a/app/views/accounts/_header.html.haml +++ b/app/views/accounts/_header.html.haml @@ -10,7 +10,11 @@ %span>< @#{account.local_username_and_domain} = fa_icon('lock') if account.locked? - - if Setting.show_staff_badge + - if account.bot? + .roles + .account-role.bot + = t 'accounts.roles.bot' + - elsif Setting.show_staff_badge - if account.user_admin? .roles .account-role.admin diff --git a/app/views/settings/profiles/show.html.haml b/app/views/settings/profiles/show.html.haml index f28834d72..a84f8a7da 100644 --- a/app/views/settings/profiles/show.html.haml +++ b/app/views/settings/profiles/show.html.haml @@ -19,6 +19,9 @@ .fields-group = f.input :locked, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.locked') + .fields-group + = f.input :bot, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.bot') + .fields-group .input.with_block_label %label= t('simple_form.labels.defaults.fields') diff --git a/config/locales/en.yml b/config/locales/en.yml index e18354eac..5369311ac 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -49,6 +49,7 @@ en: reserved_username: The username is reserved roles: admin: Admin + bot: Bot moderator: Mod unfollow: Unfollow admin: diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 7ba32906d..495c6166b 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -4,6 +4,7 @@ en: hints: defaults: avatar: PNG, GIF or JPG. At most 2MB. Will be downscaled to 400x400px + bot: Warns people that the account does not represent a person digest: Only sent after a long period of inactivity and only if you have received any personal messages in your absence display_name: one: 1 character left @@ -29,6 +30,7 @@ en: value: Content defaults: avatar: Avatar + bot: This is a bot account confirm_new_password: Confirm new password confirm_password: Confirm password current_password: Current password diff --git a/db/migrate/20180506221944_add_actor_type_to_accounts.rb b/db/migrate/20180506221944_add_actor_type_to_accounts.rb new file mode 100644 index 000000000..7cfed640f --- /dev/null +++ b/db/migrate/20180506221944_add_actor_type_to_accounts.rb @@ -0,0 +1,5 @@ +class AddActorTypeToAccounts < ActiveRecord::Migration[5.2] + def change + add_column :accounts, :actor_type, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 566a320d8..f7fa24b83 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_04_16_210259) do +ActiveRecord::Schema.define(version: 2018_05_06_221944) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -75,6 +75,7 @@ ActiveRecord::Schema.define(version: 2018_04_16_210259) do t.bigint "moved_to_account_id" t.string "featured_collection_url" t.jsonb "fields" + t.string "actor_type" t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin t.index "lower((username)::text), lower((domain)::text)", name: "index_accounts_on_username_and_domain_lower" t.index ["uri"], name: "index_accounts_on_uri" -- cgit From b4fb766b23f4b50b51a366f55b451770ece3153a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 11 May 2018 11:49:12 +0200 Subject: Add REST API for Web Push Notifications subscriptions (#7445) - POST /api/v1/push/subscription - PUT /api/v1/push/subscription - DELETE /api/v1/push/subscription - New OAuth scope: "push" (required for the above methods) --- .../api/v1/push/subscriptions_controller.rb | 50 +++++++++++++ .../api/web/push_subscriptions_controller.rb | 11 +-- app/controllers/shares_controller.rb | 1 + app/models/user.rb | 2 +- app/models/web/push_subscription.rb | 47 +++++++----- app/serializers/initial_state_serializer.rb | 4 +- .../rest/web_push_subscription_serializer.rb | 13 ++++ app/serializers/web/notification_serializer.rb | 2 +- app/services/notify_service.rb | 21 +++--- app/workers/web/push_notification_worker.rb | 18 +++++ app/workers/web_push_notification_worker.rb | 25 ------- config/initializers/doorkeeper.rb | 2 +- config/locales/doorkeeper.en.yml | 1 + config/routes.rb | 4 ++ ...dd_access_token_id_to_web_push_subscriptions.rb | 6 ++ ...0180510230049_migrate_web_push_subscriptions.rb | 13 ++++ db/schema.rb | 8 ++- .../api/v1/push/subscriptions_controller_spec.rb | 83 ++++++++++++++++++++++ .../api/web/push_subscriptions_controller_spec.rb | 16 ++--- spec/models/web/push_subscription_spec.rb | 12 ---- 20 files changed, 258 insertions(+), 81 deletions(-) create mode 100644 app/controllers/api/v1/push/subscriptions_controller.rb create mode 100644 app/serializers/rest/web_push_subscription_serializer.rb create mode 100644 app/workers/web/push_notification_worker.rb delete mode 100644 app/workers/web_push_notification_worker.rb create mode 100644 db/migrate/20180510214435_add_access_token_id_to_web_push_subscriptions.rb create mode 100644 db/migrate/20180510230049_migrate_web_push_subscriptions.rb create mode 100644 spec/controllers/api/v1/push/subscriptions_controller_spec.rb (limited to 'app/controllers') diff --git a/app/controllers/api/v1/push/subscriptions_controller.rb b/app/controllers/api/v1/push/subscriptions_controller.rb new file mode 100644 index 000000000..5038cc03c --- /dev/null +++ b/app/controllers/api/v1/push/subscriptions_controller.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +class Api::V1::Push::SubscriptionsController < Api::BaseController + before_action -> { doorkeeper_authorize! :push } + before_action :require_user! + before_action :set_web_push_subscription + + def create + @web_subscription&.destroy! + + @web_subscription = ::Web::PushSubscription.create!( + endpoint: subscription_params[:endpoint], + key_p256dh: subscription_params[:keys][:p256dh], + key_auth: subscription_params[:keys][:auth], + data: data_params, + user_id: current_user.id, + access_token_id: doorkeeper_token.id + ) + + render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer + end + + def update + raise ActiveRecord::RecordNotFound if @web_subscription.nil? + + @web_subscription.update!(data: data_params) + + render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer + end + + def destroy + @web_subscription&.destroy! + render_empty + end + + private + + def set_web_push_subscription + @web_subscription = ::Web::PushSubscription.find_by(access_token_id: doorkeeper_token.id) + end + + def subscription_params + params.require(:subscription).permit(:endpoint, keys: [:auth, :p256dh]) + end + + def data_params + return {} if params[:data].blank? + params.require(:data).permit(alerts: [:follow, :favourite, :reblog, :mention]) + end +end diff --git a/app/controllers/api/web/push_subscriptions_controller.rb b/app/controllers/api/web/push_subscriptions_controller.rb index 249e7c186..fe8e42580 100644 --- a/app/controllers/api/web/push_subscriptions_controller.rb +++ b/app/controllers/api/web/push_subscriptions_controller.rb @@ -31,22 +31,23 @@ class Api::Web::PushSubscriptionsController < Api::Web::BaseController endpoint: subscription_params[:endpoint], key_p256dh: subscription_params[:keys][:p256dh], key_auth: subscription_params[:keys][:auth], - data: data + data: data, + user_id: active_session.user_id, + access_token_id: active_session.access_token_id ) active_session.update!(web_push_subscription: web_subscription) - render json: web_subscription.as_payload + render json: web_subscription, serializer: REST::WebPushSubscriptionSerializer end def update params.require([:id]) web_subscription = ::Web::PushSubscription.find(params[:id]) - web_subscription.update!(data: data_params) - render json: web_subscription.as_payload + render json: web_subscription, serializer: REST::WebPushSubscriptionSerializer end private @@ -56,6 +57,6 @@ class Api::Web::PushSubscriptionsController < Api::Web::BaseController end def data_params - @data_params ||= params.require(:data).permit(:alerts) + @data_params ||= params.require(:data).permit(alerts: [:follow, :favourite, :reblog, :mention]) end end diff --git a/app/controllers/shares_controller.rb b/app/controllers/shares_controller.rb index 3ec831a72..9ef1e0749 100644 --- a/app/controllers/shares_controller.rb +++ b/app/controllers/shares_controller.rb @@ -15,6 +15,7 @@ class SharesController < ApplicationController def initial_state_params text = [params[:title], params[:text], params[:url]].compact.join(' ') + { settings: Web::Setting.find_by(user: current_user)&.data || {}, push_subscription: current_account.user.web_push_subscription(current_session), diff --git a/app/models/user.rb b/app/models/user.rb index f5f542f07..21c217e77 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -245,7 +245,7 @@ class User < ApplicationRecord end def web_push_subscription(session) - session.web_push_subscription.nil? ? nil : session.web_push_subscription.as_payload + session.web_push_subscription.nil? ? nil : session.web_push_subscription end def invite_code=(code) diff --git a/app/models/web/push_subscription.rb b/app/models/web/push_subscription.rb index 1736106f7..df549c6d3 100644 --- a/app/models/web/push_subscription.rb +++ b/app/models/web/push_subscription.rb @@ -3,38 +3,51 @@ # # Table name: web_push_subscriptions # -# id :bigint(8) not null, primary key -# endpoint :string not null -# key_p256dh :string not null -# key_auth :string not null -# data :json -# created_at :datetime not null -# updated_at :datetime not null +# id :bigint(8) not null, primary key +# endpoint :string not null +# key_p256dh :string not null +# key_auth :string not null +# data :json +# created_at :datetime not null +# updated_at :datetime not null +# access_token_id :bigint(8) +# user_id :bigint(8) # -require 'webpush' - class Web::PushSubscription < ApplicationRecord + belongs_to :user, optional: true + belongs_to :access_token, class_name: 'Doorkeeper::AccessToken', optional: true + has_one :session_activation def push(notification) - I18n.with_locale(session_activation.user.locale || I18n.default_locale) do + I18n.with_locale(associated_user.locale || I18n.default_locale) do push_payload(message_from(notification), 48.hours.seconds) end end def pushable?(notification) - data&.key?('alerts') && data['alerts'][notification.type.to_s] + data&.key?('alerts') && ActiveModel::Type::Boolean.new.cast(data['alerts'][notification.type.to_s]) end - def as_payload - payload = { id: id, endpoint: endpoint } - payload[:alerts] = data['alerts'] if data&.key?('alerts') - payload + def associated_user + return @associated_user if defined?(@associated_user) + + @associated_user = if user_id.nil? + session_activation.user + else + user + end end - def access_token - find_or_create_access_token.token + def associated_access_token + return @associated_access_token if defined?(@associated_access_token) + + @associated_access_token = if access_token_id.nil? + find_or_create_access_token.token + else + access_token + end end private diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index 3b908e224..6c9fba2f5 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -2,7 +2,9 @@ class InitialStateSerializer < ActiveModel::Serializer attributes :meta, :compose, :accounts, - :media_attachments, :settings, :push_subscription + :media_attachments, :settings + + has_one :push_subscription, serializer: REST::WebPushSubscriptionSerializer def meta store = { diff --git a/app/serializers/rest/web_push_subscription_serializer.rb b/app/serializers/rest/web_push_subscription_serializer.rb new file mode 100644 index 000000000..7fd952a56 --- /dev/null +++ b/app/serializers/rest/web_push_subscription_serializer.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class REST::WebPushSubscriptionSerializer < ActiveModel::Serializer + attributes :id, :endpoint, :alerts, :server_key + + def alerts + object.data&.dig('alerts') || {} + end + + def server_key + Rails.configuration.x.vapid_public_key + end +end diff --git a/app/serializers/web/notification_serializer.rb b/app/serializers/web/notification_serializer.rb index e5524fe7a..31c703832 100644 --- a/app/serializers/web/notification_serializer.rb +++ b/app/serializers/web/notification_serializer.rb @@ -54,7 +54,7 @@ class Web::NotificationSerializer < ActiveModel::Serializer def access_token return if actions.empty? - current_push_subscription.access_token + current_push_subscription.associated_access_token end def message diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb index ba086449c..6490d2735 100644 --- a/app/services/notify_service.rb +++ b/app/services/notify_service.rb @@ -9,6 +9,7 @@ class NotifyService < BaseService return if recipient.user.nil? || blocked? create_notification + push_notification if @notification.browserable? send_email if email_enabled? rescue ActiveRecord::RecordInvalid return @@ -101,25 +102,27 @@ class NotifyService < BaseService def create_notification @notification.save! - return unless @notification.browserable? + end + + def push_notification + return if @notification.activity.nil? + Redis.current.publish("timeline:#{@recipient.id}", Oj.dump(event: :notification, payload: InlineRenderer.render(@notification, @recipient, :notification))) send_push_notifications end def send_push_notifications - # HACK: Can be caused by quickly unfavouriting a status, since creating - # a favourite and creating a notification are not wrapped in a transaction. - return if @notification.activity.nil? - - sessions_with_subscriptions = @recipient.user.session_activations.where.not(web_push_subscription: nil) - sessions_with_subscriptions_ids = sessions_with_subscriptions.select { |session| session.web_push_subscription.pushable? @notification }.map(&:id) + subscriptions_ids = ::Web::PushSubscription.where(user_id: @recipient.user.id) + .select { |subscription| subscription.pushable?(@notification) } + .map(&:id) - WebPushNotificationWorker.push_bulk(sessions_with_subscriptions_ids) do |session_activation_id| - [session_activation_id, @notification.id] + ::Web::PushNotificationWorker.push_bulk(subscriptions_ids) do |subscription_id| + [subscription_id, @notification.id] end end def send_email + return if @notification.activity.nil? NotificationMailer.public_send(@notification.type, @recipient, @notification).deliver_later end diff --git a/app/workers/web/push_notification_worker.rb b/app/workers/web/push_notification_worker.rb new file mode 100644 index 000000000..4a40e5c8b --- /dev/null +++ b/app/workers/web/push_notification_worker.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class Web::PushNotificationWorker + include Sidekiq::Worker + + sidekiq_options backtrace: true + + def perform(subscription_id, notification_id) + subscription = ::Web::PushSubscription.find(subscription_id) + notification = Notification.find(notification_id) + + subscription.push(notification) unless notification.activity.nil? + rescue Webpush::InvalidSubscription, Webpush::ExpiredSubscription + subscription.destroy! + rescue ActiveRecord::RecordNotFound + true + end +end diff --git a/app/workers/web_push_notification_worker.rb b/app/workers/web_push_notification_worker.rb deleted file mode 100644 index eacea04c3..000000000 --- a/app/workers/web_push_notification_worker.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class WebPushNotificationWorker - include Sidekiq::Worker - - sidekiq_options backtrace: true - - def perform(session_activation_id, notification_id) - session_activation = SessionActivation.find(session_activation_id) - notification = Notification.find(notification_id) - - return if session_activation.web_push_subscription.nil? || notification.activity.nil? - - session_activation.web_push_subscription.push(notification) - rescue Webpush::InvalidSubscription, Webpush::ExpiredSubscription - # Subscription expiration is not currently implemented in any browser - - session_activation.web_push_subscription.destroy! - session_activation.update!(web_push_subscription: nil) - - true - rescue ActiveRecord::RecordNotFound - true - end -end diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb index 074f8c410..469553803 100644 --- a/config/initializers/doorkeeper.rb +++ b/config/initializers/doorkeeper.rb @@ -55,7 +55,7 @@ Doorkeeper.configure do # For more information go to # https://github.com/doorkeeper-gem/doorkeeper/wiki/Using-Scopes default_scopes :read - optional_scopes :write, :follow + optional_scopes :write, :follow, :push # Change the way client credentials are retrieved from the request object. # By default it retrieves first from the `HTTP_AUTHORIZATION` header, then diff --git a/config/locales/doorkeeper.en.yml b/config/locales/doorkeeper.en.yml index 33d544bed..eca1fc675 100644 --- a/config/locales/doorkeeper.en.yml +++ b/config/locales/doorkeeper.en.yml @@ -115,5 +115,6 @@ en: title: OAuth authorization required scopes: follow: follow, block, unblock and unfollow accounts + push: receive push notifications for your account read: read your account's data write: post on your behalf diff --git a/config/routes.rb b/config/routes.rb index 4c920cf74..b7bd1a7ed 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -306,6 +306,10 @@ Rails.application.routes.draw do resources :lists, only: [:index, :create, :show, :update, :destroy] do resource :accounts, only: [:show, :create, :destroy], controller: 'lists/accounts' end + + namespace :push do + resource :subscription, only: [:create, :update, :destroy] + end end namespace :web do diff --git a/db/migrate/20180510214435_add_access_token_id_to_web_push_subscriptions.rb b/db/migrate/20180510214435_add_access_token_id_to_web_push_subscriptions.rb new file mode 100644 index 000000000..94ef8e0f5 --- /dev/null +++ b/db/migrate/20180510214435_add_access_token_id_to_web_push_subscriptions.rb @@ -0,0 +1,6 @@ +class AddAccessTokenIdToWebPushSubscriptions < ActiveRecord::Migration[5.2] + def change + add_reference :web_push_subscriptions, :access_token, null: true, default: nil, foreign_key: { on_delete: :cascade, to_table: :oauth_access_tokens }, index: false + add_reference :web_push_subscriptions, :user, null: true, default: nil, foreign_key: { on_delete: :cascade }, index: false + end +end diff --git a/db/migrate/20180510230049_migrate_web_push_subscriptions.rb b/db/migrate/20180510230049_migrate_web_push_subscriptions.rb new file mode 100644 index 000000000..6de1bed79 --- /dev/null +++ b/db/migrate/20180510230049_migrate_web_push_subscriptions.rb @@ -0,0 +1,13 @@ +class MigrateWebPushSubscriptions < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def up + add_index :web_push_subscriptions, :user_id, algorithm: :concurrently + add_index :web_push_subscriptions, :access_token_id, algorithm: :concurrently + end + + def down + remove_index :web_push_subscriptions, :user_id + remove_index :web_push_subscriptions, :access_token_id + end +end diff --git a/db/schema.rb b/db/schema.rb index f7fa24b83..221c08d98 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_05_06_221944) do +ActiveRecord::Schema.define(version: 2018_05_10_230049) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -539,6 +539,10 @@ ActiveRecord::Schema.define(version: 2018_05_06_221944) do t.json "data" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.bigint "access_token_id" + t.bigint "user_id" + t.index ["access_token_id"], name: "index_web_push_subscriptions_on_access_token_id" + t.index ["user_id"], name: "index_web_push_subscriptions_on_user_id" end create_table "web_settings", force: :cascade do |t| @@ -605,5 +609,7 @@ ActiveRecord::Schema.define(version: 2018_05_06_221944) do add_foreign_key "subscriptions", "accounts", name: "fk_9847d1cbb5", on_delete: :cascade add_foreign_key "users", "accounts", name: "fk_50500f500d", on_delete: :cascade add_foreign_key "users", "invites", on_delete: :nullify + add_foreign_key "web_push_subscriptions", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade + add_foreign_key "web_push_subscriptions", "users", on_delete: :cascade add_foreign_key "web_settings", "users", name: "fk_11910667b2", on_delete: :cascade end diff --git a/spec/controllers/api/v1/push/subscriptions_controller_spec.rb b/spec/controllers/api/v1/push/subscriptions_controller_spec.rb new file mode 100644 index 000000000..01146294f --- /dev/null +++ b/spec/controllers/api/v1/push/subscriptions_controller_spec.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Push::SubscriptionsController do + render_views + + let(:user) { Fabricate(:user) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'push') } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + let(:create_payload) do + { + subscription: { + endpoint: 'https://fcm.googleapis.com/fcm/send/fiuH06a27qE:APA91bHnSiGcLwdaxdyqVXNDR9w1NlztsHb6lyt5WDKOC_Z_Q8BlFxQoR8tWFSXUIDdkyw0EdvxTu63iqamSaqVSevW5LfoFwojws8XYDXv_NRRLH6vo2CdgiN4jgHv5VLt2A8ah6lUX', + keys: { + p256dh: 'BEm_a0bdPDhf0SOsrnB2-ategf1hHoCnpXgQsFj5JCkcoMrMt2WHoPfEYOYPzOIs9mZE8ZUaD7VA5vouy0kEkr8=', + auth: 'eH_C8rq2raXqlcBVDa1gLg==', + }, + } + }.with_indifferent_access + end + + let(:alerts_payload) do + { + data: { + alerts: { + follow: true, + favourite: false, + reblog: true, + mention: false, + } + } + }.with_indifferent_access + end + + describe 'POST #create' do + it 'saves push subscriptions' do + post :create, params: create_payload + + push_subscription = Web::PushSubscription.find_by(endpoint: create_payload[:subscription][:endpoint]) + + expect(push_subscription.endpoint).to eq(create_payload[:subscription][:endpoint]) + expect(push_subscription.key_p256dh).to eq(create_payload[:subscription][:keys][:p256dh]) + expect(push_subscription.key_auth).to eq(create_payload[:subscription][:keys][:auth]) + expect(push_subscription.user_id).to eq user.id + expect(push_subscription.access_token_id).to eq token.id + end + + it 'replaces old subscription on repeat calls' do + post :create, params: create_payload + post :create, params: create_payload + + expect(Web::PushSubscription.where(endpoint: create_payload[:subscription][:endpoint]).count).to eq 1 + end + end + + describe 'PUT #update' do + it 'changes alert settings' do + post :create, params: create_payload + put :update, params: alerts_payload + + push_subscription = Web::PushSubscription.find_by(endpoint: create_payload[:subscription][:endpoint]) + + expect(push_subscription.data.dig('alerts', 'follow')).to eq(alerts_payload[:data][:alerts][:follow].to_s) + expect(push_subscription.data.dig('alerts', 'favourite')).to eq(alerts_payload[:data][:alerts][:favourite].to_s) + expect(push_subscription.data.dig('alerts', 'reblog')).to eq(alerts_payload[:data][:alerts][:reblog].to_s) + expect(push_subscription.data.dig('alerts', 'mention')).to eq(alerts_payload[:data][:alerts][:mention].to_s) + end + end + + describe 'DELETE #destroy' do + it 'removes the subscription' do + post :create, params: create_payload + delete :destroy + + expect(Web::PushSubscription.find_by(endpoint: create_payload[:subscription][:endpoint])).to be_nil + end + end +end diff --git a/spec/controllers/api/web/push_subscriptions_controller_spec.rb b/spec/controllers/api/web/push_subscriptions_controller_spec.rb index bbf94c5c6..381cdeab9 100644 --- a/spec/controllers/api/web/push_subscriptions_controller_spec.rb +++ b/spec/controllers/api/web/push_subscriptions_controller_spec.rb @@ -59,10 +59,10 @@ describe Api::Web::PushSubscriptionsController do push_subscription = Web::PushSubscription.find_by(endpoint: create_payload[:subscription][:endpoint]) - expect(push_subscription.data['follow']).to eq(alerts_payload[:data][:follow]) - expect(push_subscription.data['favourite']).to eq(alerts_payload[:data][:favourite]) - expect(push_subscription.data['reblog']).to eq(alerts_payload[:data][:reblog]) - expect(push_subscription.data['mention']).to eq(alerts_payload[:data][:mention]) + expect(push_subscription.data['alerts']['follow']).to eq(alerts_payload[:data][:alerts][:follow].to_s) + expect(push_subscription.data['alerts']['favourite']).to eq(alerts_payload[:data][:alerts][:favourite].to_s) + expect(push_subscription.data['alerts']['reblog']).to eq(alerts_payload[:data][:alerts][:reblog].to_s) + expect(push_subscription.data['alerts']['mention']).to eq(alerts_payload[:data][:alerts][:mention].to_s) end end end @@ -81,10 +81,10 @@ describe Api::Web::PushSubscriptionsController do push_subscription = Web::PushSubscription.find_by(endpoint: create_payload[:subscription][:endpoint]) - expect(push_subscription.data['follow']).to eq(alerts_payload[:data][:follow]) - expect(push_subscription.data['favourite']).to eq(alerts_payload[:data][:favourite]) - expect(push_subscription.data['reblog']).to eq(alerts_payload[:data][:reblog]) - expect(push_subscription.data['mention']).to eq(alerts_payload[:data][:mention]) + expect(push_subscription.data['alerts']['follow']).to eq(alerts_payload[:data][:alerts][:follow].to_s) + expect(push_subscription.data['alerts']['favourite']).to eq(alerts_payload[:data][:alerts][:favourite].to_s) + expect(push_subscription.data['alerts']['reblog']).to eq(alerts_payload[:data][:alerts][:reblog].to_s) + expect(push_subscription.data['alerts']['mention']).to eq(alerts_payload[:data][:alerts][:mention].to_s) end end end diff --git a/spec/models/web/push_subscription_spec.rb b/spec/models/web/push_subscription_spec.rb index 574da55ac..c6665611c 100644 --- a/spec/models/web/push_subscription_spec.rb +++ b/spec/models/web/push_subscription_spec.rb @@ -2,20 +2,8 @@ require 'rails_helper' RSpec.describe Web::PushSubscription, type: :model do let(:alerts) { { mention: true, reblog: false, follow: true, follow_request: false, favourite: true } } - let(:payload_no_alerts) { Web::PushSubscription.new(id: 1, endpoint: 'a', key_p256dh: 'c', key_auth: 'd').as_payload } - let(:payload_alerts) { Web::PushSubscription.new(id: 1, endpoint: 'a', key_p256dh: 'c', key_auth: 'd', data: { alerts: alerts }).as_payload } let(:push_subscription) { Web::PushSubscription.new(data: { alerts: alerts }) } - describe '#as_payload' do - it 'only returns id and endpoint' do - expect(payload_no_alerts.keys).to eq [:id, :endpoint] - end - - it 'returns alerts if set' do - expect(payload_alerts.keys).to eq [:id, :endpoint, :alerts] - end - end - describe '#pushable?' do it 'obeys alert settings' do expect(push_subscription.send(:pushable?, Notification.new(activity_type: 'Mention'))).to eq true -- cgit From 50491e0d92acea90e7a83d2ab0e9a1b271daa8a8 Mon Sep 17 00:00:00 2001 From: Shuhei Kitagawa Date: Fri, 11 May 2018 20:14:33 +0900 Subject: Add tests for invites controller (#7441) * Add tests for invites controller * Small refactoring and fix for invites controller --- app/controllers/invites_controller.rb | 12 ++++-- spec/controllers/invites_controller_spec.rb | 67 +++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 spec/controllers/invites_controller_spec.rb (limited to 'app/controllers') diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 38d6c8d73..8e87c63cf 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -8,9 +8,9 @@ class InvitesController < ApplicationController before_action :authenticate_user! def index - authorize :invite, :create? + authorize :invite, :index? - @invites = Invite.where(user: current_user) + @invites = invites @invite = Invite.new(expires_in: 1.day.to_i) end @@ -23,13 +23,13 @@ class InvitesController < ApplicationController if @invite.save redirect_to invites_path else - @invites = Invite.where(user: current_user) + @invites = invites render :index end end def destroy - @invite = Invite.where(user: current_user).find(params[:id]) + @invite = invites.find(params[:id]) authorize @invite, :destroy? @invite.expire! redirect_to invites_path @@ -37,6 +37,10 @@ class InvitesController < ApplicationController private + def invites + Invite.where(user: current_user) + end + def resource_params params.require(:invite).permit(:max_uses, :expires_in) end diff --git a/spec/controllers/invites_controller_spec.rb b/spec/controllers/invites_controller_spec.rb new file mode 100644 index 000000000..c5c6cb651 --- /dev/null +++ b/spec/controllers/invites_controller_spec.rb @@ -0,0 +1,67 @@ +require 'rails_helper' + +describe InvitesController do + render_views + + before do + sign_in user + end + + describe 'GET #index' do + subject { get :index } + + let!(:invite) { Fabricate(:invite, user: user) } + + context 'when user is a staff' do + let(:user) { Fabricate(:user, moderator: true, admin: false) } + + it 'renders index page' do + expect(subject).to render_template :index + expect(assigns(:invites)).to include invite + expect(assigns(:invites).count).to eq 1 + end + end + + context 'when user is not a staff' do + let(:user) { Fabricate(:user, moderator: false, admin: false) } + + it 'returns 403' do + expect(subject).to have_http_status 403 + end + end + end + + describe 'POST #create' do + subject { post :create, params: { invite: { max_uses: '10', expires_in: 1800 } } } + + context 'when user is an admin' do + let(:user) { Fabricate(:user, moderator: false, admin: true) } + + it 'succeeds to create a invite' do + expect{ subject }.to change { Invite.count }.by(1) + expect(subject).to redirect_to invites_path + expect(Invite.last).to have_attributes(user_id: user.id, max_uses: 10) + end + end + + context 'when user is not an admin' do + let(:user) { Fabricate(:user, moderator: true, admin: false) } + + it 'returns 403' do + expect(subject).to have_http_status 403 + end + end + end + + describe 'DELETE #create' do + subject { delete :destroy, params: { id: invite.id } } + + let!(:invite) { Fabricate(:invite, user: user, expires_at: nil) } + let(:user) { Fabricate(:user, moderator: false, admin: true) } + + it 'expires invite' do + expect(subject).to redirect_to invites_path + expect(invite.reload).to be_expired + end + end +end -- cgit From 352bae8c3ef2aca41de4aacb85d5e036a1d2bace Mon Sep 17 00:00:00 2001 From: ThibG Date: Fri, 11 May 2018 13:20:58 +0200 Subject: Update session activation time (fixes #5605) (#7408) --- app/controllers/application_controller.rb | 1 + .../concerns/session_tracking_concern.rb | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 app/controllers/concerns/session_tracking_concern.rb (limited to 'app/controllers') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 588526447..5b22f17c6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,6 +9,7 @@ class ApplicationController < ActionController::Base include Localized include UserTrackingConcern + include SessionTrackingConcern helper_method :current_account helper_method :current_session diff --git a/app/controllers/concerns/session_tracking_concern.rb b/app/controllers/concerns/session_tracking_concern.rb new file mode 100644 index 000000000..45361b019 --- /dev/null +++ b/app/controllers/concerns/session_tracking_concern.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module SessionTrackingConcern + extend ActiveSupport::Concern + + UPDATE_SIGN_IN_HOURS = 24 + + included do + before_action :set_session_activity + end + + private + + def set_session_activity + return unless session_needs_update? + current_session.touch + end + + def session_needs_update? + !current_session.nil? && current_session.updated_at < UPDATE_SIGN_IN_HOURS.hours.ago + end +end -- cgit From 97e43ec5f08aeafe0cb34a2e71e857f22c547f7a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 13 May 2018 21:07:31 +0200 Subject: Add GET /api/v1/push/subscription REST API (#7471) * Add Api::V1::Push::SubscriptionsController#show * Add to routes --- app/controllers/api/v1/push/subscriptions_controller.rb | 4 ++++ config/routes.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/api/v1/push/subscriptions_controller.rb b/app/controllers/api/v1/push/subscriptions_controller.rb index 5038cc03c..e99f20ca0 100644 --- a/app/controllers/api/v1/push/subscriptions_controller.rb +++ b/app/controllers/api/v1/push/subscriptions_controller.rb @@ -20,6 +20,10 @@ class Api::V1::Push::SubscriptionsController < Api::BaseController render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer end + def show + render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer + end + def update raise ActiveRecord::RecordNotFound if @web_subscription.nil? diff --git a/config/routes.rb b/config/routes.rb index b7bd1a7ed..bd9d09226 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -308,7 +308,7 @@ Rails.application.routes.draw do end namespace :push do - resource :subscription, only: [:create, :update, :destroy] + resource :subscription, only: [:create, :show, :update, :destroy] end end -- cgit From 416f6445050b662fb15045185332e1dc3bec3694 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 13 May 2018 21:45:18 +0200 Subject: Fix 404 for GET /api/v1/push/subscription (#7472) My bad... --- app/controllers/api/v1/push/subscriptions_controller.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/api/v1/push/subscriptions_controller.rb b/app/controllers/api/v1/push/subscriptions_controller.rb index e99f20ca0..1a19bd0ef 100644 --- a/app/controllers/api/v1/push/subscriptions_controller.rb +++ b/app/controllers/api/v1/push/subscriptions_controller.rb @@ -21,6 +21,8 @@ class Api::V1::Push::SubscriptionsController < Api::BaseController end def show + raise ActiveRecord::RecordNotFound if @web_subscription.nil? + render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer end -- cgit From 55fd55714a374eaedfab457f7e7254f816911ff1 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Wed, 16 May 2018 19:29:45 +0900 Subject: Raise Mastodon::RaceConditionError if Redis lock failed (#7511) An explicit error allows user agents to know the error and Sidekiq to retry. --- app/controllers/media_proxy_controller.rb | 2 ++ app/lib/activitypub/activity/create.rb | 2 ++ app/lib/ostatus/activity/creation.rb | 2 ++ app/services/activitypub/process_account_service.rb | 2 ++ app/services/fetch_link_card_service.rb | 2 ++ app/services/resolve_account_service.rb | 2 ++ 6 files changed, 12 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/media_proxy_controller.rb b/app/controllers/media_proxy_controller.rb index 155670837..d820b257e 100644 --- a/app/controllers/media_proxy_controller.rb +++ b/app/controllers/media_proxy_controller.rb @@ -8,6 +8,8 @@ class MediaProxyController < ApplicationController if lock.acquired? @media_attachment = MediaAttachment.remote.find(params[:id]) redownload! if @media_attachment.needs_redownload? && !reject_media? + else + raise Mastodon::RaceConditionError end end diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 8d17a4ebe..ab1d63cd4 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -11,6 +11,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity if lock.acquired? @status = find_existing_status process_status if @status.nil? + else + raise Mastodon::RaceConditionError end end diff --git a/app/lib/ostatus/activity/creation.rb b/app/lib/ostatus/activity/creation.rb index dbccc8330..d3a303a0c 100644 --- a/app/lib/ostatus/activity/creation.rb +++ b/app/lib/ostatus/activity/creation.rb @@ -15,6 +15,8 @@ class OStatus::Activity::Creation < OStatus::Activity::Base @status = find_status(id) return [@status, false] unless @status.nil? @status = process_status + else + raise Mastodon::RaceConditionError end end diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 783bbd8e5..453253db4 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -23,6 +23,8 @@ class ActivityPub::ProcessAccountService < BaseService create_account if @account.nil? update_account process_tags + else + raise Mastodon::RaceConditionError end end diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb index f9b1b2f0c..86d0f9971 100644 --- a/app/services/fetch_link_card_service.rb +++ b/app/services/fetch_link_card_service.rb @@ -23,6 +23,8 @@ class FetchLinkCardService < BaseService if lock.acquired? @card = PreviewCard.find_by(url: @url) process_url if @card.nil? || @card.updated_at <= 2.weeks.ago + else + raise Mastodon::RaceConditionError end end diff --git a/app/services/resolve_account_service.rb b/app/services/resolve_account_service.rb index de8d1151d..4323e7f06 100644 --- a/app/services/resolve_account_service.rb +++ b/app/services/resolve_account_service.rb @@ -49,6 +49,8 @@ class ResolveAccountService < BaseService else handle_ostatus end + else + raise Mastodon::RaceConditionError end end -- cgit From 77cd6b5096369cf8986a6bb23e5375f3cba7ff8a Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Wed, 16 May 2018 19:30:14 +0900 Subject: Do not use permitted_for scope when querying pinned statuses (#7510) permitted_for scope is slow when combined with pinned status scope. Fortunately permitted_for scope can safely be removed because a pinned status is always public. --- app/controllers/api/v1/accounts/statuses_controller.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/api/v1/accounts/statuses_controller.rb b/app/controllers/api/v1/accounts/statuses_controller.rb index cbcc7ef04..c40155cb5 100644 --- a/app/controllers/api/v1/accounts/statuses_controller.rb +++ b/app/controllers/api/v1/accounts/statuses_controller.rb @@ -27,19 +27,17 @@ class Api::V1::Accounts::StatusesController < Api::BaseController end def account_statuses - default_statuses.tap do |statuses| - statuses.merge!(only_media_scope) if truthy_param?(:only_media) - statuses.merge!(pinned_scope) if truthy_param?(:pinned) - statuses.merge!(no_replies_scope) if truthy_param?(:exclude_replies) - end - end - - def default_statuses - permitted_account_statuses.paginate_by_max_id( + statuses = truthy_param?(:pinned) ? pinned_scope : permitted_account_statuses + statuses = statuses.paginate_by_max_id( limit_param(DEFAULT_STATUSES_LIMIT), params[:max_id], params[:since_id] ) + + statuses.merge!(only_media_scope) if truthy_param?(:only_media) + statuses.merge!(no_replies_scope) if truthy_param?(:exclude_replies) + + statuses end def permitted_account_statuses -- cgit From dfb6907e08350ca487e2978a85013f4525526bdf Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 17 May 2018 04:03:28 +0200 Subject: HTTP signatures spec no longer requires algorithms field (#7525) Fix #7520 --- app/controllers/concerns/signature_verification.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/concerns/signature_verification.rb b/app/controllers/concerns/signature_verification.rb index f289228d3..41aa1c8a6 100644 --- a/app/controllers/concerns/signature_verification.rb +++ b/app/controllers/concerns/signature_verification.rb @@ -107,9 +107,7 @@ module SignatureVerification def incompatible_signature?(signature_params) signature_params['keyId'].blank? || - signature_params['signature'].blank? || - signature_params['algorithm'].blank? || - signature_params['algorithm'] != 'rsa-sha256' + signature_params['signature'].blank? end def account_from_key_id(key_id) -- cgit From 7293b9fc6190acd6d2a481c158c718a7a8299c73 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 17 May 2018 13:00:56 +0200 Subject: Ensure unfilled fields are shown when errors are shown (#7523) Fix #7486 --- app/controllers/settings/profiles_controller.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/controllers') diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb index 1b01fc75f..fe265c81d 100644 --- a/app/controllers/settings/profiles_controller.rb +++ b/app/controllers/settings/profiles_controller.rb @@ -20,6 +20,7 @@ class Settings::ProfilesController < ApplicationController ActivityPub::UpdateDistributionWorker.perform_async(@account.id) redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg') else + @account.build_fields render :show end end -- cgit From 1e02dc871533de78174b48a6a527f11b0f2bc7ec Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 18 May 2018 02:26:51 +0200 Subject: Add preference to hide following/followers lists (#7532) * Add preference to hide following/followers lists - Public pages - ActivityPub collections (does not return pages but does give total) - REST API (unless it's your own) (does not federate) Fix #6901 * Add preference * Add delegation * Fix issue * Fix issue --- .../api/v1/accounts/follower_accounts_controller.rb | 2 ++ .../api/v1/accounts/following_accounts_controller.rb | 2 ++ app/controllers/follower_accounts_controller.rb | 4 ++++ app/controllers/following_accounts_controller.rb | 4 ++++ app/controllers/settings/preferences_controller.rb | 1 + app/javascript/styles/mastodon/accounts.scss | 13 +++++++++++-- app/javascript/styles/mastodon/footer.scss | 2 +- app/lib/user_settings_decorator.rb | 5 +++++ app/models/account.rb | 1 + app/models/user.rb | 6 +++++- app/views/accounts/_follow_grid.html.haml | 3 ++- app/views/accounts/_follow_grid_hidden.html.haml | 3 +++ app/views/follower_accounts/index.html.haml | 5 ++++- app/views/following_accounts/index.html.haml | 5 ++++- app/views/layouts/public.html.haml | 4 ++-- app/views/settings/preferences/show.html.haml | 3 +++ config/locales/en.yml | 1 + config/locales/simple_form.en.yml | 2 ++ config/settings.yml | 1 + 19 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 app/views/accounts/_follow_grid_hidden.html.haml (limited to 'app/controllers') diff --git a/app/controllers/api/v1/accounts/follower_accounts_controller.rb b/app/controllers/api/v1/accounts/follower_accounts_controller.rb index c4f600c54..4578cf6ca 100644 --- a/app/controllers/api/v1/accounts/follower_accounts_controller.rb +++ b/app/controllers/api/v1/accounts/follower_accounts_controller.rb @@ -19,6 +19,8 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController end def load_accounts + return [] if @account.user_hides_network? && current_account.id != @account.id + default_accounts.merge(paginated_follows).to_a end diff --git a/app/controllers/api/v1/accounts/following_accounts_controller.rb b/app/controllers/api/v1/accounts/following_accounts_controller.rb index 90b1f7fc5..ce2bbda85 100644 --- a/app/controllers/api/v1/accounts/following_accounts_controller.rb +++ b/app/controllers/api/v1/accounts/following_accounts_controller.rb @@ -19,6 +19,8 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController end def load_accounts + return [] if @account.user_hides_network? && current_account.id != @account.id + default_accounts.merge(paginated_follows).to_a end diff --git a/app/controllers/follower_accounts_controller.rb b/app/controllers/follower_accounts_controller.rb index ac0d4c54e..99cb3676f 100644 --- a/app/controllers/follower_accounts_controller.rb +++ b/app/controllers/follower_accounts_controller.rb @@ -6,11 +6,15 @@ class FollowerAccountsController < ApplicationController def index respond_to do |format| format.html do + next if @account.user_hides_network? + follows @relationships = AccountRelationshipsPresenter.new(follows.map(&:account_id), current_user.account_id) if user_signed_in? end format.json do + raise Mastodon::NotPermittedError if params[:page].present? && @account.user_hides_network? + render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, diff --git a/app/controllers/following_accounts_controller.rb b/app/controllers/following_accounts_controller.rb index 974d95c8e..03c4b1046 100644 --- a/app/controllers/following_accounts_controller.rb +++ b/app/controllers/following_accounts_controller.rb @@ -6,11 +6,15 @@ class FollowingAccountsController < ApplicationController def index respond_to do |format| format.html do + next if @account.user_hides_network? + follows @relationships = AccountRelationshipsPresenter.new(follows.map(&:target_account_id), current_user.account_id) if user_signed_in? end format.json do + raise Mastodon::NotPermittedError if params[:page].present? && @account.user_hides_network? + render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index 839763138..57793d776 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -44,6 +44,7 @@ class Settings::PreferencesController < ApplicationController :setting_system_font_ui, :setting_noindex, :setting_theme, + :setting_hide_network, notification_emails: %i(follow follow_request reblog favourite mention digest), interactions: %i(must_be_follower must_be_following) ) diff --git a/app/javascript/styles/mastodon/accounts.scss b/app/javascript/styles/mastodon/accounts.scss index b063ca52d..93aa134cf 100644 --- a/app/javascript/styles/mastodon/accounts.scss +++ b/app/javascript/styles/mastodon/accounts.scss @@ -322,6 +322,15 @@ z-index: 2; position: relative; + &.empty img { + position: absolute; + opacity: 0.2; + height: 200px; + left: 0; + bottom: 0; + pointer-events: none; + } + @media screen and (max-width: 740px) { border-radius: 0; box-shadow: none; @@ -438,8 +447,8 @@ font-size: 14px; font-weight: 500; text-align: center; - padding: 60px 0; - padding-top: 55px; + padding: 130px 0; + padding-top: 125px; margin: 0 auto; cursor: default; } diff --git a/app/javascript/styles/mastodon/footer.scss b/app/javascript/styles/mastodon/footer.scss index ba2a06954..dd3c1b688 100644 --- a/app/javascript/styles/mastodon/footer.scss +++ b/app/javascript/styles/mastodon/footer.scss @@ -4,7 +4,7 @@ font-size: 12px; color: $darker-text-color; - .domain { + .footer__domain { font-weight: 500; a { diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index 9260a81bc..a82f8974b 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -28,6 +28,7 @@ class UserSettingsDecorator user.settings['system_font_ui'] = system_font_ui_preference if change?('setting_system_font_ui') user.settings['noindex'] = noindex_preference if change?('setting_noindex') user.settings['theme'] = theme_preference if change?('setting_theme') + user.settings['hide_network'] = hide_network_preference if change?('setting_hide_network') end def merged_notification_emails @@ -78,6 +79,10 @@ class UserSettingsDecorator boolean_cast_setting 'setting_noindex' end + def hide_network_preference + boolean_cast_setting 'setting_hide_network' + end + def theme_preference settings['setting_theme'] end diff --git a/app/models/account.rb b/app/models/account.rb index 2b3ef5cdc..72e850aa7 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -136,6 +136,7 @@ class Account < ApplicationRecord :moderator?, :staff?, :locale, + :hides_network?, to: :user, prefix: true, allow_nil: true diff --git a/app/models/user.rb b/app/models/user.rb index 21c217e77..cfbae58ed 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -86,7 +86,7 @@ class User < ApplicationRecord has_many :session_activations, dependent: :destroy delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :delete_modal, - :reduce_motion, :system_font_ui, :noindex, :theme, :display_sensitive_media, + :reduce_motion, :system_font_ui, :noindex, :theme, :display_sensitive_media, :hide_network, to: :settings, prefix: :setting, allow_nil: false attr_accessor :invite_code @@ -219,6 +219,10 @@ class User < ApplicationRecord settings.notification_emails['digest'] end + def hides_network? + @hides_network ||= settings.hide_network + end + def token_for_app(a) return nil if a.nil? || a.owner != self Doorkeeper::AccessToken diff --git a/app/views/accounts/_follow_grid.html.haml b/app/views/accounts/_follow_grid.html.haml index a6d0ee817..fdcef84be 100644 --- a/app/views/accounts/_follow_grid.html.haml +++ b/app/views/accounts/_follow_grid.html.haml @@ -1,5 +1,6 @@ -.accounts-grid +.accounts-grid{ class: accounts.empty? ? 'empty' : '' } - if accounts.empty? + = image_tag asset_pack_path('elephant_ui_greeting.svg'), alt: '', role: 'presentational' = render partial: 'accounts/nothing_here' - else = render partial: 'accounts/grid_card', collection: accounts, as: :account, cached: !user_signed_in? diff --git a/app/views/accounts/_follow_grid_hidden.html.haml b/app/views/accounts/_follow_grid_hidden.html.haml new file mode 100644 index 000000000..e970350e6 --- /dev/null +++ b/app/views/accounts/_follow_grid_hidden.html.haml @@ -0,0 +1,3 @@ +.accounts-grid.empty + = image_tag asset_pack_path('elephant_ui_greeting.svg'), alt: '', role: 'presentational' + %p.nothing-here= t('accounts.network_hidden') diff --git a/app/views/follower_accounts/index.html.haml b/app/views/follower_accounts/index.html.haml index a24e4ea20..65af81a5b 100644 --- a/app/views/follower_accounts/index.html.haml +++ b/app/views/follower_accounts/index.html.haml @@ -7,4 +7,7 @@ = render 'accounts/header', account: @account -= render 'accounts/follow_grid', follows: @follows, accounts: @follows.map(&:account) +- if @account.user_hides_network? + = render 'accounts/follow_grid_hidden' +- else + = render 'accounts/follow_grid', follows: @follows, accounts: @follows.map(&:account) diff --git a/app/views/following_accounts/index.html.haml b/app/views/following_accounts/index.html.haml index 67f6cfede..8fd95a0b4 100644 --- a/app/views/following_accounts/index.html.haml +++ b/app/views/following_accounts/index.html.haml @@ -7,4 +7,7 @@ = render 'accounts/header', account: @account -= render 'accounts/follow_grid', follows: @follows, accounts: @follows.map(&:target_account) +- if @account.user_hides_network? + = render 'accounts/follow_grid_hidden' +- else + = render 'accounts/follow_grid', follows: @follows, accounts: @follows.map(&:target_account) diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml index be9648561..63cc3c7a7 100644 --- a/app/views/layouts/public.html.haml +++ b/app/views/layouts/public.html.haml @@ -8,9 +8,9 @@ %span.single-user-login = link_to t('auth.login'), new_user_session_path — - %span.domain= link_to site_hostname, about_path + %span.footer__domain= link_to site_hostname, about_path - else - %span.domain= link_to site_hostname, root_path + %span.footer__domain= link_to site_hostname, root_path %span.powered-by != t('generic.powered_by', link: link_to('Mastodon', 'https://joinmastodon.org')) diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml index fd66e13fb..d2e866373 100644 --- a/app/views/settings/preferences/show.html.haml +++ b/app/views/settings/preferences/show.html.haml @@ -26,6 +26,9 @@ .fields-group = f.input :setting_noindex, as: :boolean, wrapper: :with_label + .fields-group + = f.input :setting_hide_network, as: :boolean, wrapper: :with_label + %h4= t 'preferences.web' .fields-group diff --git a/config/locales/en.yml b/config/locales/en.yml index c074fa5b0..0257241cf 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -40,6 +40,7 @@ en: following: Following media: Media moved_html: "%{name} has moved to %{new_profile_link}:" + network_hidden: This information is not available nothing_here: There is nothing here! people_followed_by: People whom %{name} follows people_who_follow: People who follow %{name} diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 7d6907ff5..85597e9a7 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -15,6 +15,7 @@ en: note: one: 1 character left other: %{count} characters left + setting_hide_network: Who you follow and who follows you will not be shown on your profile setting_noindex: Affects your public profile and status pages setting_theme: Affects how Mastodon looks when you're logged in from any device. imports: @@ -54,6 +55,7 @@ en: setting_default_sensitive: Always mark media as sensitive setting_delete_modal: Show confirmation dialog before deleting a toot setting_display_sensitive_media: Always show media marked as sensitive + setting_hide_network: Hide your network setting_noindex: Opt-out of search engine indexing setting_reduce_motion: Reduce motion in animations setting_system_font_ui: Use system's default font diff --git a/config/settings.yml b/config/settings.yml index dcf655008..3581d10a2 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -20,6 +20,7 @@ defaults: &defaults timeline_preview: true show_staff_badge: true default_sensitive: false + hide_network: false unfollow_modal: false boost_modal: false delete_modal: true -- cgit From 8378b72ebacc51e5e090faa527462b801e4c2803 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 19 May 2018 21:05:08 +0200 Subject: Ensure push subscription is immediately removed when application is revoked (#7548) * Ensure push subscription is immediately removed when application is revoked * When token is revoked from app, unsubscribe too --- .../oauth/authorized_applications_controller.rb | 5 +++++ app/controllers/oauth/tokens_controller.rb | 14 +++++++++++++ app/models/web/push_subscription.rb | 9 +++++++++ config/routes.rb | 4 +++- .../authorized_applications_controller_spec.rb | 20 +++++++++++++++++++ spec/controllers/oauth/tokens_controller_spec.rb | 23 ++++++++++++++++++++++ .../web_push_subscription_fabricator.rb | 2 +- spec/fabricators/web_setting_fabricator.rb | 3 +-- 8 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 app/controllers/oauth/tokens_controller.rb create mode 100644 spec/controllers/oauth/tokens_controller_spec.rb (limited to 'app/controllers') diff --git a/app/controllers/oauth/authorized_applications_controller.rb b/app/controllers/oauth/authorized_applications_controller.rb index 395fbc51b..0c28d194b 100644 --- a/app/controllers/oauth/authorized_applications_controller.rb +++ b/app/controllers/oauth/authorized_applications_controller.rb @@ -8,6 +8,11 @@ class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio include Localized + def destroy + Web::PushSubscription.unsubscribe_for(params[:id], current_resource_owner) + super + end + private def store_current_location diff --git a/app/controllers/oauth/tokens_controller.rb b/app/controllers/oauth/tokens_controller.rb new file mode 100644 index 000000000..fa6d58f25 --- /dev/null +++ b/app/controllers/oauth/tokens_controller.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class Oauth::TokensController < Doorkeeper::TokensController + def revoke + unsubscribe_for_token if authorized? && token.accessible? + super + end + + private + + def unsubscribe_for_token + Web::PushSubscription.where(access_token_id: token.id).delete_all + end +end diff --git a/app/models/web/push_subscription.rb b/app/models/web/push_subscription.rb index 7da3428fe..867bc9519 100644 --- a/app/models/web/push_subscription.rb +++ b/app/models/web/push_subscription.rb @@ -50,6 +50,15 @@ class Web::PushSubscription < ApplicationRecord end end + class << self + def unsubscribe_for(application_id, resource_owner) + access_token_ids = Doorkeeper::AccessToken.where(application_id: application_id, resource_owner_id: resource_owner.id, revoked_at: nil) + .pluck(:id) + + where(access_token_id: access_token_ids).delete_all + end + end + private def push_payload(message, ttl = 5.minutes.seconds) diff --git a/config/routes.rb b/config/routes.rb index bd9d09226..3042b5ea0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -14,7 +14,9 @@ Rails.application.routes.draw do end use_doorkeeper do - controllers authorizations: 'oauth/authorizations', authorized_applications: 'oauth/authorized_applications' + controllers authorizations: 'oauth/authorizations', + authorized_applications: 'oauth/authorized_applications', + tokens: 'oauth/tokens' end get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta, defaults: { format: 'xml' } diff --git a/spec/controllers/oauth/authorized_applications_controller_spec.rb b/spec/controllers/oauth/authorized_applications_controller_spec.rb index f967b507f..901e538e9 100644 --- a/spec/controllers/oauth/authorized_applications_controller_spec.rb +++ b/spec/controllers/oauth/authorized_applications_controller_spec.rb @@ -39,4 +39,24 @@ describe Oauth::AuthorizedApplicationsController do include_examples 'stores location for user' end end + + describe 'DELETE #destroy' do + let!(:user) { Fabricate(:user) } + let!(:application) { Fabricate(:application) } + let!(:access_token) { Fabricate(:accessible_access_token, application: application, resource_owner_id: user.id) } + let!(:web_push_subscription) { Fabricate(:web_push_subscription, user: user, access_token: access_token) } + + before do + sign_in user, scope: :user + post :destroy, params: { id: application.id } + end + + it 'revokes access tokens for the application' do + expect(Doorkeeper::AccessToken.where(application: application).first.revoked_at).to_not be_nil + end + + it 'removes subscriptions for the application\'s access tokens' do + expect(Web::PushSubscription.where(user: user).count).to eq 0 + end + end end diff --git a/spec/controllers/oauth/tokens_controller_spec.rb b/spec/controllers/oauth/tokens_controller_spec.rb new file mode 100644 index 000000000..ba8e367a6 --- /dev/null +++ b/spec/controllers/oauth/tokens_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe Oauth::TokensController, type: :controller do + describe 'POST #revoke' do + let!(:user) { Fabricate(:user) } + let!(:access_token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) } + let!(:web_push_subscription) { Fabricate(:web_push_subscription, user: user, access_token: access_token) } + + before do + post :revoke, params: { token: access_token.token } + end + + it 'revokes the token' do + expect(access_token.reload.revoked_at).to_not be_nil + end + + it 'removes web push subscription for token' do + expect(Web::PushSubscription.where(access_token: access_token).count).to eq 0 + end + end +end diff --git a/spec/fabricators/web_push_subscription_fabricator.rb b/spec/fabricators/web_push_subscription_fabricator.rb index 72d11b77c..97f90675d 100644 --- a/spec/fabricators/web_push_subscription_fabricator.rb +++ b/spec/fabricators/web_push_subscription_fabricator.rb @@ -1,4 +1,4 @@ -Fabricator(:web_push_subscription) do +Fabricator(:web_push_subscription, from: Web::PushSubscription) do endpoint Faker::Internet.url key_p256dh Faker::Internet.password key_auth Faker::Internet.password diff --git a/spec/fabricators/web_setting_fabricator.rb b/spec/fabricators/web_setting_fabricator.rb index e5136829b9..369b86bc1 100644 --- a/spec/fabricators/web_setting_fabricator.rb +++ b/spec/fabricators/web_setting_fabricator.rb @@ -1,3 +1,2 @@ -Fabricator('Web::Setting') do - +Fabricator(:web_setting, from: Web::Setting) do end -- cgit From 05f8c375a245ff6709a20f6a4ac5115a75db3f2b Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 21 May 2018 12:43:05 +0200 Subject: Remove small pagination limit from context API (#7564) Fix #7557 --- app/controllers/api/v1/statuses_controller.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index 01880565c..289d91045 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -10,6 +10,12 @@ class Api::V1::StatusesController < Api::BaseController respond_to :json + # This API was originally unlimited, pagination cannot be introduced without + # breaking backwards-compatibility. Arbitrarily high number to cover most + # conversations as quasi-unlimited, it would be too much work to render more + # than this anyway + CONTEXT_LIMIT = 4_096 + def show cached = Rails.cache.read(@status.cache_key) @status = cached unless cached.nil? @@ -17,8 +23,8 @@ class Api::V1::StatusesController < Api::BaseController end def context - ancestors_results = @status.in_reply_to_id.nil? ? [] : @status.ancestors(DEFAULT_STATUSES_LIMIT, current_account) - descendants_results = @status.descendants(DEFAULT_STATUSES_LIMIT, current_account) + ancestors_results = @status.in_reply_to_id.nil? ? [] : @status.ancestors(CONTEXT_LIMIT, current_account) + descendants_results = @status.descendants(CONTEXT_LIMIT, current_account) loaded_ancestors = cache_collection(ancestors_results, Status) loaded_descendants = cache_collection(descendants_results, Status) -- cgit From 36e47a31e33a86c401c2aaf1f9788ca0c91bdec0 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 22 May 2018 14:44:53 +0200 Subject: Enforce order on authorized applications page (#7587) Fix #7586 --- app/controllers/settings/applications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/settings/applications_controller.rb b/app/controllers/settings/applications_controller.rb index 8fc9a0fa9..2a4962311 100644 --- a/app/controllers/settings/applications_controller.rb +++ b/app/controllers/settings/applications_controller.rb @@ -8,7 +8,7 @@ class Settings::ApplicationsController < ApplicationController before_action :prepare_scopes, only: [:create, :update] def index - @applications = current_user.applications.page(params[:page]) + @applications = current_user.applications.order(id: :desc).page(params[:page]) end def new -- cgit From 4d81809f36fcbfe787e23d490f2cb0ad943ab32c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 22 May 2018 20:05:24 +0200 Subject: Yeah, it was supposed to be #create? --- app/controllers/invites_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 8e87c63cf..26ef99b7e 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -8,7 +8,7 @@ class InvitesController < ApplicationController before_action :authenticate_user! def index - authorize :invite, :index? + authorize :invite, :create? @invites = invites @invite = Invite.new(expires_in: 1.day.to_i) -- cgit From ebf2fef029bb44dc3872c4fa578cbbda6ec506b2 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 26 May 2018 01:09:30 +0200 Subject: Catch ActionController::UnknownFormat and return HTTP 406 (#7621) An error like that should not appear in production error log. --- app/controllers/application_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5b22f17c6..29ba6cad6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -20,6 +20,7 @@ class ApplicationController < ActionController::Base rescue_from ActionController::RoutingError, with: :not_found rescue_from ActiveRecord::RecordNotFound, with: :not_found rescue_from ActionController::InvalidAuthenticityToken, with: :unprocessable_entity + rescue_from ActionController::UnknownFormat, with: :not_acceptable rescue_from Mastodon::NotPermittedError, with: :forbidden before_action :store_current_location, except: :raise_not_found, unless: :devise_controller? @@ -73,6 +74,10 @@ class ApplicationController < ActionController::Base respond_with_error(422) end + def not_acceptable + respond_with_error(406) + end + def single_user_mode? @single_user_mode ||= Rails.configuration.x.single_user_mode && Account.exists? end -- cgit From 9bd23dc4e51ba47283a8e3a66cd94b4e624a5235 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 27 May 2018 21:45:30 +0200 Subject: Track trending tags (#7638) * Track trending tags - Half-life of 1 day - Historical usage in daily buckets (last 7 days stored) - GET /api/v1/trends Fix #271 * Add trends to web UI * Don't render compose form on search route, adjust search results header * Disqualify tag from trends if it's in disallowed hashtags setting * Count distinct accounts using tag, ignore silenced accounts --- app/controllers/api/v1/trends_controller.rb | 17 +++++ app/javascript/mastodon/actions/trends.js | 32 +++++++++ .../features/compose/components/search_results.js | 59 ++++++++++++++- .../compose/containers/search_results_container.js | 8 ++- app/javascript/mastodon/features/compose/index.js | 4 +- app/javascript/mastodon/reducers/index.js | 2 + app/javascript/mastodon/reducers/trends.js | 13 ++++ app/javascript/styles/mastodon/components.scss | 83 +++++++++++++++++++++- app/models/tag.rb | 16 +++++ app/models/trending_tags.rb | 61 ++++++++++++++++ app/serializers/rest/tag_serializer.rb | 11 +++ app/services/process_hashtags_service.rb | 6 +- config/routes.rb | 1 + package.json | 1 + yarn.lock | 6 ++ 15 files changed, 310 insertions(+), 10 deletions(-) create mode 100644 app/controllers/api/v1/trends_controller.rb create mode 100644 app/javascript/mastodon/actions/trends.js create mode 100644 app/javascript/mastodon/reducers/trends.js create mode 100644 app/models/trending_tags.rb create mode 100644 app/serializers/rest/tag_serializer.rb (limited to 'app/controllers') diff --git a/app/controllers/api/v1/trends_controller.rb b/app/controllers/api/v1/trends_controller.rb new file mode 100644 index 000000000..bcea9857e --- /dev/null +++ b/app/controllers/api/v1/trends_controller.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class Api::V1::TrendsController < Api::BaseController + before_action :set_tags + + respond_to :json + + def index + render json: @tags, each_serializer: REST::TagSerializer + end + + private + + def set_tags + @tags = TrendingTags.get(limit_param(10)) + end +end diff --git a/app/javascript/mastodon/actions/trends.js b/app/javascript/mastodon/actions/trends.js new file mode 100644 index 000000000..853e4f60a --- /dev/null +++ b/app/javascript/mastodon/actions/trends.js @@ -0,0 +1,32 @@ +import api from '../api'; + +export const TRENDS_FETCH_REQUEST = 'TRENDS_FETCH_REQUEST'; +export const TRENDS_FETCH_SUCCESS = 'TRENDS_FETCH_SUCCESS'; +export const TRENDS_FETCH_FAIL = 'TRENDS_FETCH_FAIL'; + +export const fetchTrends = () => (dispatch, getState) => { + dispatch(fetchTrendsRequest()); + + api(getState) + .get('/api/v1/trends') + .then(({ data }) => dispatch(fetchTrendsSuccess(data))) + .catch(err => dispatch(fetchTrendsFail(err))); +}; + +export const fetchTrendsRequest = () => ({ + type: TRENDS_FETCH_REQUEST, + skipLoading: true, +}); + +export const fetchTrendsSuccess = trends => ({ + type: TRENDS_FETCH_SUCCESS, + trends, + skipLoading: true, +}); + +export const fetchTrendsFail = error => ({ + type: TRENDS_FETCH_FAIL, + error, + skipLoading: true, + skipAlert: true, +}); diff --git a/app/javascript/mastodon/features/compose/components/search_results.js b/app/javascript/mastodon/features/compose/components/search_results.js index 84455563c..f2655c14d 100644 --- a/app/javascript/mastodon/features/compose/components/search_results.js +++ b/app/javascript/mastodon/features/compose/components/search_results.js @@ -1,23 +1,75 @@ import React from 'react'; +import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; -import { FormattedMessage } from 'react-intl'; +import { FormattedMessage, FormattedNumber } from 'react-intl'; import AccountContainer from '../../../containers/account_container'; import StatusContainer from '../../../containers/status_container'; import { Link } from 'react-router-dom'; import ImmutablePureComponent from 'react-immutable-pure-component'; +import { Sparklines, SparklinesCurve } from 'react-sparklines'; + +const shortNumberFormat = number => { + if (number < 1000) { + return ; + } else { + return K; + } +}; export default class SearchResults extends ImmutablePureComponent { static propTypes = { results: ImmutablePropTypes.map.isRequired, + trends: ImmutablePropTypes.list, + fetchTrends: PropTypes.func.isRequired, }; + componentDidMount () { + const { fetchTrends } = this.props; + fetchTrends(); + } + render () { - const { results } = this.props; + const { results, trends } = this.props; let accounts, statuses, hashtags; let count = 0; + if (results.isEmpty()) { + return ( +
+
+
+ + +
+ + {trends && trends.map(hashtag => ( +
+
+ + #{hashtag.get('name')} + + + {shortNumberFormat(hashtag.getIn(['history', 0, 'accounts']))} }} /> +
+ +
+ {shortNumberFormat(hashtag.getIn(['history', 0, 'uses']))} +
+ +
+ day.get('uses')).toArray()}> + + +
+
+ ))} +
+
+ ); + } + if (results.get('accounts') && results.get('accounts').size > 0) { count += results.get('accounts').size; accounts = ( @@ -48,7 +100,7 @@ export default class SearchResults extends ImmutablePureComponent { {results.get('hashtags').map(hashtag => ( - #{hashtag} + {hashtag} ))}
@@ -58,6 +110,7 @@ export default class SearchResults extends ImmutablePureComponent { return (
+
diff --git a/app/javascript/mastodon/features/compose/containers/search_results_container.js b/app/javascript/mastodon/features/compose/containers/search_results_container.js index 16d95d417..7273460e2 100644 --- a/app/javascript/mastodon/features/compose/containers/search_results_container.js +++ b/app/javascript/mastodon/features/compose/containers/search_results_container.js @@ -1,8 +1,14 @@ import { connect } from 'react-redux'; import SearchResults from '../components/search_results'; +import { fetchTrends } from '../../../actions/trends'; const mapStateToProps = state => ({ results: state.getIn(['search', 'results']), + trends: state.get('trends'), }); -export default connect(mapStateToProps)(SearchResults); +const mapDispatchToProps = dispatch => ({ + fetchTrends: () => dispatch(fetchTrends()), +}); + +export default connect(mapStateToProps, mapDispatchToProps)(SearchResults); diff --git a/app/javascript/mastodon/features/compose/index.js b/app/javascript/mastodon/features/compose/index.js index 19aae0332..d8e9ad9ee 100644 --- a/app/javascript/mastodon/features/compose/index.js +++ b/app/javascript/mastodon/features/compose/index.js @@ -101,7 +101,7 @@ export default class Compose extends React.PureComponent { {(multiColumn || isSearchPage) && }
-
+ {!isSearchPage &&
{multiColumn && ( @@ -109,7 +109,7 @@ export default class Compose extends React.PureComponent {
)} -
+
} {({ x }) => ( diff --git a/app/javascript/mastodon/reducers/index.js b/app/javascript/mastodon/reducers/index.js index 3d9a6a132..019c1f466 100644 --- a/app/javascript/mastodon/reducers/index.js +++ b/app/javascript/mastodon/reducers/index.js @@ -26,6 +26,7 @@ import height_cache from './height_cache'; import custom_emojis from './custom_emojis'; import lists from './lists'; import listEditor from './list_editor'; +import trends from './trends'; const reducers = { dropdown_menu, @@ -55,6 +56,7 @@ const reducers = { custom_emojis, lists, listEditor, + trends, }; export default combineReducers(reducers); diff --git a/app/javascript/mastodon/reducers/trends.js b/app/javascript/mastodon/reducers/trends.js new file mode 100644 index 000000000..95cf8f284 --- /dev/null +++ b/app/javascript/mastodon/reducers/trends.js @@ -0,0 +1,13 @@ +import { TRENDS_FETCH_SUCCESS } from '../actions/trends'; +import { fromJS } from 'immutable'; + +const initialState = null; + +export default function trendsReducer(state = initialState, action) { + switch(action.type) { + case TRENDS_FETCH_SUCCESS: + return fromJS(action.trends); + default: + return state; + } +}; diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 2724454fb..c66bc427c 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -3334,9 +3334,15 @@ a.status-card { color: $dark-text-color; background: lighten($ui-base-color, 2%); border-bottom: 1px solid darken($ui-base-color, 4%); - padding: 15px 10px; - font-size: 14px; + padding: 15px; font-weight: 500; + font-size: 16px; + cursor: default; + + .fa { + display: inline-block; + margin-right: 5px; + } } .search-results__section { @@ -5209,3 +5215,76 @@ noscript { background: $ui-base-color; } } + +.trends { + &__header { + color: $dark-text-color; + background: lighten($ui-base-color, 2%); + border-bottom: 1px solid darken($ui-base-color, 4%); + font-weight: 500; + padding: 15px; + font-size: 16px; + cursor: default; + + .fa { + display: inline-block; + margin-right: 5px; + } + } + + &__item { + display: flex; + align-items: center; + padding: 15px; + border-bottom: 1px solid lighten($ui-base-color, 8%); + + &:last-child { + border-bottom: 0; + } + + &__name { + flex: 1 1 auto; + color: $dark-text-color; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + + strong { + font-weight: 500; + } + + a { + color: $darker-text-color; + text-decoration: none; + font-size: 14px; + font-weight: 500; + display: block; + + &:hover, + &:focus, + &:active { + span { + text-decoration: underline; + } + } + } + } + + &__current { + width: 100px; + font-size: 24px; + line-height: 36px; + font-weight: 500; + text-align: center; + color: $secondary-text-color; + } + + &__sparkline { + width: 50px; + + path { + stroke: lighten($highlight-text-color, 6%) !important; + } + } + } +} diff --git a/app/models/tag.rb b/app/models/tag.rb index 8b1b02412..4f31f796e 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -21,6 +21,22 @@ class Tag < ApplicationRecord name end + def history + days = [] + + 7.times do |i| + day = i.days.ago.beginning_of_day.to_i + + days << { + day: day.to_s, + uses: Redis.current.get("activity:tags:#{id}:#{day}") || '0', + accounts: Redis.current.pfcount("activity:tags:#{id}:#{day}:accounts").to_s, + } + end + + days + end + class << self def search_for(term, limit = 5) pattern = sanitize_sql_like(term.strip) + '%' diff --git a/app/models/trending_tags.rb b/app/models/trending_tags.rb new file mode 100644 index 000000000..eedd92644 --- /dev/null +++ b/app/models/trending_tags.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +class TrendingTags + KEY = 'trending_tags' + HALF_LIFE = 1.day.to_i + MAX_ITEMS = 500 + EXPIRE_HISTORY_AFTER = 7.days.seconds + + class << self + def record_use!(tag, account, at_time = Time.now.utc) + return if disallowed_hashtags.include?(tag.name) || account.silenced? + + increment_vote!(tag.id, at_time) + increment_historical_use!(tag.id, at_time) + increment_unique_use!(tag.id, account.id, at_time) + end + + def get(limit) + tag_ids = redis.zrevrange(KEY, 0, limit).map(&:to_i) + tags = Tag.where(id: tag_ids).to_a.map { |tag| [tag.id, tag] }.to_h + tag_ids.map { |tag_id| tags[tag_id] }.compact + end + + private + + def increment_vote!(tag_id, at_time) + redis.zincrby(KEY, (2**((at_time.to_i - epoch) / HALF_LIFE)).to_f, tag_id.to_s) + redis.zremrangebyrank(KEY, 0, -MAX_ITEMS) if rand < (2.to_f / MAX_ITEMS) + end + + def increment_historical_use!(tag_id, at_time) + key = "activity:tags:#{tag_id}:#{at_time.beginning_of_day.to_i}" + redis.incrby(key, 1) + redis.expire(key, EXPIRE_HISTORY_AFTER) + end + + def increment_unique_use!(tag_id, account_id, at_time) + key = "activity:tags:#{tag_id}:#{at_time.beginning_of_day.to_i}:accounts" + redis.pfadd(key, account_id) + redis.expire(key, EXPIRE_HISTORY_AFTER) + end + + # The epoch needs to be 2.5 years in the future if the half-life is one day + # While dynamic, it will always be the same within one year + def epoch + @epoch ||= Date.new(Date.current.year + 2.5, 10, 1).to_datetime.to_i + end + + def disallowed_hashtags + return @disallowed_hashtags if defined?(@disallowed_hashtags) + + @disallowed_hashtags = Setting.disallowed_hashtags.nil? ? [] : Setting.disallowed_hashtags + @disallowed_hashtags = @disallowed_hashtags.split(' ') if @disallowed_hashtags.is_a? String + @disallowed_hashtags = @disallowed_hashtags.map(&:downcase) + end + + def redis + Redis.current + end + end +end diff --git a/app/serializers/rest/tag_serializer.rb b/app/serializers/rest/tag_serializer.rb new file mode 100644 index 000000000..74aa571a4 --- /dev/null +++ b/app/serializers/rest/tag_serializer.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class REST::TagSerializer < ActiveModel::Serializer + include RoutingHelper + + attributes :name, :url, :history + + def url + tag_url(object) + end +end diff --git a/app/services/process_hashtags_service.rb b/app/services/process_hashtags_service.rb index 5b45c865f..0695922b8 100644 --- a/app/services/process_hashtags_service.rb +++ b/app/services/process_hashtags_service.rb @@ -4,8 +4,10 @@ class ProcessHashtagsService < BaseService def call(status, tags = []) tags = Extractor.extract_hashtags(status.text) if status.local? - tags.map { |str| str.mb_chars.downcase }.uniq(&:to_s).each do |tag| - status.tags << Tag.where(name: tag).first_or_initialize(name: tag) + tags.map { |str| str.mb_chars.downcase }.uniq(&:to_s).each do |name| + tag = Tag.where(name: name).first_or_create(name: name) + status.tags << tag + TrendingTags.record_use!(tag, status.account, status.created_at) end end end diff --git a/config/routes.rb b/config/routes.rb index 3042b5ea0..2fcb885ed 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -254,6 +254,7 @@ Rails.application.routes.draw do resources :mutes, only: [:index] resources :favourites, only: [:index] resources :reports, only: [:index, :create] + resources :trends, only: [:index] namespace :apps do get :verify_credentials, to: 'credentials#show' diff --git a/package.json b/package.json index 61f38409c..6ee6f98d3 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,7 @@ "react-redux-loading-bar": "^2.9.3", "react-router-dom": "^4.1.1", "react-router-scroll-4": "^1.0.0-beta.1", + "react-sparklines": "^1.7.0", "react-swipeable-views": "^0.12.3", "react-textarea-autosize": "^5.2.1", "react-toggle": "^4.0.1", diff --git a/yarn.lock b/yarn.lock index 50c88557d..de48c995a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6124,6 +6124,12 @@ react-router@^4.2.0: prop-types "^15.5.4" warning "^3.0.0" +react-sparklines@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/react-sparklines/-/react-sparklines-1.7.0.tgz#9b1d97e8c8610095eeb2ad658d2e1fcf91f91a60" + dependencies: + prop-types "^15.5.10" + react-swipeable-views-core@^0.12.11: version "0.12.11" resolved "https://registry.yarnpkg.com/react-swipeable-views-core/-/react-swipeable-views-core-0.12.11.tgz#3cf2b4daffbb36f9d69bd19bf5b2d5370b6b2c1b" -- cgit From b87a1229c74aebec02cd08091f25613f6dff4428 Mon Sep 17 00:00:00 2001 From: tateisu Date: Mon, 28 May 2018 18:04:06 +0900 Subject: optimize direct timeline (#7614) * optimize direct timeline * fix typo in class name * change filter condition for direct timeline * fix codestyle issue * revoke index_accounts_not_silenced because direct timeline does not use it. * revoke index_accounts_not_silenced because direct timeline does not use it. * fix rspec test condition. * fix rspec test condition. * fix rspec test condition. * revoke adding column and partial index * (direct timeline) move merging logic to model * fix pagination parameter * add method arguments that switches return array of status or cache_ids * fix order by * returns ActiveRecord.Relation in default behavor * fix codestyle issue --- .../api/v1/timelines/direct_controller.rb | 15 +++++--- app/models/status.rb | 43 +++++++++++++++++++--- spec/models/status_spec.rb | 23 ++++++------ 3 files changed, 59 insertions(+), 22 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/api/v1/timelines/direct_controller.rb b/app/controllers/api/v1/timelines/direct_controller.rb index d455227eb..ef64078be 100644 --- a/app/controllers/api/v1/timelines/direct_controller.rb +++ b/app/controllers/api/v1/timelines/direct_controller.rb @@ -23,15 +23,18 @@ class Api::V1::Timelines::DirectController < Api::BaseController end def direct_statuses - direct_timeline_statuses.paginate_by_max_id( - limit_param(DEFAULT_STATUSES_LIMIT), - params[:max_id], - params[:since_id] - ) + direct_timeline_statuses end def direct_timeline_statuses - Status.as_direct_timeline(current_account) + # this query requires built in pagination. + Status.as_direct_timeline( + current_account, + limit_param(DEFAULT_STATUSES_LIMIT), + params[:max_id], + params[:since_id], + true # returns array of cache_ids object + ) end def insert_pagination_headers diff --git a/app/models/status.rb b/app/models/status.rb index 853e75b43..54f3f68f5 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -188,12 +188,45 @@ class Status < ApplicationRecord where(account: [account] + account.following).where(visibility: [:public, :unlisted, :private]) end - def as_direct_timeline(account) - query = joins("LEFT OUTER JOIN mentions ON statuses.id = mentions.status_id AND mentions.account_id = #{account.id}") - .where("mentions.account_id = #{account.id} OR statuses.account_id = #{account.id}") - .where(visibility: [:direct]) + def as_direct_timeline(account, limit = 20, max_id = nil, since_id = nil, cache_ids = false) + # direct timeline is mix of direct message from_me and to_me. + # 2 querys are executed with pagination. + # constant expression using arel_table is required for partial index + + # _from_me part does not require any timeline filters + query_from_me = where(account_id: account.id) + .where(Status.arel_table[:visibility].eq(3)) + .limit(limit) + .order('statuses.id DESC') + + # _to_me part requires mute and block filter. + # FIXME: may we check mutes.hide_notifications? + query_to_me = Status + .joins(:mentions) + .merge(Mention.where(account_id: account.id)) + .where(Status.arel_table[:visibility].eq(3)) + .limit(limit) + .order('mentions.status_id DESC') + .not_excluded_by_account(account) + + if max_id.present? + query_from_me = query_from_me.where('statuses.id < ?', max_id) + query_to_me = query_to_me.where('mentions.status_id < ?', max_id) + end + + if since_id.present? + query_from_me = query_from_me.where('statuses.id > ?', since_id) + query_to_me = query_to_me.where('mentions.status_id > ?', since_id) + end - apply_timeline_filters(query, account, false) + if cache_ids + # returns array of cache_ids object that have id and updated_at + (query_from_me.cache_ids.to_a + query_to_me.cache_ids.to_a).uniq(&:id).sort_by(&:id).reverse.take(limit) + else + # returns ActiveRecord.Relation + items = (query_from_me.select(:id).to_a + query_to_me.select(:id).to_a).uniq(&:id).sort_by(&:id).reverse.take(limit) + Status.where(id: items.map(&:id)) + end end def as_public_timeline(account = nil, local_only = false) diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index c6701018e..aee4f49b4 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -154,7 +154,7 @@ RSpec.describe Status, type: :model do describe '#target' do it 'returns nil if the status is self-contained' do - expect(subject.target).to be_nil + expect(subject.target).to be_nil end it 'returns nil if the status is a reply' do @@ -333,24 +333,25 @@ RSpec.describe Status, type: :model do expect(@results).to_not include(@followed_public_status) end - it 'includes direct statuses mentioning recipient from followed' do - Fabricate(:mention, account: account, status: @followed_direct_status) - expect(@results).to include(@followed_direct_status) - end - it 'does not include direct statuses not mentioning recipient from followed' do expect(@results).to_not include(@followed_direct_status) end - it 'includes direct statuses mentioning recipient from non-followed' do - Fabricate(:mention, account: account, status: @not_followed_direct_status) - expect(@results).to include(@not_followed_direct_status) - end - it 'does not include direct statuses not mentioning recipient from non-followed' do expect(@results).to_not include(@not_followed_direct_status) end + it 'includes direct statuses mentioning recipient from followed' do + Fabricate(:mention, account: account, status: @followed_direct_status) + results2 = Status.as_direct_timeline(account) + expect(results2).to include(@followed_direct_status) + end + + it 'includes direct statuses mentioning recipient from non-followed' do + Fabricate(:mention, account: account, status: @not_followed_direct_status) + results2 = Status.as_direct_timeline(account) + expect(results2).to include(@not_followed_direct_status) + end end describe '.as_public_timeline' do -- cgit From 8bb74e50beb3e6602c183e59086ccebe87f96fb2 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 29 May 2018 02:01:24 +0200 Subject: Add GET /api/v2/search which returns rich tag objects, adjust web UI (#7661) --- app/controllers/api/v2/search_controller.rb | 8 ++++ app/javascript/mastodon/actions/search.js | 2 +- .../features/compose/components/search_results.js | 56 +++++++++++----------- app/javascript/mastodon/reducers/search.js | 4 +- app/javascript/styles/mastodon/components.scss | 44 ++++++++--------- app/serializers/rest/v2/search_serializer.rb | 7 +++ config/routes.rb | 4 ++ 7 files changed, 69 insertions(+), 56 deletions(-) create mode 100644 app/controllers/api/v2/search_controller.rb create mode 100644 app/serializers/rest/v2/search_serializer.rb (limited to 'app/controllers') diff --git a/app/controllers/api/v2/search_controller.rb b/app/controllers/api/v2/search_controller.rb new file mode 100644 index 000000000..2e91d68ee --- /dev/null +++ b/app/controllers/api/v2/search_controller.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class Api::V2::SearchController < Api::V1::SearchController + def index + @search = Search.new(search) + render json: @search, serializer: REST::V2::SearchSerializer + end +end diff --git a/app/javascript/mastodon/actions/search.js b/app/javascript/mastodon/actions/search.js index 882c1709e..b670d25c3 100644 --- a/app/javascript/mastodon/actions/search.js +++ b/app/javascript/mastodon/actions/search.js @@ -33,7 +33,7 @@ export function submitSearch() { dispatch(fetchSearchRequest()); - api(getState).get('/api/v1/search', { + api(getState).get('/api/v2/search', { params: { q: value, resolve: true, diff --git a/app/javascript/mastodon/features/compose/components/search_results.js b/app/javascript/mastodon/features/compose/components/search_results.js index f2655c14d..445bf27bb 100644 --- a/app/javascript/mastodon/features/compose/components/search_results.js +++ b/app/javascript/mastodon/features/compose/components/search_results.js @@ -16,6 +16,28 @@ const shortNumberFormat = number => { } }; +const renderHashtag = hashtag => ( +
+
+ + #{hashtag.get('name')} + + + {shortNumberFormat(hashtag.getIn(['history', 0, 'accounts']))} }} /> +
+ +
+ {shortNumberFormat(hashtag.getIn(['history', 0, 'uses']))} +
+ +
+ day.get('uses')).toArray()}> + + +
+
+); + export default class SearchResults extends ImmutablePureComponent { static propTypes = { @@ -44,27 +66,7 @@ export default class SearchResults extends ImmutablePureComponent {
- {trends && trends.map(hashtag => ( -
-
- - #{hashtag.get('name')} - - - {shortNumberFormat(hashtag.getIn(['history', 0, 'accounts']))} }} /> -
- -
- {shortNumberFormat(hashtag.getIn(['history', 0, 'uses']))} -
- -
- day.get('uses')).toArray()}> - - -
-
- ))} + {trends && trends.map(hashtag => renderHashtag(hashtag))}
); @@ -74,7 +76,7 @@ export default class SearchResults extends ImmutablePureComponent { count += results.get('accounts').size; accounts = (
-
+
{results.get('accounts').map(accountId => )}
@@ -85,7 +87,7 @@ export default class SearchResults extends ImmutablePureComponent { count += results.get('statuses').size; statuses = (
-
+
{results.get('statuses').map(statusId => )}
@@ -96,13 +98,9 @@ export default class SearchResults extends ImmutablePureComponent { count += results.get('hashtags').size; hashtags = (
-
+
- {results.get('hashtags').map(hashtag => ( - - {hashtag} - - ))} + {results.get('hashtags').map(hashtag => renderHashtag(hashtag))}
); } diff --git a/app/javascript/mastodon/reducers/search.js b/app/javascript/mastodon/reducers/search.js index 56fd7226b..4758defb1 100644 --- a/app/javascript/mastodon/reducers/search.js +++ b/app/javascript/mastodon/reducers/search.js @@ -9,7 +9,7 @@ import { COMPOSE_REPLY, COMPOSE_DIRECT, } from '../actions/compose'; -import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; +import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable'; const initialState = ImmutableMap({ value: '', @@ -39,7 +39,7 @@ export default function search(state = initialState, action) { return state.set('results', ImmutableMap({ accounts: ImmutableList(action.results.accounts.map(item => item.id)), statuses: ImmutableList(action.results.statuses.map(item => item.id)), - hashtags: ImmutableList(action.results.hashtags), + hashtags: fromJS(action.results.hashtags), })).set('submitted', true); default: return state; diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index a2a18b5a0..c93d8e86a 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -3284,6 +3284,15 @@ a.status-card { } .search__icon { + &::-moz-focus-inner { + border: 0; + } + + &::-moz-focus-inner, + &:focus { + outline: 0 !important; + } + .fa { position: absolute; top: 10px; @@ -3333,7 +3342,6 @@ a.status-card { .search-results__header { color: $dark-text-color; background: lighten($ui-base-color, 2%); - border-bottom: 1px solid darken($ui-base-color, 4%); padding: 15px; font-weight: 500; font-size: 16px; @@ -3346,33 +3354,21 @@ a.status-card { } .search-results__section { - margin-bottom: 20px; + margin-bottom: 5px; h5 { - position: relative; - - &::before { - content: ""; - display: block; - position: absolute; - left: 0; - right: 0; - top: 50%; - width: 100%; - height: 0; - border-top: 1px solid lighten($ui-base-color, 8%); - } + background: darken($ui-base-color, 4%); + border-bottom: 1px solid lighten($ui-base-color, 8%); + cursor: default; + display: flex; + padding: 15px; + font-weight: 500; + font-size: 16px; + color: $dark-text-color; - span { + .fa { display: inline-block; - background: $ui-base-color; - color: $darker-text-color; - font-size: 14px; - font-weight: 500; - padding: 10px; - position: relative; - z-index: 1; - cursor: default; + margin-right: 5px; } } diff --git a/app/serializers/rest/v2/search_serializer.rb b/app/serializers/rest/v2/search_serializer.rb new file mode 100644 index 000000000..cdb6b3a53 --- /dev/null +++ b/app/serializers/rest/v2/search_serializer.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class REST::V2::SearchSerializer < ActiveModel::Serializer + has_many :accounts, serializer: REST::AccountSerializer + has_many :statuses, serializer: REST::StatusSerializer + has_many :hashtags, serializer: REST::TagSerializer +end diff --git a/config/routes.rb b/config/routes.rb index 2fcb885ed..31e90e2ff 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -315,6 +315,10 @@ Rails.application.routes.draw do end end + namespace :v2 do + get '/search', to: 'search#index', as: :search + end + namespace :web do resource :settings, only: [:update] resource :embed, only: [:create] -- cgit