From 03644ac855b8688345069f2440bec6a01b761a30 Mon Sep 17 00:00:00 2001 From: m4sk1n Date: Tue, 18 Jul 2017 20:03:06 +0200 Subject: [PATCH 01/20] i18n: Update Polish translation (#4252) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Mikołajczak --- app/javascript/mastodon/locales/pl.json | 4 ++-- config/locales/pl.yml | 17 ++++++++++++++++- config/locales/simple_form.pl.yml | 3 +++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/javascript/mastodon/locales/pl.json b/app/javascript/mastodon/locales/pl.json index 683f589b1e..f04ef4e8c1 100644 --- a/app/javascript/mastodon/locales/pl.json +++ b/app/javascript/mastodon/locales/pl.json @@ -55,8 +55,8 @@ "confirmations.domain_block.message": "Czy na pewno chcesz zablokować całą domenę {domain}? Zwykle lepszym rozwiązaniem jest blokada lub wyciszenie kilku użytkowników.", "confirmations.mute.confirm": "Wycisz", "confirmations.mute.message": "Czy na pewno chcesz wyciszyć {name}?", - "confirmations.unfollow.confirm": "Unfollow", - "confirmations.unfollow.message": "Are you sure you want to unfollow {name}?", + "confirmations.unfollow.confirm": "Przestań śledzić", + "confirmations.unfollow.message": "Czy na pewno zamierzasz przestać śledzić {name}?", "emoji_button.activity": "Aktywność", "emoji_button.flags": "Flagi", "emoji_button.food": "Żywność i napoje", diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 98cfe1b771..23912662e3 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -176,7 +176,7 @@ pl: title: Opis instancji site_description_extended: desc_html: Dobre miejsce na zasady użytkowania, wprowadzenie i inne rzeczy, które wyróżniają tą instancję. Możesz korzystać z tagów HTML - title: Niestandrdowy opis stronyv + title: Niestandrdowy opis strony site_terms: desc_html: Miejsce na własną politykę prywatności, zasady użytkowania i inne unormowania prawne. Możesz używać tagów HTML title: Niestandardowe zasady użytkowania @@ -185,6 +185,21 @@ pl: desc_html: Wyświetlaj publiczną oś czasu na stronie widocznej dla niezalogowanych title: Podgląd osi czasu title: Ustawienia strony + statuses: + back_to_account: Wróć na konto + batch: + 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 + with_media: Z zawartością multimedialną + title: Statusy konta subscriptions: callback_url: URL zwrotny confirmed: Potwierdzono diff --git a/config/locales/simple_form.pl.yml b/config/locales/simple_form.pl.yml index 5553c75e33..dc5492ea5e 100644 --- a/config/locales/simple_form.pl.yml +++ b/config/locales/simple_form.pl.yml @@ -40,11 +40,14 @@ pl: otp_attempt: Kod uwierzytelnienia dwustopniowego password: Hasło setting_auto_play_gif: Automatycznie odtwarzaj animowane GIFy + setting_boost_modal: Pytaj o potwierdzenie przed podbiciem setting_default_privacy: Widoczność posta setting_default_sensitive: Zawsze oznaczaj zawartość multimedialną jako wrażliwą setting_delete_modal: Pytaj o potwierdzenie przed usunięciem postu setting_system_font_ui: Używaj domyślnej czcionki systemu + setting_unfollow_modal: Pytaj o potwierdzenie przed usunięciem śledzenia + setting_noindex: Nie indeksuj mojego profilu w wyszukiwarkach internetowych severity: Priorytet type: Typ importu username: Nazwa użytkownika From b8db4f786a76ee5379e20f7e3ee111bdc76fc8c2 Mon Sep 17 00:00:00 2001 From: lindwurm Date: Wed, 19 Jul 2017 03:03:18 +0900 Subject: [PATCH 02/20] Update Japanese translation (chase #4249) (#4251) Signed-off-by: lindwurm --- app/javascript/mastodon/locales/ja.json | 2 +- config/locales/simple_form.ja.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/javascript/mastodon/locales/ja.json b/app/javascript/mastodon/locales/ja.json index b3943f646c..7fe27a092c 100644 --- a/app/javascript/mastodon/locales/ja.json +++ b/app/javascript/mastodon/locales/ja.json @@ -56,7 +56,7 @@ "confirmations.mute.confirm": "ミュート", "confirmations.mute.message": "本当に{name}をミュートしますか?", "confirmations.unfollow.confirm": "フォロー解除", - "confirmations.unfollow.message": "本当に{name}のフォローを解除しますか?", + "confirmations.unfollow.message": "本当に{name}をフォロー解除しますか?", "emoji_button.activity": "活動", "emoji_button.flags": "国旗", "emoji_button.food": "食べ物", diff --git a/config/locales/simple_form.ja.yml b/config/locales/simple_form.ja.yml index 58975e4265..65845e1aa5 100644 --- a/config/locales/simple_form.ja.yml +++ b/config/locales/simple_form.ja.yml @@ -39,6 +39,7 @@ ja: setting_default_sensitive: メディアを常に閲覧注意としてマークする setting_delete_modal: トゥートを削除する前に確認ダイアログを表示する setting_system_font_ui: システムのデフォルトフォントを使う + setting_unfollow_modal: フォロー解除する前に確認ダイアログを表示する setting_noindex: 検索エンジンによるインデックスを拒否する severity: 重大性 type: インポートする項目 From fa9c1179211299ffd69f5b28c9ba47ac4d30eac0 Mon Sep 17 00:00:00 2001 From: Sorin Davidoi Date: Tue, 18 Jul 2017 22:49:24 +0200 Subject: [PATCH 03/20] feat(emoji): Add back title attribute (#4253) --- app/javascript/mastodon/emoji.js | 10 +++++----- app/javascript/mastodon/emojione_light.js | 4 ++-- spec/javascript/components/emojify.test.js | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/javascript/mastodon/emoji.js b/app/javascript/mastodon/emoji.js index 1de41f5722..9b58cacf59 100644 --- a/app/javascript/mastodon/emoji.js +++ b/app/javascript/mastodon/emoji.js @@ -1,7 +1,7 @@ -import { unicodeToFilename } from './emojione_light'; +import { unicodeMapping } from './emojione_light'; import Trie from 'substring-trie'; -const trie = new Trie(Object.keys(unicodeToFilename)); +const trie = new Trie(Object.keys(unicodeMapping)); function emojify(str) { // This walks through the string from start to end, ignoring any tags (

,
, etc.) @@ -19,10 +19,10 @@ function emojify(str) { insideTag = true; } else if (!insideTag && (match = trie.search(str.substring(i)))) { const unicodeStr = match; - if (unicodeStr in unicodeToFilename) { - const filename = unicodeToFilename[unicodeStr]; + if (unicodeStr in unicodeMapping) { + const [filename, shortCode] = unicodeMapping[unicodeStr]; const alt = unicodeStr; - const replacement = `${alt}`; + const replacement = `${alt}`; str = str.substring(0, i) + replacement + str.substring(i + unicodeStr.length); i += (replacement.length - unicodeStr.length); // jump ahead the length we've added to the string } diff --git a/app/javascript/mastodon/emojione_light.js b/app/javascript/mastodon/emojione_light.js index c75e10a98b..985e9dbcb3 100644 --- a/app/javascript/mastodon/emojione_light.js +++ b/app/javascript/mastodon/emojione_light.js @@ -5,7 +5,7 @@ const emojione = require('emojione'); const mappedUnicode = emojione.mapUnicodeToShort(); -module.exports.unicodeToFilename = Object.keys(emojione.jsEscapeMap) +module.exports.unicodeMapping = Object.keys(emojione.jsEscapeMap) .map(unicodeStr => [unicodeStr, mappedUnicode[emojione.jsEscapeMap[unicodeStr]]]) - .map(([unicodeStr, shortCode]) => ({ [unicodeStr]: emojione.emojioneList[shortCode].fname })) + .map(([unicodeStr, shortCode]) => ({ [unicodeStr]: [emojione.emojioneList[shortCode].fname, shortCode.slice(1, shortCode.length - 1)] })) .reduce((x, y) => Object.assign(x, y), { }); diff --git a/spec/javascript/components/emojify.test.js b/spec/javascript/components/emojify.test.js index 2874bb56d3..e165b4519f 100644 --- a/spec/javascript/components/emojify.test.js +++ b/spec/javascript/components/emojify.test.js @@ -22,23 +22,23 @@ describe('emojify', () => { it('does unicode', () => { expect(emojify('\uD83D\uDC69\u200D\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66')).to.equal( - '👩‍👩‍👦‍👦'); + '👩‍👩‍👦‍👦'); expect(emojify('\uD83D\uDC68\uD83D\uDC69\uD83D\uDC67\uD83D\uDC67')).to.equal( - '👨👩👧👧'); - expect(emojify('\uD83D\uDC69\uD83D\uDC69\uD83D\uDC66')).to.equal('👩👩👦'); + '👨👩👧👧'); + expect(emojify('\uD83D\uDC69\uD83D\uDC69\uD83D\uDC66')).to.equal('👩👩👦'); expect(emojify('\u2757')).to.equal( - '❗'); + '❗'); }); it('does multiple unicode', () => { expect(emojify('\u2757 #\uFE0F\u20E3')).to.equal( - '❗ #️⃣'); + '❗ #️⃣'); expect(emojify('\u2757#\uFE0F\u20E3')).to.equal( - '❗#️⃣'); + '❗#️⃣'); expect(emojify('\u2757 #\uFE0F\u20E3 \u2757')).to.equal( - '❗ #️⃣ ❗'); + '❗ #️⃣ ❗'); expect(emojify('foo \u2757 #\uFE0F\u20E3 bar')).to.equal( - 'foo ❗ #️⃣ bar'); + 'foo ❗ #️⃣ bar'); }); it('ignores unicode inside of tags', () => { From 38520329535b14a13bdef229a8a0d9190f2fde2a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 19 Jul 2017 01:37:26 +0200 Subject: [PATCH 04/20] Correct OStatus inflection (Ostatus -> OStatus) (#4255) --- app/controllers/accounts_controller.rb | 2 +- app/controllers/stream_entries_controller.rb | 2 +- app/lib/ostatus/activity/base.rb | 2 +- app/lib/ostatus/activity/creation.rb | 2 +- app/lib/ostatus/activity/deletion.rb | 2 +- app/lib/ostatus/activity/general.rb | 8 +- app/lib/ostatus/activity/post.rb | 2 +- app/lib/ostatus/activity/remote.rb | 2 +- app/lib/ostatus/activity/share.rb | 4 +- app/lib/ostatus/atom_serializer.rb | 2 +- app/services/authorize_follow_service.rb | 2 +- app/services/block_service.rb | 2 +- .../concerns/stream_entry_renderer.rb | 2 +- app/services/favourite_service.rb | 2 +- app/services/follow_service.rb | 4 +- app/services/process_feed_service.rb | 2 +- app/services/reject_follow_service.rb | 2 +- app/services/unblock_service.rb | 2 +- app/services/unfavourite_service.rb | 2 +- app/services/unfollow_service.rb | 2 +- .../pubsubhubbub/distribution_worker.rb | 4 +- config/initializers/inflections.rb | 1 + spec/lib/ostatus/atom_serializer_spec.rb | 330 +++++++++--------- 23 files changed, 193 insertions(+), 192 deletions(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 37a1e540f4..c270eb000c 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -13,7 +13,7 @@ class AccountsController < ApplicationController format.atom do @entries = @account.stream_entries.where(hidden: false).with_includes.paginate_by_max_id(20, params[:max_id], params[:since_id]) - render xml: Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.feed(@account, @entries.to_a)) + render xml: OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.feed(@account, @entries.to_a)) end format.json do diff --git a/app/controllers/stream_entries_controller.rb b/app/controllers/stream_entries_controller.rb index e3db77caaa..3eb91d8305 100644 --- a/app/controllers/stream_entries_controller.rb +++ b/app/controllers/stream_entries_controller.rb @@ -19,7 +19,7 @@ class StreamEntriesController < ApplicationController end format.atom do - render xml: Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.entry(@stream_entry, true)) + render xml: OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.entry(@stream_entry, true)) end end end diff --git a/app/lib/ostatus/activity/base.rb b/app/lib/ostatus/activity/base.rb index f528815b3e..e1477f0eb2 100644 --- a/app/lib/ostatus/activity/base.rb +++ b/app/lib/ostatus/activity/base.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::Activity::Base +class OStatus::Activity::Base def initialize(xml, account = nil) @xml = xml @account = account diff --git a/app/lib/ostatus/activity/creation.rb b/app/lib/ostatus/activity/creation.rb index c54d64fd77..e22f746f2c 100644 --- a/app/lib/ostatus/activity/creation.rb +++ b/app/lib/ostatus/activity/creation.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::Activity::Creation < Ostatus::Activity::Base +class OStatus::Activity::Creation < OStatus::Activity::Base def perform if redis.exists("delete_upon_arrival:#{@account.id}:#{id}") Rails.logger.debug "Delete for status #{id} was queued, ignoring" diff --git a/app/lib/ostatus/activity/deletion.rb b/app/lib/ostatus/activity/deletion.rb index c4d05a4679..860faf501e 100644 --- a/app/lib/ostatus/activity/deletion.rb +++ b/app/lib/ostatus/activity/deletion.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::Activity::Deletion < Ostatus::Activity::Base +class OStatus::Activity::Deletion < OStatus::Activity::Base def perform Rails.logger.debug "Deleting remote status #{id}" status = Status.find_by(uri: id, account: @account) diff --git a/app/lib/ostatus/activity/general.rb b/app/lib/ostatus/activity/general.rb index 3ff7a039a6..b3bef9861d 100644 --- a/app/lib/ostatus/activity/general.rb +++ b/app/lib/ostatus/activity/general.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::Activity::General < Ostatus::Activity::Base +class OStatus::Activity::General < OStatus::Activity::Base def specialize special_class&.new(@xml, @account) end @@ -10,11 +10,11 @@ class Ostatus::Activity::General < Ostatus::Activity::Base def special_class case verb when :post - Ostatus::Activity::Post + OStatus::Activity::Post when :share - Ostatus::Activity::Share + OStatus::Activity::Share when :delete - Ostatus::Activity::Deletion + OStatus::Activity::Deletion end end end diff --git a/app/lib/ostatus/activity/post.rb b/app/lib/ostatus/activity/post.rb index 8028db2f8d..755ed86563 100644 --- a/app/lib/ostatus/activity/post.rb +++ b/app/lib/ostatus/activity/post.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::Activity::Post < Ostatus::Activity::Creation +class OStatus::Activity::Post < OStatus::Activity::Creation def perform status, just_created = super diff --git a/app/lib/ostatus/activity/remote.rb b/app/lib/ostatus/activity/remote.rb index 755f885e62..ecec6886c0 100644 --- a/app/lib/ostatus/activity/remote.rb +++ b/app/lib/ostatus/activity/remote.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::Activity::Remote < Ostatus::Activity::Base +class OStatus::Activity::Remote < OStatus::Activity::Base def perform find_status(id) || FetchRemoteStatusService.new.call(url) end diff --git a/app/lib/ostatus/activity/share.rb b/app/lib/ostatus/activity/share.rb index 73aac58ed2..2900080216 100644 --- a/app/lib/ostatus/activity/share.rb +++ b/app/lib/ostatus/activity/share.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::Activity::Share < Ostatus::Activity::Creation +class OStatus::Activity::Share < OStatus::Activity::Creation def perform return if reblog.nil? @@ -18,7 +18,7 @@ class Ostatus::Activity::Share < Ostatus::Activity::Creation def reblog return @reblog if defined? @reblog - original_status = Ostatus::Activity::Remote.new(object).perform + original_status = OStatus::Activity::Remote.new(object).perform return if original_status.nil? @reblog = original_status.reblog? ? original_status.reblog : original_status diff --git a/app/lib/ostatus/atom_serializer.rb b/app/lib/ostatus/atom_serializer.rb index 909d84df31..0d62361bec 100644 --- a/app/lib/ostatus/atom_serializer.rb +++ b/app/lib/ostatus/atom_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::AtomSerializer +class OStatus::AtomSerializer include RoutingHelper include ActionView::Helpers::SanitizeHelper diff --git a/app/services/authorize_follow_service.rb b/app/services/authorize_follow_service.rb index a25d11dbd5..41815a393e 100644 --- a/app/services/authorize_follow_service.rb +++ b/app/services/authorize_follow_service.rb @@ -10,6 +10,6 @@ class AuthorizeFollowService < BaseService private def build_xml(follow_request) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request)) end end diff --git a/app/services/block_service.rb b/app/services/block_service.rb index 15420e192d..5d7bf6a3bc 100644 --- a/app/services/block_service.rb +++ b/app/services/block_service.rb @@ -18,6 +18,6 @@ class BlockService < BaseService private def build_xml(block) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.block_salmon(block)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.block_salmon(block)) end end diff --git a/app/services/concerns/stream_entry_renderer.rb b/app/services/concerns/stream_entry_renderer.rb index d9c30c53cf..9f6c8a082a 100644 --- a/app/services/concerns/stream_entry_renderer.rb +++ b/app/services/concerns/stream_entry_renderer.rb @@ -2,6 +2,6 @@ module StreamEntryRenderer def stream_entry_to_xml(stream_entry) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.entry(stream_entry, true)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.entry(stream_entry, true)) end end diff --git a/app/services/favourite_service.rb b/app/services/favourite_service.rb index a08aba6380..291f9e56ef 100644 --- a/app/services/favourite_service.rb +++ b/app/services/favourite_service.rb @@ -28,6 +28,6 @@ class FavouriteService < BaseService private def build_xml(favourite) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.favourite_salmon(favourite)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.favourite_salmon(favourite)) end end diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb index 7a7275b6e7..3155feaa49 100644 --- a/app/services/follow_service.rb +++ b/app/services/follow_service.rb @@ -57,10 +57,10 @@ class FollowService < BaseService end def build_follow_request_xml(follow_request) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.follow_request_salmon(follow_request)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.follow_request_salmon(follow_request)) end def build_follow_xml(follow) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.follow_salmon(follow)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.follow_salmon(follow)) end end diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb index b99048a068..9fa8eda519 100644 --- a/app/services/process_feed_service.rb +++ b/app/services/process_feed_service.rb @@ -20,7 +20,7 @@ class ProcessFeedService < BaseService end def process_entry(xml, account) - activity = Ostatus::Activity::General.new(xml, account) + activity = OStatus::Activity::General.new(xml, account) activity.specialize&.perform if activity.status? rescue ActiveRecord::RecordInvalid => e Rails.logger.debug "Nothing was saved for #{id} because: #{e}" diff --git a/app/services/reject_follow_service.rb b/app/services/reject_follow_service.rb index 87fc49b348..fd7e66c237 100644 --- a/app/services/reject_follow_service.rb +++ b/app/services/reject_follow_service.rb @@ -10,6 +10,6 @@ class RejectFollowService < BaseService private def build_xml(follow_request) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.reject_follow_request_salmon(follow_request)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.reject_follow_request_salmon(follow_request)) end end diff --git a/app/services/unblock_service.rb b/app/services/unblock_service.rb index 50c2dc2f01..ff15c72754 100644 --- a/app/services/unblock_service.rb +++ b/app/services/unblock_service.rb @@ -11,6 +11,6 @@ class UnblockService < BaseService private def build_xml(block) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.unblock_salmon(block)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.unblock_salmon(block)) end end diff --git a/app/services/unfavourite_service.rb b/app/services/unfavourite_service.rb index ede3caad17..564aaee46a 100644 --- a/app/services/unfavourite_service.rb +++ b/app/services/unfavourite_service.rb @@ -13,6 +13,6 @@ class UnfavouriteService < BaseService private def build_xml(favourite) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.unfavourite_salmon(favourite)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.unfavourite_salmon(favourite)) end end diff --git a/app/services/unfollow_service.rb b/app/services/unfollow_service.rb index 0c9a5f6577..388909586b 100644 --- a/app/services/unfollow_service.rb +++ b/app/services/unfollow_service.rb @@ -14,6 +14,6 @@ class UnfollowService < BaseService private def build_xml(follow) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.unfollow_salmon(follow)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.unfollow_salmon(follow)) end end diff --git a/app/workers/pubsubhubbub/distribution_worker.rb b/app/workers/pubsubhubbub/distribution_worker.rb index 9c1fa76cb9..ce467d18b1 100644 --- a/app/workers/pubsubhubbub/distribution_worker.rb +++ b/app/workers/pubsubhubbub/distribution_worker.rb @@ -22,7 +22,7 @@ class Pubsubhubbub::DistributionWorker def distribute_public!(stream_entries) return if stream_entries.empty? - @payload = Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.feed(@account, stream_entries)) + @payload = OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.feed(@account, stream_entries)) Pubsubhubbub::DeliveryWorker.push_bulk(@subscriptions) do |subscription| [subscription.id, @payload] @@ -32,7 +32,7 @@ class Pubsubhubbub::DistributionWorker def distribute_hidden!(stream_entries) return if stream_entries.empty? - @payload = Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.feed(@account, stream_entries)) + @payload = OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.feed(@account, stream_entries)) @domains = @account.followers.domains Pubsubhubbub::DeliveryWorker.push_bulk(@subscriptions.reject { |s| !allowed_to_receive?(s.callback_url, s.domain) }) do |subscription| diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 26275d0928..44e54c9f36 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -13,6 +13,7 @@ ActiveSupport::Inflector.inflections(:en) do |inflect| inflect.acronym 'StatsD' inflect.acronym 'OEmbed' + inflect.acronym 'OStatus' inflect.acronym 'ActivityPub' inflect.acronym 'PubSubHubbub' inflect.acronym 'ActivityStreams' diff --git a/spec/lib/ostatus/atom_serializer_spec.rb b/spec/lib/ostatus/atom_serializer_spec.rb index 8caef93554..b0cb8f019e 100644 --- a/spec/lib/ostatus/atom_serializer_spec.rb +++ b/spec/lib/ostatus/atom_serializer_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe Ostatus::AtomSerializer do +RSpec.describe OStatus::AtomSerializer do shared_examples 'follow request salmon' do it 'appends author element with account' do account = Fabricate(:account, domain: nil, username: 'username') @@ -108,7 +108,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'returns XML with emojis' do element = Ox::Element.new('tag') element << '💩' - xml = Ostatus::AtomSerializer.render(element) + xml = OStatus::AtomSerializer.render(element) expect(xml).to eq "\n💩\n" end @@ -116,7 +116,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'returns XML, stripping invalid characters like \b and \v' do element = Ox::Element.new('tag') element << "im l33t\b haxo\b\vr" - xml = Ostatus::AtomSerializer.render(element) + xml = OStatus::AtomSerializer.render(element) expect(xml).to eq "\nim l33t haxor\n" end @@ -127,7 +127,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends poco:note element with note for local account' do account = Fabricate(:account, domain: nil, note: '

note

') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) note = author.nodes.find { |node| node.name == 'poco:note' } expect(note.text).to eq '

note

' @@ -136,7 +136,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends poco:note element with tags-stripped note for remote account' do account = Fabricate(:account, domain: 'remote', note: '

note

') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) note = author.nodes.find { |node| node.name == 'poco:note' } expect(note.text).to eq 'note' @@ -144,7 +144,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends summary element with type attribute and simplified note if present' do account = Fabricate(:account, note: 'note') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) expect(author.summary.text).to eq '

note

' expect(author.summary[:type]).to eq 'html' end @@ -153,27 +153,27 @@ RSpec.describe Ostatus::AtomSerializer do context 'when note is not present' do it 'does not append poco:note element' do account = Fabricate(:account, note: '') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) author.nodes.each { |node| expect(node.name).not_to eq 'poco:note' } end it 'does not append summary element' do account = Fabricate(:account, note: '') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) author.nodes.each { |node| expect(node.name).not_to eq 'summary' } end end it 'returns author element' do account = Fabricate(:account) - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) expect(author.name).to eq 'author' end it 'appends activity:object-type element with person type' do account = Fabricate(:account, domain: nil, username: 'username') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) object_type = author.nodes.find { |node| node.name == 'activity:object-type' } expect(object_type.text).to eq TagManager::TYPES[:person] @@ -181,20 +181,20 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends email element with username and domain for local account' do account = Fabricate(:account, username: 'username') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) expect(author.email.text).to eq 'username@cb6e6126.ngrok.io' end it 'appends email element with username and domain for remote user' do account = Fabricate(:account, domain: 'domain', username: 'username') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) expect(author.email.text).to eq 'username@domain' end it 'appends link element for an alternative' do account = Fabricate(:account, domain: nil, username: 'username') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) link = author.nodes.find { |node| node.name == 'link' && node[:rel] == 'alternate' } expect(link[:type]).to eq 'text/html' @@ -205,7 +205,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'has link element for avatar if present' do account = Fabricate(:account, avatar: attachment_fixture('avatar.gif')) - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) link = author.nodes.find { |node| node.name == 'link' && node[:rel] == 'avatar' } expect(link[:type]).to eq 'image/gif' @@ -217,7 +217,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'does not have link element for avatar if not present' do account = Fabricate(:account, avatar: nil) - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) author.nodes.each do |node| expect(node[:rel]).not_to eq 'avatar' if node.name == 'link' @@ -227,7 +227,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends link element for header if present' do account = Fabricate(:account, header: attachment_fixture('avatar.gif')) - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) link = author.nodes.find { |node| node.name == 'link' && node[:rel] == 'header' } expect(link[:type]).to eq 'image/gif' @@ -239,7 +239,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'does not append link element for header if not present' do account = Fabricate(:account, header: nil) - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) author.nodes.each do |node| expect(node[:rel]).not_to eq 'header' if node.name == 'link' @@ -249,7 +249,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends poco:displayName element with display name if present' do account = Fabricate(:account, display_name: 'display name') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) display_name = author.nodes.find { |node| node.name == 'poco:displayName' } expect(display_name.text).to eq 'display name' @@ -257,14 +257,14 @@ RSpec.describe Ostatus::AtomSerializer do it 'does not append poco:displayName element with display name if not present' do account = Fabricate(:account, display_name: '') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) author.nodes.each { |node| expect(node.name).not_to eq 'poco:displayName' } end it "appends mastodon:scope element with 'private' if locked" do account = Fabricate(:account, locked: true) - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) scope = author.nodes.find { |node| node.name == 'mastodon:scope' } expect(scope.text).to eq 'private' @@ -273,7 +273,7 @@ RSpec.describe Ostatus::AtomSerializer do it "appends mastodon:scope element with 'public' if unlocked" do account = Fabricate(:account, locked: false) - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) scope = author.nodes.find { |node| node.name == 'mastodon:scope' } expect(scope.text).to eq 'public' @@ -282,7 +282,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'includes URI' do account = Fabricate(:account, domain: nil, username: 'username') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) expect(author.id.text).to eq 'https://cb6e6126.ngrok.io/users/username' expect(author.uri.text).to eq 'https://cb6e6126.ngrok.io/users/username' @@ -291,7 +291,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'includes username' do account = Fabricate(:account, username: 'username') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) name = author.nodes.find { |node| node.name == 'name' } username = author.nodes.find { |node| node.name == 'poco:preferredUsername' } @@ -317,7 +317,7 @@ RSpec.describe Ostatus::AtomSerializer do include_examples 'namespaces' do def serialize stream_entry = Fabricate(:stream_entry) - Ostatus::AtomSerializer.new.entry(stream_entry, true) + OStatus::AtomSerializer.new.entry(stream_entry, true) end end @@ -325,7 +325,7 @@ RSpec.describe Ostatus::AtomSerializer do account = Fabricate(:account, username: 'username') status = Fabricate(:status, account: account) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry, true) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry, true) expect(entry.author.id.text).to eq 'https://cb6e6126.ngrok.io/users/username' end @@ -334,14 +334,14 @@ RSpec.describe Ostatus::AtomSerializer do context 'if status is present' do include_examples 'status attributes' do def serialize(status) - Ostatus::AtomSerializer.new.entry(status.stream_entry, true) + OStatus::AtomSerializer.new.entry(status.stream_entry, true) end end it 'appends link element for the public collection if status is publicly visible' do status = Fabricate(:status, visibility: :public) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) mentioned_person = entry.nodes.find do |node| node.name == 'link' && @@ -354,7 +354,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'does not append link element for the public collection if status is not publicly visible' do status = Fabricate(:status, visibility: :private) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) entry.nodes.each do |node| if node.name == 'link' && @@ -369,14 +369,14 @@ RSpec.describe Ostatus::AtomSerializer do tag = Fabricate(:tag, name: 'tag') status = Fabricate(:status, tags: [ tag ]) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) expect(entry.category[:term]).to eq 'tag' end it 'appends category element for NSFW if status is sensitive' do status = Fabricate(:status, sensitive: true) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) expect(entry.category[:term]).to eq 'nsfw' end @@ -385,7 +385,7 @@ RSpec.describe Ostatus::AtomSerializer do media_attachment = Fabricate(:media_attachment, file: file) status = Fabricate(:status, media_attachments: [ media_attachment ]) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) enclosure = entry.nodes.find { |node| node.name == 'link' && node[:rel] == 'enclosure' } expect(enclosure[:type]).to eq 'image/jpeg' @@ -395,7 +395,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends mastodon:scope element with visibility' do status = Fabricate(:status, visibility: :public) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) scope = entry.nodes.find { |node| node.name == 'mastodon:scope' } expect(scope.text).to eq 'public' @@ -406,8 +406,8 @@ RSpec.describe Ostatus::AtomSerializer do remote_status = Fabricate(:status, account: remote_account) remote_status.stream_entry.update!(created_at: '2000-01-01T00:00:00Z') - entry = Ostatus::AtomSerializer.new.entry(remote_status.stream_entry, true) - xml = Ostatus::AtomSerializer.render(entry).gsub('cb6e6126.ngrok.io', 'remote') + entry = OStatus::AtomSerializer.new.entry(remote_status.stream_entry, true) + xml = OStatus::AtomSerializer.render(entry).gsub('cb6e6126.ngrok.io', 'remote') remote_status.destroy! remote_account.destroy! @@ -429,7 +429,7 @@ RSpec.describe Ostatus::AtomSerializer do status = Fabricate(:status) status.destroy! - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) expect(entry.content.text).to eq 'Deleted status' end @@ -439,7 +439,7 @@ RSpec.describe Ostatus::AtomSerializer do status = Fabricate(:status, account: account) status.destroy! - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) expect(entry.title.text).to eq 'username deleted status' end @@ -447,19 +447,19 @@ RSpec.describe Ostatus::AtomSerializer do context 'it is not root' do let(:stream_entry) { Fabricate(:stream_entry) } - subject { Ostatus::AtomSerializer.new.entry(stream_entry, false) } + subject { OStatus::AtomSerializer.new.entry(stream_entry, false) } include_examples 'not root' end context 'without root parameter' do let(:stream_entry) { Fabricate(:stream_entry) } - subject { Ostatus::AtomSerializer.new.entry(stream_entry) } + subject { OStatus::AtomSerializer.new.entry(stream_entry) } include_examples 'not root' end it 'returns entry element' do stream_entry = Fabricate(:stream_entry) - entry = Ostatus::AtomSerializer.new.entry(stream_entry) + entry = OStatus::AtomSerializer.new.entry(stream_entry) expect(entry.name).to eq 'entry' end @@ -467,33 +467,33 @@ RSpec.describe Ostatus::AtomSerializer do status = Fabricate(:status, reblog_of_id: nil) status.stream_entry.update!(created_at: '2000-01-01T00:00:00Z') - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) expect(entry.id.text).to eq "tag:cb6e6126.ngrok.io,2000-01-01:objectId=#{status.id}:objectType=Status" end it 'appends published element with created date' do stream_entry = Fabricate(:stream_entry, created_at: '2000-01-01T00:00:00Z') - entry = Ostatus::AtomSerializer.new.entry(stream_entry) + entry = OStatus::AtomSerializer.new.entry(stream_entry) expect(entry.published.text).to eq '2000-01-01T00:00:00Z' end it 'appends updated element with updated date' do stream_entry = Fabricate(:stream_entry, updated_at: '2000-01-01T00:00:00Z') - entry = Ostatus::AtomSerializer.new.entry(stream_entry) + entry = OStatus::AtomSerializer.new.entry(stream_entry) expect(entry.updated.text).to eq '2000-01-01T00:00:00Z' end it 'appends title element with status title' do account = Fabricate(:account, username: 'username') status = Fabricate(:status, account: account, reblog_of_id: nil) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) expect(entry.title.text).to eq 'New status by username' end it 'appends activity:object-type element with object type' do status = Fabricate(:status) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) object_type = entry.nodes.find { |node| node.name == 'activity:object-type' } expect(object_type.text).to eq TagManager::TYPES[:note] end @@ -501,7 +501,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:verb element with object type' do status = Fabricate(:status) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) object_type = entry.nodes.find { |node| node.name == 'activity:verb' } expect(object_type.text).to eq TagManager::VERBS[:post] @@ -511,7 +511,7 @@ RSpec.describe Ostatus::AtomSerializer do reblogged = Fabricate(:status, created_at: '2000-01-01T00:00:00Z') reblog = Fabricate(:status, reblog: reblogged) - entry = Ostatus::AtomSerializer.new.entry(reblog.stream_entry) + entry = OStatus::AtomSerializer.new.entry(reblog.stream_entry) object = entry.nodes.find { |node| node.name == 'activity:object' } expect(object.id.text).to eq "tag:cb6e6126.ngrok.io,2000-01-01:objectId=#{reblogged.id}:objectType=Status" @@ -519,7 +519,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'does not append activity:object element if target is not present' do status = Fabricate(:status, reblog_of_id: nil) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) entry.nodes.each { |node| expect(node.name).not_to eq 'activity:object' } end @@ -527,7 +527,7 @@ RSpec.describe Ostatus::AtomSerializer do account = Fabricate(:account, username: 'username') status = Fabricate(:status, account: account) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) link = entry.nodes.find { |node| node.name == 'link' && node[:rel] == 'alternate' } expect(link[:type]).to eq 'text/html' @@ -538,7 +538,7 @@ RSpec.describe Ostatus::AtomSerializer do account = Fabricate(:account, username: 'username') status = Fabricate(:status, account: account) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) link = entry.nodes.find { |node| node.name == 'link' && node[:rel] == 'self' } expect(link[:type]).to eq 'application/atom+xml' @@ -549,7 +549,7 @@ RSpec.describe Ostatus::AtomSerializer do in_reply_to_status = Fabricate(:status, created_at: '2000-01-01T00:00:00Z', reblog_of_id: nil) reply_status = Fabricate(:status, in_reply_to_id: in_reply_to_status.id) - entry = Ostatus::AtomSerializer.new.entry(reply_status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(reply_status.stream_entry) in_reply_to = entry.nodes.find { |node| node.name == 'thr:in-reply-to' } expect(in_reply_to[:ref]).to eq "tag:cb6e6126.ngrok.io,2000-01-01:objectId=#{in_reply_to_status.id}:objectType=Status" @@ -557,7 +557,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'does not append thr:in-reply-to element if not threaded' do status = Fabricate(:status) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) entry.nodes.each { |node| expect(node.name).not_to eq 'thr:in-reply-to' } end @@ -565,7 +565,7 @@ RSpec.describe Ostatus::AtomSerializer do status = Fabricate(:status) status.conversation.update!(created_at: '2000-01-01T00:00:00Z') - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) conversation = entry.nodes.find { |node| node.name == 'ostatus:conversation' } expect(conversation[:ref]).to eq "tag:cb6e6126.ngrok.io,2000-01-01:objectId=#{status.conversation_id}:objectType=Conversation" @@ -575,7 +575,7 @@ RSpec.describe Ostatus::AtomSerializer do status = Fabricate.build(:status, conversation_id: nil) status.save!(validate: false) - entry = Ostatus::AtomSerializer.new.entry(status.stream_entry) + entry = OStatus::AtomSerializer.new.entry(status.stream_entry) entry.nodes.each { |node| expect(node.name).not_to eq 'ostatus:conversation' } end @@ -585,62 +585,62 @@ RSpec.describe Ostatus::AtomSerializer do include_examples 'namespaces' do def serialize account = Fabricate(:account) - Ostatus::AtomSerializer.new.feed(account, []) + OStatus::AtomSerializer.new.feed(account, []) end end it 'returns feed element' do account = Fabricate(:account) - feed = Ostatus::AtomSerializer.new.feed(account, []) + feed = OStatus::AtomSerializer.new.feed(account, []) expect(feed.name).to eq 'feed' end it 'appends id element with account Atom URL' do account = Fabricate(:account, username: 'username') - feed = Ostatus::AtomSerializer.new.feed(account, []) + feed = OStatus::AtomSerializer.new.feed(account, []) expect(feed.id.text).to eq 'https://cb6e6126.ngrok.io/users/username.atom' end it 'appends title element with account display name if present' do account = Fabricate(:account, display_name: 'display name') - feed = Ostatus::AtomSerializer.new.feed(account, []) + feed = OStatus::AtomSerializer.new.feed(account, []) expect(feed.title.text).to eq 'display name' end it 'does not append title element with account username if account display name is not present' do account = Fabricate(:account, display_name: '', username: 'username') - feed = Ostatus::AtomSerializer.new.feed(account, []) + feed = OStatus::AtomSerializer.new.feed(account, []) expect(feed.title.text).to eq 'username' end it 'appends subtitle element with account note' do account = Fabricate(:account, note: 'note') - feed = Ostatus::AtomSerializer.new.feed(account, []) + feed = OStatus::AtomSerializer.new.feed(account, []) expect(feed.subtitle.text).to eq 'note' end it 'appends updated element with date account got updated' do account = Fabricate(:account, updated_at: '2000-01-01T00:00:00Z') - feed = Ostatus::AtomSerializer.new.feed(account, []) + feed = OStatus::AtomSerializer.new.feed(account, []) expect(feed.updated.text).to eq '2000-01-01T00:00:00Z' end it 'appends logo element with full asset URL for original account avatar' do account = Fabricate(:account, avatar: attachment_fixture('avatar.gif')) - feed = Ostatus::AtomSerializer.new.feed(account, []) + feed = OStatus::AtomSerializer.new.feed(account, []) expect(feed.logo.text).to match /^https:\/\/cb6e6126.ngrok.io\/system\/accounts\/avatars\/.+\/original\/avatar.gif/ end it 'appends author element' do account = Fabricate(:account, username: 'username') - feed = Ostatus::AtomSerializer.new.feed(account, []) + feed = OStatus::AtomSerializer.new.feed(account, []) expect(feed.author.id.text).to eq 'https://cb6e6126.ngrok.io/users/username' end it 'appends link element for an alternative' do account = Fabricate(:account, username: 'username') - feed = Ostatus::AtomSerializer.new.feed(account, []) + feed = OStatus::AtomSerializer.new.feed(account, []) link = feed.nodes.find { |node| node.name == 'link' && node[:rel] == 'alternate' } expect(link[:type]).to eq 'text/html' @@ -650,7 +650,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends link element for itself' do account = Fabricate(:account, username: 'username') - feed = Ostatus::AtomSerializer.new.feed(account, []) + feed = OStatus::AtomSerializer.new.feed(account, []) link = feed.nodes.find { |node| node.name == 'link' && node[:rel] == 'self' } expect(link[:type]).to eq 'application/atom+xml' @@ -661,7 +661,7 @@ RSpec.describe Ostatus::AtomSerializer do account = Fabricate(:account, username: 'username') stream_entry = Fabricate(:stream_entry) - feed = Ostatus::AtomSerializer.new.feed(account, Array.new(20, stream_entry)) + feed = OStatus::AtomSerializer.new.feed(account, Array.new(20, stream_entry)) link = feed.nodes.find { |node| node.name == 'link' && node[:rel] == 'next' } expect(link[:type]).to eq 'application/atom+xml' @@ -671,7 +671,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'does not append link element for the next if it does not have 20 stream entries' do account = Fabricate(:account, username: 'username') - feed = Ostatus::AtomSerializer.new.feed(account, []) + feed = OStatus::AtomSerializer.new.feed(account, []) feed.nodes.each do |node| expect(node[:rel]).not_to eq 'next' if node.name == 'link' @@ -681,7 +681,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends link element for hub' do account = Fabricate(:account, username: 'username') - feed = Ostatus::AtomSerializer.new.feed(account, []) + feed = OStatus::AtomSerializer.new.feed(account, []) link = feed.nodes.find { |node| node.name == 'link' && node[:rel] == 'hub' } expect(link[:href]).to eq 'https://cb6e6126.ngrok.io/api/push' @@ -690,7 +690,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends link element for Salmon' do account = Fabricate(:account, username: 'username') - feed = Ostatus::AtomSerializer.new.feed(account, []) + feed = OStatus::AtomSerializer.new.feed(account, []) link = feed.nodes.find { |node| node.name == 'link' && node[:rel] == 'salmon' } expect(link[:href]).to start_with 'https://cb6e6126.ngrok.io/api/salmon/' @@ -700,7 +700,7 @@ RSpec.describe Ostatus::AtomSerializer do account = Fabricate(:account, username: 'username') status = Fabricate(:status, account: account) - feed = Ostatus::AtomSerializer.new.feed(account, [status.stream_entry]) + feed = OStatus::AtomSerializer.new.feed(account, [status.stream_entry]) expect(feed.entry.title.text).to eq 'New status by username' end @@ -710,13 +710,13 @@ RSpec.describe Ostatus::AtomSerializer do include_examples 'namespaces' do def serialize block = Fabricate(:block) - Ostatus::AtomSerializer.new.block_salmon(block) + OStatus::AtomSerializer.new.block_salmon(block) end end it 'returns entry element' do block = Fabricate(:block) - block_salmon = Ostatus::AtomSerializer.new.block_salmon(block) + block_salmon = OStatus::AtomSerializer.new.block_salmon(block) expect(block_salmon.name).to eq 'entry' end @@ -724,7 +724,7 @@ RSpec.describe Ostatus::AtomSerializer do block = Fabricate(:block) time_before = Time.now - block_salmon = Ostatus::AtomSerializer.new.block_salmon(block) + block_salmon = OStatus::AtomSerializer.new.block_salmon(block) time_after = Time.now expect(block_salmon.id.text).to( @@ -738,7 +738,7 @@ RSpec.describe Ostatus::AtomSerializer do target_account = Fabricate(:account, domain: 'remote', username: 'target_account') block = Fabricate(:block, account: account, target_account: target_account) - block_salmon = Ostatus::AtomSerializer.new.block_salmon(block) + block_salmon = OStatus::AtomSerializer.new.block_salmon(block) expect(block_salmon.title.text).to eq 'account no longer wishes to interact with target_account@remote' end @@ -747,7 +747,7 @@ RSpec.describe Ostatus::AtomSerializer do account = Fabricate(:account, domain: nil, username: 'account') block = Fabricate(:block, account: account) - block_salmon = Ostatus::AtomSerializer.new.block_salmon(block) + block_salmon = OStatus::AtomSerializer.new.block_salmon(block) expect(block_salmon.author.id.text).to eq 'https://cb6e6126.ngrok.io/users/account' end @@ -755,7 +755,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:object-type element with activity type' do block = Fabricate(:block) - block_salmon = Ostatus::AtomSerializer.new.block_salmon(block) + block_salmon = OStatus::AtomSerializer.new.block_salmon(block) object_type = block_salmon.nodes.find { |node| node.name == 'activity:object-type' } expect(object_type.text).to eq TagManager::TYPES[:activity] @@ -764,7 +764,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:verb element with block' do block = Fabricate(:block) - block_salmon = Ostatus::AtomSerializer.new.block_salmon(block) + block_salmon = OStatus::AtomSerializer.new.block_salmon(block) verb = block_salmon.nodes.find { |node| node.name == 'activity:verb' } expect(verb.text).to eq TagManager::VERBS[:block] @@ -774,7 +774,7 @@ RSpec.describe Ostatus::AtomSerializer do target_account = Fabricate(:account, domain: 'domain', uri: 'https://domain/id') block = Fabricate(:block, target_account: target_account) - block_salmon = Ostatus::AtomSerializer.new.block_salmon(block) + block_salmon = OStatus::AtomSerializer.new.block_salmon(block) object = block_salmon.nodes.find { |node| node.name == 'activity:object' } expect(object.id.text).to eq 'https://domain/id' @@ -782,8 +782,8 @@ RSpec.describe Ostatus::AtomSerializer do it 'returns element whose rendered view triggers block when processed' do block = Fabricate(:block) - block_salmon = Ostatus::AtomSerializer.new.block_salmon(block) - xml = Ostatus::AtomSerializer.render(block_salmon) + block_salmon = OStatus::AtomSerializer.new.block_salmon(block) + xml = OStatus::AtomSerializer.render(block_salmon) envelope = OStatus2::Salmon.new.pack(xml, block.account.keypair) block.destroy! @@ -797,13 +797,13 @@ RSpec.describe Ostatus::AtomSerializer do include_examples 'namespaces' do def serialize block = Fabricate(:block) - Ostatus::AtomSerializer.new.unblock_salmon(block) + OStatus::AtomSerializer.new.unblock_salmon(block) end end it 'returns entry element' do block = Fabricate(:block) - unblock_salmon = Ostatus::AtomSerializer.new.unblock_salmon(block) + unblock_salmon = OStatus::AtomSerializer.new.unblock_salmon(block) expect(unblock_salmon.name).to eq 'entry' end @@ -811,7 +811,7 @@ RSpec.describe Ostatus::AtomSerializer do block = Fabricate(:block) time_before = Time.now - unblock_salmon = Ostatus::AtomSerializer.new.unblock_salmon(block) + unblock_salmon = OStatus::AtomSerializer.new.unblock_salmon(block) time_after = Time.now expect(unblock_salmon.id.text).to( @@ -825,7 +825,7 @@ RSpec.describe Ostatus::AtomSerializer do target_account = Fabricate(:account, domain: 'remote', username: 'target_account') block = Fabricate(:block, account: account, target_account: target_account) - unblock_salmon = Ostatus::AtomSerializer.new.unblock_salmon(block) + unblock_salmon = OStatus::AtomSerializer.new.unblock_salmon(block) expect(unblock_salmon.title.text).to eq 'account no longer blocks target_account@remote' end @@ -834,7 +834,7 @@ RSpec.describe Ostatus::AtomSerializer do account = Fabricate(:account, domain: nil, username: 'account') block = Fabricate(:block, account: account) - unblock_salmon = Ostatus::AtomSerializer.new.unblock_salmon(block) + unblock_salmon = OStatus::AtomSerializer.new.unblock_salmon(block) expect(unblock_salmon.author.id.text).to eq 'https://cb6e6126.ngrok.io/users/account' end @@ -842,7 +842,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:object-type element with activity type' do block = Fabricate(:block) - unblock_salmon = Ostatus::AtomSerializer.new.unblock_salmon(block) + unblock_salmon = OStatus::AtomSerializer.new.unblock_salmon(block) object_type = unblock_salmon.nodes.find { |node| node.name == 'activity:object-type' } expect(object_type.text).to eq TagManager::TYPES[:activity] @@ -851,7 +851,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:verb element with block' do block = Fabricate(:block) - unblock_salmon = Ostatus::AtomSerializer.new.unblock_salmon(block) + unblock_salmon = OStatus::AtomSerializer.new.unblock_salmon(block) verb = unblock_salmon.nodes.find { |node| node.name == 'activity:verb' } expect(verb.text).to eq TagManager::VERBS[:unblock] @@ -861,7 +861,7 @@ RSpec.describe Ostatus::AtomSerializer do target_account = Fabricate(:account, domain: 'domain', uri: 'https://domain/id') block = Fabricate(:block, target_account: target_account) - unblock_salmon = Ostatus::AtomSerializer.new.unblock_salmon(block) + unblock_salmon = OStatus::AtomSerializer.new.unblock_salmon(block) object = unblock_salmon.nodes.find { |node| node.name == 'activity:object' } expect(object.id.text).to eq 'https://domain/id' @@ -869,8 +869,8 @@ RSpec.describe Ostatus::AtomSerializer do it 'returns element whose rendered view triggers block when processed' do block = Fabricate(:block) - unblock_salmon = Ostatus::AtomSerializer.new.unblock_salmon(block) - xml = Ostatus::AtomSerializer.render(unblock_salmon) + unblock_salmon = OStatus::AtomSerializer.new.unblock_salmon(block) + xml = OStatus::AtomSerializer.render(unblock_salmon) envelope = OStatus2::Salmon.new.pack(xml, block.account.keypair) ProcessInteractionService.new.call(envelope, block.target_account) @@ -883,19 +883,19 @@ RSpec.describe Ostatus::AtomSerializer do include_examples 'namespaces' do def serialize favourite = Fabricate(:favourite) - Ostatus::AtomSerializer.new.favourite_salmon(favourite) + OStatus::AtomSerializer.new.favourite_salmon(favourite) end end it 'returns entry element' do favourite = Fabricate(:favourite) - favourite_salmon = Ostatus::AtomSerializer.new.favourite_salmon(favourite) + favourite_salmon = OStatus::AtomSerializer.new.favourite_salmon(favourite) expect(favourite_salmon.name).to eq 'entry' end it 'appends id element with unique tag' do favourite = Fabricate(:favourite, created_at: '2000-01-01T00:00:00Z') - favourite_salmon = Ostatus::AtomSerializer.new.favourite_salmon(favourite) + favourite_salmon = OStatus::AtomSerializer.new.favourite_salmon(favourite) expect(favourite_salmon.id.text).to eq "tag:cb6e6126.ngrok.io,2000-01-01:objectId=#{favourite.id}:objectType=Favourite" end @@ -903,7 +903,7 @@ RSpec.describe Ostatus::AtomSerializer do account = Fabricate(:account, domain: nil, username: 'username') favourite = Fabricate(:favourite, account: account) - favourite_salmon = Ostatus::AtomSerializer.new.favourite_salmon(favourite) + favourite_salmon = OStatus::AtomSerializer.new.favourite_salmon(favourite) expect(favourite_salmon.author.id.text).to eq 'https://cb6e6126.ngrok.io/users/username' end @@ -911,7 +911,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:object-type element with activity type' do favourite = Fabricate(:favourite) - favourite_salmon = Ostatus::AtomSerializer.new.favourite_salmon(favourite) + favourite_salmon = OStatus::AtomSerializer.new.favourite_salmon(favourite) object_type = favourite_salmon.nodes.find { |node| node.name == 'activity:object-type' } expect(object_type.text).to eq 'http://activitystrea.ms/schema/1.0/activity' @@ -920,7 +920,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:verb element with favorite' do favourite = Fabricate(:favourite) - favourite_salmon = Ostatus::AtomSerializer.new.favourite_salmon(favourite) + favourite_salmon = OStatus::AtomSerializer.new.favourite_salmon(favourite) verb = favourite_salmon.nodes.find { |node| node.name == 'activity:verb' } expect(verb.text).to eq TagManager::VERBS[:favorite] @@ -930,7 +930,7 @@ RSpec.describe Ostatus::AtomSerializer do status = Fabricate(:status, created_at: '2000-01-01T00:00:00Z') favourite = Fabricate(:favourite, status: status) - favourite_salmon = Ostatus::AtomSerializer.new.favourite_salmon(favourite) + favourite_salmon = OStatus::AtomSerializer.new.favourite_salmon(favourite) object = favourite_salmon.nodes.find { |node| node.name == 'activity:object' } expect(object.id.text).to eq "tag:cb6e6126.ngrok.io,2000-01-01:objectId=#{status.id}:objectType=Status" @@ -941,7 +941,7 @@ RSpec.describe Ostatus::AtomSerializer do status = Fabricate(:status, account: status_account, created_at: '2000-01-01T00:00:00Z') favourite = Fabricate(:favourite, status: status) - favourite_salmon = Ostatus::AtomSerializer.new.favourite_salmon(favourite) + favourite_salmon = OStatus::AtomSerializer.new.favourite_salmon(favourite) in_reply_to = favourite_salmon.nodes.find { |node| node.name == 'thr:in-reply-to' } expect(in_reply_to.ref).to eq "tag:cb6e6126.ngrok.io,2000-01-01:objectId=#{status.id}:objectType=Status" @@ -954,7 +954,7 @@ RSpec.describe Ostatus::AtomSerializer do status = Fabricate(:status, account: status_account) favourite = Fabricate(:favourite, account: account, status: status) - favourite_salmon = Ostatus::AtomSerializer.new.favourite_salmon(favourite) + favourite_salmon = OStatus::AtomSerializer.new.favourite_salmon(favourite) expect(favourite_salmon.title.text).to eq 'account favourited a status by status_account@remote' expect(favourite_salmon.content.text).to eq 'account favourited a status by status_account@remote' @@ -962,8 +962,8 @@ RSpec.describe Ostatus::AtomSerializer do it 'returns element whose rendered view triggers favourite when processed' do favourite = Fabricate(:favourite) - favourite_salmon = Ostatus::AtomSerializer.new.favourite_salmon(favourite) - xml = Ostatus::AtomSerializer.render(favourite_salmon) + favourite_salmon = OStatus::AtomSerializer.new.favourite_salmon(favourite) + xml = OStatus::AtomSerializer.render(favourite_salmon) envelope = OStatus2::Salmon.new.pack(xml, favourite.account.keypair) favourite.destroy! @@ -976,13 +976,13 @@ RSpec.describe Ostatus::AtomSerializer do include_examples 'namespaces' do def serialize favourite = Fabricate(:favourite) - Ostatus::AtomSerializer.new.favourite_salmon(favourite) + OStatus::AtomSerializer.new.favourite_salmon(favourite) end end it 'returns entry element' do favourite = Fabricate(:favourite) - unfavourite_salmon = Ostatus::AtomSerializer.new.unfavourite_salmon(favourite) + unfavourite_salmon = OStatus::AtomSerializer.new.unfavourite_salmon(favourite) expect(unfavourite_salmon.name).to eq 'entry' end @@ -990,7 +990,7 @@ RSpec.describe Ostatus::AtomSerializer do favourite = Fabricate(:favourite) time_before = Time.now - unfavourite_salmon = Ostatus::AtomSerializer.new.unfavourite_salmon(favourite) + unfavourite_salmon = OStatus::AtomSerializer.new.unfavourite_salmon(favourite) time_after = Time.now expect(unfavourite_salmon.id.text).to( @@ -1003,7 +1003,7 @@ RSpec.describe Ostatus::AtomSerializer do account = Fabricate(:account, domain: nil, username: 'username') favourite = Fabricate(:favourite, account: account) - unfavourite_salmon = Ostatus::AtomSerializer.new.unfavourite_salmon(favourite) + unfavourite_salmon = OStatus::AtomSerializer.new.unfavourite_salmon(favourite) expect(unfavourite_salmon.author.id.text).to eq 'https://cb6e6126.ngrok.io/users/username' end @@ -1011,7 +1011,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:object-type element with activity type' do favourite = Fabricate(:favourite) - unfavourite_salmon = Ostatus::AtomSerializer.new.unfavourite_salmon(favourite) + unfavourite_salmon = OStatus::AtomSerializer.new.unfavourite_salmon(favourite) object_type = unfavourite_salmon.nodes.find { |node| node.name == 'activity:object-type' } expect(object_type.text).to eq 'http://activitystrea.ms/schema/1.0/activity' @@ -1020,7 +1020,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:verb element with favorite' do favourite = Fabricate(:favourite) - unfavourite_salmon = Ostatus::AtomSerializer.new.unfavourite_salmon(favourite) + unfavourite_salmon = OStatus::AtomSerializer.new.unfavourite_salmon(favourite) verb = unfavourite_salmon.nodes.find { |node| node.name == 'activity:verb' } expect(verb.text).to eq TagManager::VERBS[:unfavorite] @@ -1030,7 +1030,7 @@ RSpec.describe Ostatus::AtomSerializer do status = Fabricate(:status, created_at: '2000-01-01T00:00:00Z') favourite = Fabricate(:favourite, status: status) - unfavourite_salmon = Ostatus::AtomSerializer.new.unfavourite_salmon(favourite) + unfavourite_salmon = OStatus::AtomSerializer.new.unfavourite_salmon(favourite) object = unfavourite_salmon.nodes.find { |node| node.name == 'activity:object' } expect(object.id.text).to eq "tag:cb6e6126.ngrok.io,2000-01-01:objectId=#{status.id}:objectType=Status" @@ -1041,7 +1041,7 @@ RSpec.describe Ostatus::AtomSerializer do status = Fabricate(:status, account: status_account, created_at: '2000-01-01T00:00:00Z') favourite = Fabricate(:favourite, status: status) - unfavourite_salmon = Ostatus::AtomSerializer.new.unfavourite_salmon(favourite) + unfavourite_salmon = OStatus::AtomSerializer.new.unfavourite_salmon(favourite) in_reply_to = unfavourite_salmon.nodes.find { |node| node.name == 'thr:in-reply-to' } expect(in_reply_to.ref).to eq "tag:cb6e6126.ngrok.io,2000-01-01:objectId=#{status.id}:objectType=Status" @@ -1054,7 +1054,7 @@ RSpec.describe Ostatus::AtomSerializer do status = Fabricate(:status, account: status_account) favourite = Fabricate(:favourite, account: account, status: status) - unfavourite_salmon = Ostatus::AtomSerializer.new.unfavourite_salmon(favourite) + unfavourite_salmon = OStatus::AtomSerializer.new.unfavourite_salmon(favourite) expect(unfavourite_salmon.title.text).to eq 'account no longer favourites a status by status_account@remote' expect(unfavourite_salmon.content.text).to eq 'account no longer favourites a status by status_account@remote' @@ -1062,8 +1062,8 @@ RSpec.describe Ostatus::AtomSerializer do it 'returns element whose rendered view triggers unfavourite when processed' do favourite = Fabricate(:favourite) - unfavourite_salmon = Ostatus::AtomSerializer.new.unfavourite_salmon(favourite) - xml = Ostatus::AtomSerializer.render(unfavourite_salmon) + unfavourite_salmon = OStatus::AtomSerializer.new.unfavourite_salmon(favourite) + xml = OStatus::AtomSerializer.render(unfavourite_salmon) envelope = OStatus2::Salmon.new.pack(xml, favourite.account.keypair) ProcessInteractionService.new.call(envelope, favourite.status.account) @@ -1075,19 +1075,19 @@ RSpec.describe Ostatus::AtomSerializer do include_examples 'namespaces' do def serialize follow = Fabricate(:follow) - Ostatus::AtomSerializer.new.follow_salmon(follow) + OStatus::AtomSerializer.new.follow_salmon(follow) end end it 'returns entry element' do follow = Fabricate(:follow) - follow_salmon = Ostatus::AtomSerializer.new.follow_salmon(follow) + follow_salmon = OStatus::AtomSerializer.new.follow_salmon(follow) expect(follow_salmon.name).to eq 'entry' end it 'appends id element with unique tag' do follow = Fabricate(:follow, created_at: '2000-01-01T00:00:00Z') - follow_salmon = Ostatus::AtomSerializer.new.follow_salmon(follow) + follow_salmon = OStatus::AtomSerializer.new.follow_salmon(follow) expect(follow_salmon.id.text).to eq "tag:cb6e6126.ngrok.io,2000-01-01:objectId=#{follow.id}:objectType=Follow" end @@ -1095,7 +1095,7 @@ RSpec.describe Ostatus::AtomSerializer do account = Fabricate(:account, domain: nil, username: 'username') follow = Fabricate(:follow, account: account) - follow_salmon = Ostatus::AtomSerializer.new.follow_salmon(follow) + follow_salmon = OStatus::AtomSerializer.new.follow_salmon(follow) expect(follow_salmon.author.id.text).to eq 'https://cb6e6126.ngrok.io/users/username' end @@ -1103,7 +1103,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:object-type element with activity type' do follow = Fabricate(:follow) - follow_salmon = Ostatus::AtomSerializer.new.follow_salmon(follow) + follow_salmon = OStatus::AtomSerializer.new.follow_salmon(follow) object_type = follow_salmon.nodes.find { |node| node.name == 'activity:object-type' } expect(object_type.text).to eq TagManager::TYPES[:activity] @@ -1112,7 +1112,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:verb element with follow' do follow = Fabricate(:follow) - follow_salmon = Ostatus::AtomSerializer.new.follow_salmon(follow) + follow_salmon = OStatus::AtomSerializer.new.follow_salmon(follow) verb = follow_salmon.nodes.find { |node| node.name == 'activity:verb' } expect(verb.text).to eq TagManager::VERBS[:follow] @@ -1122,7 +1122,7 @@ RSpec.describe Ostatus::AtomSerializer do target_account = Fabricate(:account, domain: 'domain', uri: 'https://domain/id') follow = Fabricate(:follow, target_account: target_account) - follow_salmon = Ostatus::AtomSerializer.new.follow_salmon(follow) + follow_salmon = OStatus::AtomSerializer.new.follow_salmon(follow) object = follow_salmon.nodes.find { |node| node.name == 'activity:object' } expect(object.id.text).to eq 'https://domain/id' @@ -1133,7 +1133,7 @@ RSpec.describe Ostatus::AtomSerializer do target_account = Fabricate(:account, domain: 'remote', username: 'target_account') follow = Fabricate(:follow, account: account, target_account: target_account) - follow_salmon = Ostatus::AtomSerializer.new.follow_salmon(follow) + follow_salmon = OStatus::AtomSerializer.new.follow_salmon(follow) expect(follow_salmon.title.text).to eq 'account started following target_account@remote' expect(follow_salmon.content.text).to eq 'account started following target_account@remote' @@ -1141,8 +1141,8 @@ RSpec.describe Ostatus::AtomSerializer do it 'returns element whose rendered view triggers follow when processed' do follow = Fabricate(:follow) - follow_salmon = Ostatus::AtomSerializer.new.follow_salmon(follow) - xml = Ostatus::AtomSerializer.render(follow_salmon) + follow_salmon = OStatus::AtomSerializer.new.follow_salmon(follow) + xml = OStatus::AtomSerializer.render(follow_salmon) follow.destroy! envelope = OStatus2::Salmon.new.pack(xml, follow.account.keypair) @@ -1157,7 +1157,7 @@ RSpec.describe Ostatus::AtomSerializer do def serialize follow = Fabricate(:follow) follow.destroy! - Ostatus::AtomSerializer.new.unfollow_salmon(follow) + OStatus::AtomSerializer.new.unfollow_salmon(follow) end end @@ -1165,7 +1165,7 @@ RSpec.describe Ostatus::AtomSerializer do follow = Fabricate(:follow) follow.destroy! - unfollow_salmon = Ostatus::AtomSerializer.new.unfollow_salmon(follow) + unfollow_salmon = OStatus::AtomSerializer.new.unfollow_salmon(follow) expect(unfollow_salmon.name).to eq 'entry' end @@ -1175,7 +1175,7 @@ RSpec.describe Ostatus::AtomSerializer do follow.destroy! time_before = Time.now - unfollow_salmon = Ostatus::AtomSerializer.new.unfollow_salmon(follow) + unfollow_salmon = OStatus::AtomSerializer.new.unfollow_salmon(follow) time_after = Time.now expect(unfollow_salmon.id.text).to( @@ -1190,7 +1190,7 @@ RSpec.describe Ostatus::AtomSerializer do follow = Fabricate(:follow, account: account, target_account: target_account) follow.destroy! - unfollow_salmon = Ostatus::AtomSerializer.new.unfollow_salmon(follow) + unfollow_salmon = OStatus::AtomSerializer.new.unfollow_salmon(follow) expect(unfollow_salmon.title.text).to eq 'account is no longer following target_account@remote' end @@ -1201,7 +1201,7 @@ RSpec.describe Ostatus::AtomSerializer do follow = Fabricate(:follow, account: account, target_account: target_account) follow.destroy! - unfollow_salmon = Ostatus::AtomSerializer.new.unfollow_salmon(follow) + unfollow_salmon = OStatus::AtomSerializer.new.unfollow_salmon(follow) expect(unfollow_salmon.content.text).to eq 'account is no longer following target_account@remote' end @@ -1211,7 +1211,7 @@ RSpec.describe Ostatus::AtomSerializer do follow = Fabricate(:follow, account: account) follow.destroy! - unfollow_salmon = Ostatus::AtomSerializer.new.unfollow_salmon(follow) + unfollow_salmon = OStatus::AtomSerializer.new.unfollow_salmon(follow) expect(unfollow_salmon.author.id.text).to eq 'https://cb6e6126.ngrok.io/users/username' end @@ -1220,7 +1220,7 @@ RSpec.describe Ostatus::AtomSerializer do follow = Fabricate(:follow) follow.destroy! - unfollow_salmon = Ostatus::AtomSerializer.new.unfollow_salmon(follow) + unfollow_salmon = OStatus::AtomSerializer.new.unfollow_salmon(follow) object_type = unfollow_salmon.nodes.find { |node| node.name == 'activity:object-type' } expect(object_type.text).to eq TagManager::TYPES[:activity] @@ -1230,7 +1230,7 @@ RSpec.describe Ostatus::AtomSerializer do follow = Fabricate(:follow) follow.destroy! - unfollow_salmon = Ostatus::AtomSerializer.new.unfollow_salmon(follow) + unfollow_salmon = OStatus::AtomSerializer.new.unfollow_salmon(follow) verb = unfollow_salmon.nodes.find { |node| node.name == 'activity:verb' } expect(verb.text).to eq TagManager::VERBS[:unfollow] @@ -1241,7 +1241,7 @@ RSpec.describe Ostatus::AtomSerializer do follow = Fabricate(:follow, target_account: target_account) follow.destroy! - unfollow_salmon = Ostatus::AtomSerializer.new.unfollow_salmon(follow) + unfollow_salmon = OStatus::AtomSerializer.new.unfollow_salmon(follow) object = unfollow_salmon.nodes.find { |node| node.name == 'activity:object' } expect(object.id.text).to eq 'https://domain/id' @@ -1250,8 +1250,8 @@ RSpec.describe Ostatus::AtomSerializer do it 'returns element whose rendered view triggers unfollow when processed' do follow = Fabricate(:follow) follow.destroy! - unfollow_salmon = Ostatus::AtomSerializer.new.unfollow_salmon(follow) - xml = Ostatus::AtomSerializer.render(unfollow_salmon) + unfollow_salmon = OStatus::AtomSerializer.new.unfollow_salmon(follow) + xml = OStatus::AtomSerializer.render(unfollow_salmon) follow.account.follow!(follow.target_account) envelope = OStatus2::Salmon.new.pack(xml, follow.account.keypair) @@ -1265,13 +1265,13 @@ RSpec.describe Ostatus::AtomSerializer do include_examples 'namespaces' do def serialize follow_request = Fabricate(:follow_request) - Ostatus::AtomSerializer.new.follow_request_salmon(follow_request) + OStatus::AtomSerializer.new.follow_request_salmon(follow_request) end end context do def serialize(follow_request) - Ostatus::AtomSerializer.new.follow_request_salmon(follow_request) + OStatus::AtomSerializer.new.follow_request_salmon(follow_request) end it_behaves_like 'follow request salmon' @@ -1293,7 +1293,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'returns element whose rendered view triggers follow request when processed' do follow_request = Fabricate(:follow_request) follow_request_salmon = serialize(follow_request) - xml = Ostatus::AtomSerializer.render(follow_request_salmon) + xml = OStatus::AtomSerializer.render(follow_request_salmon) envelope = OStatus2::Salmon.new.pack(xml, follow_request.account.keypair) follow_request.destroy! @@ -1308,13 +1308,13 @@ RSpec.describe Ostatus::AtomSerializer do include_examples 'namespaces' do def serialize follow_request = Fabricate(:follow_request) - Ostatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request) + OStatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request) end end it_behaves_like 'follow request salmon' do def serialize(follow_request) - authorize_follow_request_salmon = Ostatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request) + authorize_follow_request_salmon = OStatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request) authorize_follow_request_salmon.nodes.find { |node| node.name == 'activity:object' } end end @@ -1323,7 +1323,7 @@ RSpec.describe Ostatus::AtomSerializer do follow_request = Fabricate(:follow_request) time_before = Time.now - authorize_follow_request_salmon = Ostatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request) + authorize_follow_request_salmon = OStatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request) time_after = Time.now expect(authorize_follow_request_salmon.id.text).to( @@ -1337,7 +1337,7 @@ RSpec.describe Ostatus::AtomSerializer do target_account = Fabricate(:account, domain: nil, username: 'target_account') follow_request = Fabricate(:follow_request, account: account, target_account: target_account) - authorize_follow_request_salmon = Ostatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request) + authorize_follow_request_salmon = OStatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request) expect(authorize_follow_request_salmon.title.text).to eq 'target_account authorizes follow request by account@remote' end @@ -1345,7 +1345,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:object-type element with activity type' do follow_request = Fabricate(:follow_request) - authorize_follow_request_salmon = Ostatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request) + authorize_follow_request_salmon = OStatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request) object_type = authorize_follow_request_salmon.nodes.find { |node| node.name == 'activity:object-type' } expect(object_type.text).to eq TagManager::TYPES[:activity] @@ -1354,7 +1354,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:verb element with authorize' do follow_request = Fabricate(:follow_request) - authorize_follow_request_salmon = Ostatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request) + authorize_follow_request_salmon = OStatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request) verb = authorize_follow_request_salmon.nodes.find { |node| node.name == 'activity:verb' } expect(verb.text).to eq TagManager::VERBS[:authorize] @@ -1362,8 +1362,8 @@ RSpec.describe Ostatus::AtomSerializer do it 'returns element whose rendered view creates follow from follow request when processed' do follow_request = Fabricate(:follow_request) - authorize_follow_request_salmon = Ostatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request) - xml = Ostatus::AtomSerializer.render(authorize_follow_request_salmon) + authorize_follow_request_salmon = OStatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request) + xml = OStatus::AtomSerializer.render(authorize_follow_request_salmon) envelope = OStatus2::Salmon.new.pack(xml, follow_request.target_account.keypair) ProcessInteractionService.new.call(envelope, follow_request.account) @@ -1377,13 +1377,13 @@ RSpec.describe Ostatus::AtomSerializer do include_examples 'namespaces' do def serialize follow_request = Fabricate(:follow_request) - Ostatus::AtomSerializer.new.reject_follow_request_salmon(follow_request) + OStatus::AtomSerializer.new.reject_follow_request_salmon(follow_request) end end it_behaves_like 'follow request salmon' do def serialize(follow_request) - reject_follow_request_salmon = Ostatus::AtomSerializer.new.reject_follow_request_salmon(follow_request) + reject_follow_request_salmon = OStatus::AtomSerializer.new.reject_follow_request_salmon(follow_request) reject_follow_request_salmon.nodes.find { |node| node.name == 'activity:object' } end end @@ -1392,7 +1392,7 @@ RSpec.describe Ostatus::AtomSerializer do follow_request = Fabricate(:follow_request) time_before = Time.now - reject_follow_request_salmon = Ostatus::AtomSerializer.new.reject_follow_request_salmon(follow_request) + reject_follow_request_salmon = OStatus::AtomSerializer.new.reject_follow_request_salmon(follow_request) time_after = Time.now expect(reject_follow_request_salmon.id.text).to( @@ -1405,28 +1405,28 @@ RSpec.describe Ostatus::AtomSerializer do account = Fabricate(:account, domain: 'remote', username: 'account') target_account = Fabricate(:account, domain: nil, username: 'target_account') follow_request = Fabricate(:follow_request, account: account, target_account: target_account) - reject_follow_request_salmon = Ostatus::AtomSerializer.new.reject_follow_request_salmon(follow_request) + reject_follow_request_salmon = OStatus::AtomSerializer.new.reject_follow_request_salmon(follow_request) expect(reject_follow_request_salmon.title.text).to eq 'target_account rejects follow request by account@remote' end it 'appends activity:object-type element with activity type' do follow_request = Fabricate(:follow_request) - reject_follow_request_salmon = Ostatus::AtomSerializer.new.reject_follow_request_salmon(follow_request) + reject_follow_request_salmon = OStatus::AtomSerializer.new.reject_follow_request_salmon(follow_request) object_type = reject_follow_request_salmon.nodes.find { |node| node.name == 'activity:object-type' } expect(object_type.text).to eq TagManager::TYPES[:activity] end it 'appends activity:verb element with authorize' do follow_request = Fabricate(:follow_request) - reject_follow_request_salmon = Ostatus::AtomSerializer.new.reject_follow_request_salmon(follow_request) + reject_follow_request_salmon = OStatus::AtomSerializer.new.reject_follow_request_salmon(follow_request) verb = reject_follow_request_salmon.nodes.find { |node| node.name == 'activity:verb' } expect(verb.text).to eq TagManager::VERBS[:reject] end it 'returns element whose rendered view deletes follow request when processed' do follow_request = Fabricate(:follow_request) - reject_follow_request_salmon = Ostatus::AtomSerializer.new.reject_follow_request_salmon(follow_request) - xml = Ostatus::AtomSerializer.render(reject_follow_request_salmon) + reject_follow_request_salmon = OStatus::AtomSerializer.new.reject_follow_request_salmon(follow_request) + xml = OStatus::AtomSerializer.render(reject_follow_request_salmon) envelope = OStatus2::Salmon.new.pack(xml, follow_request.target_account.keypair) ProcessInteractionService.new.call(envelope, follow_request.account) @@ -1439,31 +1439,31 @@ RSpec.describe Ostatus::AtomSerializer do describe '#object' do include_examples 'status attributes' do def serialize(status) - Ostatus::AtomSerializer.new.object(status) + OStatus::AtomSerializer.new.object(status) end end it 'returns activity:object element' do status = Fabricate(:status) - object = Ostatus::AtomSerializer.new.object(status) + object = OStatus::AtomSerializer.new.object(status) expect(object.name).to eq 'activity:object' end it 'appends id element with URL for status' do status = Fabricate(:status, created_at: '2000-01-01T00:00:00Z') - object = Ostatus::AtomSerializer.new.object(status) + object = OStatus::AtomSerializer.new.object(status) expect(object.id.text).to eq "tag:cb6e6126.ngrok.io,2000-01-01:objectId=#{status.id}:objectType=Status" end it 'appends published element with created date' do status = Fabricate(:status, created_at: '2000-01-01T00:00:00Z') - object = Ostatus::AtomSerializer.new.object(status) + object = OStatus::AtomSerializer.new.object(status) expect(object.published.text).to eq '2000-01-01T00:00:00Z' end it 'appends updated element with updated date' do status = Fabricate(:status, updated_at: '2000-01-01T00:00:00Z') - object = Ostatus::AtomSerializer.new.object(status) + object = OStatus::AtomSerializer.new.object(status) expect(object.updated.text).to eq '2000-01-01T00:00:00Z' end @@ -1471,7 +1471,7 @@ RSpec.describe Ostatus::AtomSerializer do account = Fabricate(:account, username: 'username') status = Fabricate(:status, account: account) - object = Ostatus::AtomSerializer.new.object(status) + object = OStatus::AtomSerializer.new.object(status) expect(object.title.text).to eq 'New status by username' end @@ -1480,7 +1480,7 @@ RSpec.describe Ostatus::AtomSerializer do account = Fabricate(:account, username: 'username') status = Fabricate(:status, account: account) - entry = Ostatus::AtomSerializer.new.object(status) + entry = OStatus::AtomSerializer.new.object(status) expect(entry.author.id.text).to eq 'https://cb6e6126.ngrok.io/users/username' end @@ -1488,7 +1488,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:object-type element with object type' do status = Fabricate(:status) - entry = Ostatus::AtomSerializer.new.object(status) + entry = OStatus::AtomSerializer.new.object(status) object_type = entry.nodes.find { |node| node.name == 'activity:object-type' } expect(object_type.text).to eq TagManager::TYPES[:note] @@ -1497,7 +1497,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends activity:verb element with verb' do status = Fabricate(:status) - entry = Ostatus::AtomSerializer.new.object(status) + entry = OStatus::AtomSerializer.new.object(status) object_type = entry.nodes.find { |node| node.name == 'activity:verb' } expect(object_type.text).to eq TagManager::VERBS[:post] @@ -1507,7 +1507,7 @@ RSpec.describe Ostatus::AtomSerializer do account = Fabricate(:account, username: 'username') status = Fabricate(:status, account: account) - entry = Ostatus::AtomSerializer.new.object(status) + entry = OStatus::AtomSerializer.new.object(status) link = entry.nodes.find { |node| node.name == 'link' && node[:rel] == 'alternate' } expect(link[:type]).to eq 'text/html' @@ -1519,7 +1519,7 @@ RSpec.describe Ostatus::AtomSerializer do thread = Fabricate(:status, account: account, created_at: '2000-01-01T00:00:00Z') reply = Fabricate(:status, thread: thread) - entry = Ostatus::AtomSerializer.new.object(reply) + entry = OStatus::AtomSerializer.new.object(reply) in_reply_to = entry.nodes.find { |node| node.name == 'thr:in-reply-to' } expect(in_reply_to.ref).to eq "tag:cb6e6126.ngrok.io,2000-01-01:objectId=#{thread.id}:objectType=Status" @@ -1528,7 +1528,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'does not append thr:in-reply-to element if thread is nil' do status = Fabricate(:status, thread: nil) - entry = Ostatus::AtomSerializer.new.object(status) + entry = OStatus::AtomSerializer.new.object(status) entry.nodes.each { |node| expect(node.name).not_to eq 'thr:in-reply-to' } end @@ -1536,7 +1536,7 @@ RSpec.describe Ostatus::AtomSerializer do status = Fabricate.build(:status, conversation_id: nil) status.save!(validate: false) - entry = Ostatus::AtomSerializer.new.object(status) + entry = OStatus::AtomSerializer.new.object(status) entry.nodes.each { |node| expect(node.name).not_to eq 'ostatus:conversation' } end @@ -1545,7 +1545,7 @@ RSpec.describe Ostatus::AtomSerializer do status = Fabricate(:status) status.conversation.update!(created_at: '2000-01-01T00:00:00Z') - entry = Ostatus::AtomSerializer.new.object(status) + entry = OStatus::AtomSerializer.new.object(status) conversation = entry.nodes.find { |node| node.name == 'ostatus:conversation' } expect(conversation[:ref]).to eq "tag:cb6e6126.ngrok.io,2000-01-01:objectId=#{status.conversation.id}:objectType=Conversation" From 9392d1025085ad51d242e9df7a0d5acb244b9d92 Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Wed, 19 Jul 2017 11:59:04 +0900 Subject: [PATCH 05/20] Add feature to revoke sessions (#4259) --- app/controllers/settings/sessions_controller.rb | 17 +++++++++++++++++ .../auth/registrations/_sessions.html.haml | 4 ++++ config/locales/en.yml | 2 ++ config/routes.rb | 2 ++ 4 files changed, 25 insertions(+) create mode 100644 app/controllers/settings/sessions_controller.rb diff --git a/app/controllers/settings/sessions_controller.rb b/app/controllers/settings/sessions_controller.rb new file mode 100644 index 0000000000..0da1b027b8 --- /dev/null +++ b/app/controllers/settings/sessions_controller.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class Settings::SessionsController < ApplicationController + before_action :set_session, only: :destroy + + def destroy + @session.destroy! + flash[:notice] = I18n.t('sessions.revoke_success') + redirect_to edit_user_registration_path + end + + private + + def set_session + @session = current_user.session_activations.find(params[:id]) + end +end diff --git a/app/views/auth/registrations/_sessions.html.haml b/app/views/auth/registrations/_sessions.html.haml index 4521aad0a2..84207862ad 100644 --- a/app/views/auth/registrations/_sessions.html.haml +++ b/app/views/auth/registrations/_sessions.html.haml @@ -7,6 +7,7 @@ %th= t 'sessions.browser' %th= t 'sessions.ip' %th= t 'sessions.activity' + %td %tbody - @sessions.each do |session| %tr @@ -22,3 +23,6 @@ = t 'sessions.current_session' - else %time.time-ago{ datetime: session.updated_at.iso8601, title: l(session.updated_at) }= l(session.updated_at) + %td + - if request.session['auth_id'] != session.session_id + = table_link_to 'times', t('sessions.revoke'), settings_session_path(session), method: :delete diff --git a/config/locales/en.yml b/config/locales/en.yml index 4cb536223e..ff02226ac6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -397,6 +397,8 @@ en: windows: Windows windows_mobile: Windows Mobile windows_phone: Windows Phone + revoke: Revoke + revoke_success: Session successfully revoked title: Sessions settings: authorized_apps: Authorized apps diff --git a/config/routes.rb b/config/routes.rb index 60234a9e6a..2aa89f16df 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -74,6 +74,8 @@ Rails.application.routes.draw do resource :follower_domains, only: [:show, :update] resource :delete, only: [:show, :destroy] + + resources :sessions, only: [:destroy] end resources :media, only: [:show] From 383c438a4497ddaea2466d0a4cfe557913ca6add Mon Sep 17 00:00:00 2001 From: m4sk1n Date: Wed, 19 Jul 2017 09:43:10 +0200 Subject: [PATCH 06/20] Fix missing closing

tag in ToS in .yml files (#4264) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Mikołajczak --- config/locales/ja.yml | 2 +- config/locales/pl.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/ja.yml b/config/locales/ja.yml index fc5a98d093..632f93ea3b 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -492,7 +492,7 @@ ja:

この文章のライセンスはCC-BY-SAです。このページは2017年5月6日が最終更新です。

-

オリジナルの出典 Discourse privacy policy. +

オリジナルの出典 Discourse privacy policy.

title: "%{instance} 利用規約・プライバシーポリシー" time: formats: diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 23912662e3..4e903936ef 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -496,7 +496,7 @@ pl:

Dokument jest dostępny na licencji CC-BY-SA. Ostatnio modyfikowany 31 maja 2013, przetłumaczony 4 lipca 2017. Tłumaczenie (mimo dołożenia wszelkich starań) może nie być w pełni poprawne.

-

Tekst bazuje na polityce prywatności Discourse. +

Tekst bazuje na polityce prywatności Discourse.

title: Zasady korzystania i polityka prywatności %{instance} time: formats: From d367c3ce416b07bfb14282c0a74b35cce8ed172a Mon Sep 17 00:00:00 2001 From: Damien Erambert Date: Wed, 19 Jul 2017 00:43:46 -0700 Subject: [PATCH 07/20] fix missing closing

tag in ToS in en.yml (#4262) --- config/locales/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index ff02226ac6..47f276ca13 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -494,7 +494,7 @@ en:

This document is CC-BY-SA. It was last updated May 31, 2013.

-

Originally adapted from the Discourse privacy policy. +

Originally adapted from the Discourse privacy policy.

title: "%{instance} Terms of Service and Privacy Policy" time: formats: From 0add7e293fdaa83476252b64d07610a1a62c1121 Mon Sep 17 00:00:00 2001 From: m4sk1n Date: Wed, 19 Jul 2017 10:49:36 +0200 Subject: [PATCH 08/20] i18n: @9392d10 (pl) (#4266) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Mikołajczak --- config/locales/pl.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 4e903936ef..325d52b45c 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -401,6 +401,8 @@ pl: windows: Windows windows_mobile: Windows Mobile windows_phone: Windows Phone + revoke: Unieważnij + revoke_success: Pomyślnie unieważniono sesję title: Sesje settings: authorized_apps: Uwierzytelnione aplikacje From 7b610bea1b04914f95aeea4ec4f418e973560a5a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 19 Jul 2017 12:00:05 +0200 Subject: [PATCH 09/20] Fix deprecation warning for non-pipeline assets (#4267) --- app/helpers/routing_helper.rb | 4 ++-- app/models/web/push_subscription.rb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/helpers/routing_helper.rb b/app/helpers/routing_helper.rb index 9650ee2867..8126176ba5 100644 --- a/app/helpers/routing_helper.rb +++ b/app/helpers/routing_helper.rb @@ -11,7 +11,7 @@ module RoutingHelper end end - def full_asset_url(source) - Rails.configuration.x.use_s3 ? source : URI.join(root_url, ActionController::Base.helpers.asset_url(source)).to_s + def full_asset_url(source, options = {}) + Rails.configuration.x.use_s3 ? source : URI.join(root_url, ActionController::Base.helpers.asset_url(source, options)).to_s end end diff --git a/app/models/web/push_subscription.rb b/app/models/web/push_subscription.rb index baf6a1ece1..dffdbbd056 100644 --- a/app/models/web/push_subscription.rb +++ b/app/models/web/push_subscription.rb @@ -45,7 +45,7 @@ class Web::PushSubscription < ApplicationRecord title: title, dir: dir, image: image, - badge: full_asset_url('badge.png'), + badge: full_asset_url('badge.png', skip_pipeline: true), tag: notification.id, timestamp: notification.created_at, icon: notification.from_account.avatar_static_url, @@ -115,7 +115,7 @@ class Web::PushSubscription < ApplicationRecord when :mention then [ { title: translate('push_notifications.mention.action_favourite'), - icon: full_asset_url('emoji/2764.png'), + icon: full_asset_url('emoji/2764.png', skip_pipeline: true), todo: 'request', method: 'POST', action: "/api/v1/statuses/#{notification.target_status.id}/favourite", @@ -156,8 +156,8 @@ class Web::PushSubscription < ApplicationRecord Webpush.payload_send( message: JSON.generate( title: translate('push_notifications.subscribed.title'), - icon: full_asset_url('android-chrome-192x192.png'), - badge: full_asset_url('badge.png'), + icon: full_asset_url('android-chrome-192x192.png', skip_pipeline: true), + badge: full_asset_url('badge.png', skip_pipeline: true), data: { content: translate('push_notifications.subscribed.body'), actions: [], From 8465019f5465f7cd5dca1c061ef2bc081ef12df9 Mon Sep 17 00:00:00 2001 From: m4sk1n Date: Wed, 19 Jul 2017 12:25:06 +0200 Subject: [PATCH 10/20] i18n: Update Polish translation (#4268) --- app/javascript/mastodon/locales/pl.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/javascript/mastodon/locales/pl.json b/app/javascript/mastodon/locales/pl.json index f04ef4e8c1..3489846483 100644 --- a/app/javascript/mastodon/locales/pl.json +++ b/app/javascript/mastodon/locales/pl.json @@ -111,8 +111,8 @@ "notifications.column_settings.favourite": "Ulubione:", "notifications.column_settings.follow": "Nowi śledzący:", "notifications.column_settings.mention": "Wspomniali:", - "notifications.column_settings.push": "Push notifications", - "notifications.column_settings.push_meta": "This device", + "notifications.column_settings.push": "Powiadomienia push", + "notifications.column_settings.push_meta": "To urządzenie", "notifications.column_settings.reblog": "Podbili:", "notifications.column_settings.show": "Pokaż w kolumnie", "notifications.column_settings.sound": "Odtwarzaj dźwięk", @@ -125,7 +125,7 @@ "onboarding.page_one.handle": "Jesteś na domenie {domain}, więc Twój pełny adres to {handle}", "onboarding.page_one.welcome": "Witamy w Mastodon!", "onboarding.page_six.admin": "Administratorem tej instancji jest {admin}.", - "onboarding.page_six.almost_done": "Prawie gotowe...", + "onboarding.page_six.almost_done": "Prawie gotowe…", "onboarding.page_six.appetoot": "Bon Appetoot!", "onboarding.page_six.apps_available": "Są dostępne {apps} dla Androida, iOS i innych platform.", "onboarding.page_six.github": "Mastodon jest oprogramowaniem otwartoźródłwym. Możesz zgłaszać błędy, proponować funkcje i pomóc w rozwoju na {github}.", @@ -151,7 +151,7 @@ "report.target": "Zgłaszanie {target}", "search.placeholder": "Szukaj", "search_results.total": "{count, number} {count, plural, one {wynik} more {wyniki}}", - "standalone.public_title": "A look inside...", + "standalone.public_title": "Spojrzenie wgłąb…", "status.cannot_reblog": "Ten post nie może zostać podbity", "status.delete": "Usuń", "status.favourite": "Ulubione", @@ -178,7 +178,7 @@ "upload_area.title": "Przeciągnij i upuść aby wysłać", "upload_button.label": "Dodaj zawartość multimedialną", "upload_form.undo": "Cofnij", - "upload_progress.label": "Wysyłanie...", + "upload_progress.label": "Wysyłanie", "video_player.expand": "Przełącz wideo", "video_player.toggle_sound": "Przełącz dźwięk", "video_player.toggle_visible": "Przełącz widoczność", From 77c64924bc080edf6d63ea3735995db2ae9ea88a Mon Sep 17 00:00:00 2001 From: Cygnan Date: Wed, 19 Jul 2017 20:35:22 +0900 Subject: [PATCH 11/20] Fix a typo in public.js (double semicolons) (#4269) Signed-off-by: Cygnan --- app/javascript/packs/public.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js index ce79836d66..a2ed086f1d 100644 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@ -35,7 +35,7 @@ function main() { [].forEach.call(document.querySelectorAll('time.time-ago'), (content) => { const datetime = new Date(content.getAttribute('datetime')); - content.textContent = relativeFormat.format(datetime);; + content.textContent = relativeFormat.format(datetime); }); }); From df59dc6639f22923f63131905e9c712b0d5cc1ac Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 19 Jul 2017 14:44:04 +0200 Subject: [PATCH 12/20] Refactor ResolveRemoteAccountService (#4258) * Refactor ResolveRemoteAccountService * Remove trailing whitespace * Use redis locks around critical ResolveRemoteAccountService code * Add test for race condition of lock --- Gemfile | 1 + Gemfile.lock | 3 + .../resolve_remote_account_service.rb | 166 ++++++++++++------ .../resolve_remote_account_service_spec.rb | 23 +++ 4 files changed, 138 insertions(+), 55 deletions(-) diff --git a/Gemfile b/Gemfile index a6c2b2d65c..f4d8891657 100644 --- a/Gemfile +++ b/Gemfile @@ -52,6 +52,7 @@ gem 'rack-timeout', '~> 0.4' gem 'rails-i18n', '~> 5.0' gem 'rails-settings-cached', '~> 0.6' gem 'redis', '~> 3.3', require: ['redis', 'redis/connection/hiredis'] +gem 'mario-redis-lock', '~> 1.2', require: 'redis_lock' gem 'rqrcode', '~> 0.10' gem 'ruby-oembed', '~> 0.12', require: 'oembed' gem 'sanitize', '~> 4.4' diff --git a/Gemfile.lock b/Gemfile.lock index f637c9bbe4..6f0621f5fa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -242,6 +242,8 @@ GEM nokogiri (>= 1.5.9) mail (2.6.6) mime-types (>= 1.16, < 4) + mario-redis-lock (1.2.0) + redis (~> 3, >= 3.0.5) method_source (0.8.2) microformats (4.0.7) json @@ -535,6 +537,7 @@ DEPENDENCIES letter_opener_web (~> 1.3) link_header (~> 0.0) lograge (~> 0.5) + mario-redis-lock (~> 1.2) microformats (~> 4.0) mime-types (~> 3.1) nokogiri (~> 1.7) diff --git a/app/services/resolve_remote_account_service.rb b/app/services/resolve_remote_account_service.rb index d2dfda8247..c948243ecd 100644 --- a/app/services/resolve_remote_account_service.rb +++ b/app/services/resolve_remote_account_service.rb @@ -11,97 +11,153 @@ class ResolveRemoteAccountService < BaseService # @param [String] uri User URI in the form of username@domain # @return [Account] def call(uri, update_profile = true, redirected = nil) - username, domain = uri.split('@') + @username, @domain = uri.split('@') - return Account.find_local(username) if TagManager.instance.local_domain?(domain) + return Account.find_local(@username) if TagManager.instance.local_domain?(@domain) - account = Account.find_remote(username, domain) - return account unless account_needs_webfinger_update?(account) + @account = Account.find_remote(@username, @domain) + + return @account unless webfinger_update_due? Rails.logger.debug "Looking up webfinger for #{uri}" - data = Goldfinger.finger("acct:#{uri}") + @webfinger = Goldfinger.finger("acct:#{uri}") - raise Goldfinger::Error, 'Missing resource links' if data.link('http://schemas.google.com/g/2010#updates-from').nil? || data.link('salmon').nil? || data.link('http://webfinger.net/rel/profile-page').nil? || data.link('magic-public-key').nil? + raise Goldfinger::Error, 'Missing resource links' if links_missing? - # Disallow account hijacking - confirmed_username, confirmed_domain = data.subject.gsub(/\Aacct:/, '').split('@') + confirmed_username, confirmed_domain = @webfinger.subject.gsub(/\Aacct:/, '').split('@') - unless confirmed_username.casecmp(username).zero? && confirmed_domain.casecmp(domain).zero? + if confirmed_username.casecmp(@username).zero? && confirmed_domain.casecmp(@domain).zero? + @username = confirmed_username + @domain = confirmed_domain + else return call("#{confirmed_username}@#{confirmed_domain}", update_profile, true) if redirected.nil? - raise Goldfinger::Error, 'Requested and returned acct URI do not match' + raise Goldfinger::Error, 'Requested and returned acct URIs do not match' end - return Account.find_local(confirmed_username) if TagManager.instance.local_domain?(confirmed_domain) + return Account.find_local(@username) if TagManager.instance.local_domain?(@domain) - confirmed_account = Account.find_remote(confirmed_username, confirmed_domain) - if confirmed_account.nil? - Rails.logger.debug "Creating new remote account for #{uri}" + RedisLock.acquire(lock_options) do |lock| + if lock.acquired? + @account = Account.find_remote(@username, @domain) - domain_block = DomainBlock.find_by(domain: domain) - account = Account.new(username: confirmed_username, domain: confirmed_domain) - account.suspended = true if domain_block && domain_block.suspend? - account.silenced = true if domain_block && domain_block.silence? - account.private_key = nil - else - account = confirmed_account + create_account if @account.nil? + update_account + + update_account_profile if update_profile + end end - account.last_webfingered_at = Time.now.utc + @account + end - account.remote_url = data.link('http://schemas.google.com/g/2010#updates-from').href - account.salmon_url = data.link('salmon').href - account.url = data.link('http://webfinger.net/rel/profile-page').href - account.public_key = magic_key_to_pem(data.link('magic-public-key').href) + private - body, xml = get_feed(account.remote_url) - hubs = get_hubs(xml) + def links_missing? + @webfinger.link('http://schemas.google.com/g/2010#updates-from').nil? || + @webfinger.link('salmon').nil? || + @webfinger.link('http://webfinger.net/rel/profile-page').nil? || + @webfinger.link('magic-public-key').nil? + end - account.uri = get_account_uri(xml) - account.hub_url = hubs.first.attribute('href').value + def webfinger_update_due? + @account.nil? || @account.last_webfingered_at.nil? || @account.last_webfingered_at <= 1.day.ago + end - begin - account.save! - get_profile(body, account) if update_profile - rescue ActiveRecord::RecordNotUnique - # The account has been added by another worker! - return Account.find_remote(confirmed_username, confirmed_domain) - end + def create_account + Rails.logger.debug "Creating new remote account for #{@username}@#{@domain}" - account + @account = Account.new(username: @username, domain: @domain) + @account.suspended = true if auto_suspend? + @account.silenced = true if auto_silence? + @account.private_key = nil end - private + def update_account + @account.last_webfingered_at = Time.now.utc + @account.remote_url = atom_url + @account.salmon_url = salmon_url + @account.url = url + @account.public_key = public_key + @account.uri = canonical_uri + @account.hub_url = hub_url + @account.save! + end - def account_needs_webfinger_update?(account) - account&.last_webfingered_at.nil? || account.last_webfingered_at <= 1.day.ago + def auto_suspend? + domain_block && domain_block.suspend? end - def get_feed(url) - response = Request.new(:get, url).perform - raise Goldfinger::Error, "Feed attempt failed for #{url}: HTTP #{response.code}" unless response.code == 200 - [response.to_s, Nokogiri::XML(response)] + def auto_silence? + domain_block && domain_block.silence? end - def get_hubs(xml) - hubs = xml.xpath('//xmlns:link[@rel="hub"]') - raise Goldfinger::Error, 'No PubSubHubbub hubs found' if hubs.empty? || hubs.first.attribute('href').nil? - hubs + def domain_block + return @domain_block if defined?(@domain_block) + @domain_block = DomainBlock.find_by(domain: @domain) end - def get_account_uri(xml) - author_uri = xml.at_xpath('/xmlns:feed/xmlns:author/xmlns:uri') + def atom_url + @atom_url ||= @webfinger.link('http://schemas.google.com/g/2010#updates-from').href + end + + def salmon_url + @salmon_url ||= @webfinger.link('salmon').href + end + + def url + @url ||= @webfinger.link('http://webfinger.net/rel/profile-page').href + end + + def public_key + @public_key ||= magic_key_to_pem(@webfinger.link('magic-public-key').href) + end + + def canonical_uri + return @canonical_uri if defined?(@canonical_uri) + + author_uri = atom.at_xpath('/xmlns:feed/xmlns:author/xmlns:uri') if author_uri.nil? - owner = xml.at_xpath('/xmlns:feed').at_xpath('./dfrn:owner', dfrn: DFRN_NS) + owner = atom.at_xpath('/xmlns:feed').at_xpath('./dfrn:owner', dfrn: DFRN_NS) author_uri = owner.at_xpath('./xmlns:uri') unless owner.nil? end raise Goldfinger::Error, 'Author URI could not be found' if author_uri.nil? - author_uri.content + + @canonical_uri = author_uri.content + end + + def hub_url + return @hub_url if defined?(@hub_url) + + hubs = atom.xpath('//xmlns:link[@rel="hub"]') + + raise Goldfinger::Error, 'No PubSubHubbub hubs found' if hubs.empty? || hubs.first['href'].nil? + + @hub_url = hubs.first['href'] + end + + def atom_body + return @atom_body if defined?(@atom_body) + + response = Request.new(:get, atom_url).perform + + raise Goldfinger::Error, "Feed attempt failed for #{atom_url}: HTTP #{response.code}" unless response.code == 200 + + @atom_body = response.to_s + end + + def atom + return @atom if defined?(@atom) + @atom = Nokogiri::XML(atom_body) + end + + def update_account_profile + RemoteProfileUpdateWorker.perform_async(@account.id, atom_body.force_encoding('UTF-8'), false) end - def get_profile(body, account) - RemoteProfileUpdateWorker.perform_async(account.id, body.force_encoding('UTF-8'), false) + def lock_options + { redis: Redis.current, key: "resolve:#{@username}@#{@domain}" } end end diff --git a/spec/services/resolve_remote_account_service_spec.rb b/spec/services/resolve_remote_account_service_spec.rb index ad4d436ba3..c51588210f 100644 --- a/spec/services/resolve_remote_account_service_spec.rb +++ b/spec/services/resolve_remote_account_service_spec.rb @@ -68,4 +68,27 @@ RSpec.describe ResolveRemoteAccountService do expect(account.domain).to eq 'localdomain.com' expect(account.remote_url).to eq 'https://webdomain.com/users/foo.atom' end + + it 'processes one remote account at a time using locks' do + wait_for_start = true + fail_occurred = false + return_values = [] + + threads = Array.new(5) do + Thread.new do + true while wait_for_start + begin + return_values << subject.call('foo@localdomain.com') + rescue ActiveRecord::RecordNotUnique + fail_occurred = true + end + end + end + + wait_for_start = false + threads.each(&:join) + + expect(fail_occurred).to be false + expect(return_values).to_not include(nil) + end end From b085c55263c6959cde66438564463dfa459bf4bb Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Wed, 19 Jul 2017 23:02:03 +0900 Subject: [PATCH 13/20] Fix logging in ProcessFeedService (#4270) --- app/services/process_feed_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb index 9fa8eda519..31191a818f 100644 --- a/app/services/process_feed_service.rb +++ b/app/services/process_feed_service.rb @@ -23,7 +23,7 @@ class ProcessFeedService < BaseService activity = OStatus::Activity::General.new(xml, account) activity.specialize&.perform if activity.status? rescue ActiveRecord::RecordInvalid => e - Rails.logger.debug "Nothing was saved for #{id} because: #{e}" + Rails.logger.debug "Nothing was saved for #{activity.id} because: #{e}" nil end end From 81ebd4025a1f898d88ba24f5d03dfa738f6a961a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 19 Jul 2017 17:06:46 +0200 Subject: [PATCH 14/20] Add ActivityPub attributes to accounts (#4273) --- app/models/account.rb | 7 +++++++ app/services/send_interaction_service.rb | 2 +- app/services/subscribe_service.rb | 2 ++ app/services/unsubscribe_service.rb | 2 ++ db/migrate/20170718211102_add_activitypub_to_accounts.rb | 9 +++++++++ db/schema.rb | 7 ++++++- 6 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20170718211102_add_activitypub_to_accounts.rb diff --git a/app/models/account.rb b/app/models/account.rb index 58b0a1086b..82c9b58d56 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -36,6 +36,11 @@ # followers_count :integer default(0), not null # following_count :integer default(0), not null # last_webfingered_at :datetime +# inbox_url :string default(""), not null +# outbox_url :string default(""), not null +# shared_inbox_url :string default(""), not null +# followers_url :string default(""), not null +# protocol :integer default("ostatus"), not null # class Account < ApplicationRecord @@ -49,6 +54,8 @@ class Account < ApplicationRecord include Remotable include EmojiHelper + enum protocol: [:ostatus, :activitypub] + # Local users has_one :user, inverse_of: :account diff --git a/app/services/send_interaction_service.rb b/app/services/send_interaction_service.rb index ef38a748b2..ab0d3aeed9 100644 --- a/app/services/send_interaction_service.rb +++ b/app/services/send_interaction_service.rb @@ -10,7 +10,7 @@ class SendInteractionService < BaseService @source_account = source_account @target_account = target_account - return if block_notification? + return if !target_account.ostatus? || block_notification? delivery = build_request.perform diff --git a/app/services/subscribe_service.rb b/app/services/subscribe_service.rb index f58067038b..c1c0a4c8b3 100644 --- a/app/services/subscribe_service.rb +++ b/app/services/subscribe_service.rb @@ -2,6 +2,8 @@ class SubscribeService < BaseService def call(account) + return unless account.ostatus? + @account = account @account.secret = SecureRandom.hex @response = build_request.perform diff --git a/app/services/unsubscribe_service.rb b/app/services/unsubscribe_service.rb index c2f022d7df..c5e0e73feb 100644 --- a/app/services/unsubscribe_service.rb +++ b/app/services/unsubscribe_service.rb @@ -2,6 +2,8 @@ class UnsubscribeService < BaseService def call(account) + return unless account.ostatus? + @account = account @response = build_request.perform diff --git a/db/migrate/20170718211102_add_activitypub_to_accounts.rb b/db/migrate/20170718211102_add_activitypub_to_accounts.rb new file mode 100644 index 0000000000..c08e38bb90 --- /dev/null +++ b/db/migrate/20170718211102_add_activitypub_to_accounts.rb @@ -0,0 +1,9 @@ +class AddActivityPubToAccounts < ActiveRecord::Migration[5.1] + def change + add_column :accounts, :inbox_url, :string, null: false, default: '' + add_column :accounts, :outbox_url, :string, null: false, default: '' + add_column :accounts, :shared_inbox_url, :string, null: false, default: '' + add_column :accounts, :followers_url, :string, null: false, default: '' + add_column :accounts, :protocol, :integer, null: false, default: 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index 5ec78a7c98..cf7b0722fc 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: 20170714184731) do +ActiveRecord::Schema.define(version: 20170718211102) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -56,6 +56,11 @@ ActiveRecord::Schema.define(version: 20170714184731) do t.integer "followers_count", default: 0, null: false t.integer "following_count", default: 0, null: false t.datetime "last_webfingered_at" + t.string "inbox_url", default: "", null: false + t.string "outbox_url", default: "", null: false + t.string "shared_inbox_url", default: "", null: false + t.string "followers_url", default: "", null: false + t.integer "protocol", default: 0, null: false 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" From e6275b4ade34313bd23b6cfe458daec244f372fe Mon Sep 17 00:00:00 2001 From: Sorin Davidoi Date: Wed, 19 Jul 2017 19:38:50 +0200 Subject: [PATCH 15/20] fix: Handle errors without response (#4274) --- app/javascript/mastodon/actions/statuses.js | 2 +- app/javascript/mastodon/actions/timelines.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/mastodon/actions/statuses.js b/app/javascript/mastodon/actions/statuses.js index 8d385715c3..2204e0b14a 100644 --- a/app/javascript/mastodon/actions/statuses.js +++ b/app/javascript/mastodon/actions/statuses.js @@ -113,7 +113,7 @@ export function fetchContext(id) { dispatch(fetchContextSuccess(id, response.data.ancestors, response.data.descendants)); }).catch(error => { - if (error.response.status === 404) { + if (error.response && error.response.status === 404) { dispatch(deleteFromTimelines(id)); } diff --git a/app/javascript/mastodon/actions/timelines.js b/app/javascript/mastodon/actions/timelines.js index dd14cb1cd0..5c0cd93c7e 100644 --- a/app/javascript/mastodon/actions/timelines.js +++ b/app/javascript/mastodon/actions/timelines.js @@ -105,7 +105,7 @@ export function refreshTimelineFail(timeline, error, skipLoading) { timeline, error, skipLoading, - skipAlert: error.response.status === 404, + skipAlert: error.response && error.response.status === 404, }; }; From c44fcfd9e70b4c90e8ca3f26336ee8f05790d3e8 Mon Sep 17 00:00:00 2001 From: unarist Date: Thu, 20 Jul 2017 03:26:51 +0900 Subject: [PATCH 16/20] Update scroll top state on column mounting (#4276) --- app/javascript/mastodon/components/status_list.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/javascript/mastodon/components/status_list.js b/app/javascript/mastodon/components/status_list.js index 86e8386bda..a8ea1ec5b1 100644 --- a/app/javascript/mastodon/components/status_list.js +++ b/app/javascript/mastodon/components/status_list.js @@ -30,8 +30,8 @@ export default class StatusList extends ImmutablePureComponent { intersectionObserverWrapper = new IntersectionObserverWrapper(); - handleScroll = debounce((e) => { - const { scrollTop, scrollHeight, clientHeight } = e.target; + handleScroll = debounce(() => { + const { scrollTop, scrollHeight, clientHeight } = this.node; const offset = scrollHeight - scrollTop - clientHeight; this._oldScrollPosition = scrollHeight - scrollTop; @@ -49,6 +49,9 @@ export default class StatusList extends ImmutablePureComponent { componentDidMount () { this.attachScrollListener(); this.attachIntersectionObserver(); + + // Handle initial scroll posiiton + this.handleScroll(); } componentDidUpdate (prevProps) { From 04ec8a8f388dc346b12b899ad61247893724a8d1 Mon Sep 17 00:00:00 2001 From: Sorin Davidoi Date: Wed, 19 Jul 2017 22:37:52 +0200 Subject: [PATCH 17/20] fix(push_subscription): Guard against malformed favourite notification (#4271) --- app/models/web/push_subscription.rb | 10 ++++------ app/services/notify_service.rb | 7 ++++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/models/web/push_subscription.rb b/app/models/web/push_subscription.rb index dffdbbd056..86df9b591c 100644 --- a/app/models/web/push_subscription.rb +++ b/app/models/web/push_subscription.rb @@ -26,8 +26,6 @@ class Web::PushSubscription < ApplicationRecord before_create :send_welcome_notification def push(notification) - return unless pushable? notification - name = display_name notification.from_account title = title_str(name, notification) body = body_str notification @@ -69,6 +67,10 @@ class Web::PushSubscription < ApplicationRecord ) end + def pushable?(notification) + data && data.key?('alerts') && data['alerts'][notification.type.to_s] + end + def as_payload payload = { id: id, @@ -148,10 +150,6 @@ class Web::PushSubscription < ApplicationRecord rtl?(body) ? 'rtl' : 'ltr' end - def pushable?(notification) - data && data.key?('alerts') && data['alerts'][notification.type.to_s] - end - def send_welcome_notification Webpush.payload_send( message: JSON.generate( diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb index c7d8ad50a5..a44df51803 100644 --- a/app/services/notify_service.rb +++ b/app/services/notify_service.rb @@ -65,7 +65,12 @@ class NotifyService < BaseService end def send_push_notifications - sessions_with_subscriptions_ids = @recipient.user.session_activations.where.not(web_push_subscription: nil).pluck(:id) + # 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) WebPushNotificationWorker.push_bulk(sessions_with_subscriptions_ids) do |session_activation_id| [session_activation_id, @notification.id] From 707d6fa9c0512e84d0ca3e41855b0307f3d884a6 Mon Sep 17 00:00:00 2001 From: Sorin Davidoi Date: Wed, 19 Jul 2017 22:38:26 +0200 Subject: [PATCH 18/20] fix(status_list): Update scroll position after toots are appended (#4277) --- app/javascript/mastodon/components/status_list.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/javascript/mastodon/components/status_list.js b/app/javascript/mastodon/components/status_list.js index a8ea1ec5b1..98f0de0a85 100644 --- a/app/javascript/mastodon/components/status_list.js +++ b/app/javascript/mastodon/components/status_list.js @@ -57,13 +57,14 @@ export default class StatusList extends ImmutablePureComponent { componentDidUpdate (prevProps) { // Reset the scroll position when a new toot comes in in order not to // jerk the scrollbar around if you're already scrolled down the page. - if (prevProps.statusIds.size < this.props.statusIds.size && - prevProps.statusIds.first() !== this.props.statusIds.first() && - this._oldScrollPosition && - this.node.scrollTop > 0) { - let newScrollTop = this.node.scrollHeight - this._oldScrollPosition; - if (this.node.scrollTop !== newScrollTop) { - this.node.scrollTop = newScrollTop; + if (prevProps.statusIds.size < this.props.statusIds.size && this._oldScrollPosition && this.node.scrollTop > 0) { + if (prevProps.statusIds.first() !== this.props.statusIds.first()) { + let newScrollTop = this.node.scrollHeight - this._oldScrollPosition; + if (this.node.scrollTop !== newScrollTop) { + this.node.scrollTop = newScrollTop; + } + } else { + this._oldScrollPosition = this.node.scrollHeight - this.node.scrollTop; } } } From 2de75ba29d9ab2af2cab7b509ee745b7944000fc Mon Sep 17 00:00:00 2001 From: Sorin Davidoi Date: Thu, 20 Jul 2017 00:20:54 +0200 Subject: [PATCH 19/20] feat(css): Remove border radius from WebKit's scrollbars (#4278) --- app/javascript/styles/components.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/javascript/styles/components.scss b/app/javascript/styles/components.scss index 1c4c97f18a..8c930ad111 100644 --- a/app/javascript/styles/components.scss +++ b/app/javascript/styles/components.scss @@ -3711,6 +3711,10 @@ button.icon-button.active i.fa-retweet { } } +::-webkit-scrollbar-thumb { + border-radius: 0; +} + noscript { text-align: center; From 75ab7677910c8062be29fceeb9cfa4db0304f6c1 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 20 Jul 2017 01:59:07 +0200 Subject: [PATCH 20/20] Fix webfinger retries (#4275) * Do not raise unretryable exceptions in ResolveRemoteAccountService * Removed fatal exceptions from ResolveRemoteAccountService Exceptions that cannot be retried should not be raised. New exception class for those that can be retried (Mastodon::UnexpectedResponseError) --- app/controllers/api/base_controller.rb | 6 +--- app/lib/exceptions.rb | 10 +++++++ app/services/fetch_remote_account_service.rb | 3 -- app/services/fetch_remote_status_service.rb | 3 -- app/services/process_interaction_service.rb | 2 +- .../resolve_remote_account_service.rb | 29 ++++++++++--------- app/services/send_interaction_service.rb | 2 +- app/services/subscribe_service.rb | 2 +- app/workers/import_worker.rb | 6 ++-- app/workers/pubsubhubbub/delivery_worker.rb | 2 +- spec/controllers/api/base_controller_spec.rb | 2 +- .../resolve_remote_account_service_spec.rb | 6 ++-- spec/services/subscribe_service_spec.rb | 4 +-- .../pubsubhubbub/delivery_worker_spec.rb | 2 +- 14 files changed, 40 insertions(+), 39 deletions(-) diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index c1b2ec3cf5..105a2859d3 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -17,11 +17,7 @@ class Api::BaseController < ApplicationController render json: { error: 'Record not found' }, status: 404 end - rescue_from Goldfinger::Error do - render json: { error: 'Remote account could not be resolved' }, status: 422 - end - - rescue_from HTTP::Error do + rescue_from HTTP::Error, Mastodon::UnexpectedResponseError do render json: { error: 'Remote data could not be fetched' }, status: 503 end diff --git a/app/lib/exceptions.rb b/app/lib/exceptions.rb index 9bc802c120..34d84a34f9 100644 --- a/app/lib/exceptions.rb +++ b/app/lib/exceptions.rb @@ -5,4 +5,14 @@ module Mastodon class NotPermittedError < Error; end class ValidationError < Error; end class RaceConditionError < Error; end + + class UnexpectedResponseError < Error + def initialize(response = nil) + @response = response + end + + def to_s + "#{@response.uri} returned code #{@response.code}" + end + end end diff --git a/app/services/fetch_remote_account_service.rb b/app/services/fetch_remote_account_service.rb index 1efac365b0..8eed0d4542 100644 --- a/app/services/fetch_remote_account_service.rb +++ b/app/services/fetch_remote_account_service.rb @@ -32,8 +32,5 @@ class FetchRemoteAccountService < BaseService rescue Nokogiri::XML::XPath::SyntaxError Rails.logger.debug 'Invalid XML or missing namespace' nil - rescue Goldfinger::NotFoundError, Goldfinger::Error - Rails.logger.debug 'Exceptions related to Goldfinger occurs' - nil end end diff --git a/app/services/fetch_remote_status_service.rb b/app/services/fetch_remote_status_service.rb index 6ac31e4d8b..b9f5f97b1a 100644 --- a/app/services/fetch_remote_status_service.rb +++ b/app/services/fetch_remote_status_service.rb @@ -33,9 +33,6 @@ class FetchRemoteStatusService < BaseService rescue Nokogiri::XML::XPath::SyntaxError Rails.logger.debug 'Invalid XML or missing namespace' nil - rescue Goldfinger::NotFoundError, Goldfinger::Error - Rails.logger.debug 'Exceptions related to Goldfinger occurs' - nil end def confirmed_domain?(domain, account) diff --git a/app/services/process_interaction_service.rb b/app/services/process_interaction_service.rb index 584a109ad4..cc99cde035 100644 --- a/app/services/process_interaction_service.rb +++ b/app/services/process_interaction_service.rb @@ -47,7 +47,7 @@ class ProcessInteractionService < BaseService reflect_unblock!(account, target_account) end end - rescue Goldfinger::Error, HTTP::Error, OStatus2::BadSalmonError, Mastodon::NotPermittedError + rescue HTTP::Error, OStatus2::BadSalmonError, Mastodon::NotPermittedError nil end diff --git a/app/services/resolve_remote_account_service.rb b/app/services/resolve_remote_account_service.rb index c948243ecd..e0e2ebc831 100644 --- a/app/services/resolve_remote_account_service.rb +++ b/app/services/resolve_remote_account_service.rb @@ -23,18 +23,19 @@ class ResolveRemoteAccountService < BaseService @webfinger = Goldfinger.finger("acct:#{uri}") - raise Goldfinger::Error, 'Missing resource links' if links_missing? - confirmed_username, confirmed_domain = @webfinger.subject.gsub(/\Aacct:/, '').split('@') if confirmed_username.casecmp(@username).zero? && confirmed_domain.casecmp(@domain).zero? @username = confirmed_username @domain = confirmed_domain + elsif redirected.nil? + return call("#{confirmed_username}@#{confirmed_domain}", update_profile, true) else - return call("#{confirmed_username}@#{confirmed_domain}", update_profile, true) if redirected.nil? - raise Goldfinger::Error, 'Requested and returned acct URIs do not match' + Rails.logger.debug 'Requested and returned acct URIs do not match' + return end + return if links_missing? return Account.find_local(@username) if TagManager.instance.local_domain?(@domain) RedisLock.acquire(lock_options) do |lock| @@ -49,6 +50,9 @@ class ResolveRemoteAccountService < BaseService end @account + rescue Goldfinger::Error => e + Rails.logger.debug "Webfinger query for #{uri} unsuccessful: #{e}" + nil end private @@ -57,7 +61,9 @@ class ResolveRemoteAccountService < BaseService @webfinger.link('http://schemas.google.com/g/2010#updates-from').nil? || @webfinger.link('salmon').nil? || @webfinger.link('http://webfinger.net/rel/profile-page').nil? || - @webfinger.link('magic-public-key').nil? + @webfinger.link('magic-public-key').nil? || + canonical_uri.nil? || + hub_url.nil? end def webfinger_update_due? @@ -123,19 +129,14 @@ class ResolveRemoteAccountService < BaseService author_uri = owner.at_xpath('./xmlns:uri') unless owner.nil? end - raise Goldfinger::Error, 'Author URI could not be found' if author_uri.nil? - - @canonical_uri = author_uri.content + @canonical_uri = author_uri.nil? ? nil : author_uri.content end def hub_url return @hub_url if defined?(@hub_url) - hubs = atom.xpath('//xmlns:link[@rel="hub"]') - - raise Goldfinger::Error, 'No PubSubHubbub hubs found' if hubs.empty? || hubs.first['href'].nil? - - @hub_url = hubs.first['href'] + hubs = atom.xpath('//xmlns:link[@rel="hub"]') + @hub_url = hubs.empty? || hubs.first['href'].nil? ? nil : hubs.first['href'] end def atom_body @@ -143,7 +144,7 @@ class ResolveRemoteAccountService < BaseService response = Request.new(:get, atom_url).perform - raise Goldfinger::Error, "Feed attempt failed for #{atom_url}: HTTP #{response.code}" unless response.code == 200 + raise Mastodon::UnexpectedResponseError, response unless response.code == 200 @atom_body = response.to_s end diff --git a/app/services/send_interaction_service.rb b/app/services/send_interaction_service.rb index ab0d3aeed9..c11813abc6 100644 --- a/app/services/send_interaction_service.rb +++ b/app/services/send_interaction_service.rb @@ -14,7 +14,7 @@ class SendInteractionService < BaseService delivery = build_request.perform - raise "Delivery failed for #{target_account.salmon_url}: HTTP #{delivery.code}" unless delivery.code > 199 && delivery.code < 300 + raise Mastodon::UnexpectedResponseError, delivery unless delivery.code > 199 && delivery.code < 300 end private diff --git a/app/services/subscribe_service.rb b/app/services/subscribe_service.rb index c1c0a4c8b3..d3e41e691d 100644 --- a/app/services/subscribe_service.rb +++ b/app/services/subscribe_service.rb @@ -18,7 +18,7 @@ class SubscribeService < BaseService else # The response was either a 429 rate limit, or a 5xx error. # We need to retry at a later time. Fail loudly! - raise "Subscription attempt failed for #{@account.acct} (#{@account.hub_url}): HTTP #{@response.code}" + raise Mastodon::UnexpectedResponseError, @response end end diff --git a/app/workers/import_worker.rb b/app/workers/import_worker.rb index 90a2262064..27cc6b365d 100644 --- a/app/workers/import_worker.rb +++ b/app/workers/import_worker.rb @@ -44,7 +44,7 @@ class ImportWorker target_account = ResolveRemoteAccountService.new.call(row.first) next if target_account.nil? MuteService.new.call(from_account, target_account) - rescue Goldfinger::Error, HTTP::Error, OpenSSL::SSL::SSLError + rescue Mastodon::UnexpectedResponseError, HTTP::Error, OpenSSL::SSL::SSLError next end end @@ -56,7 +56,7 @@ class ImportWorker target_account = ResolveRemoteAccountService.new.call(row.first) next if target_account.nil? BlockService.new.call(from_account, target_account) - rescue Goldfinger::Error, HTTP::Error, OpenSSL::SSL::SSLError + rescue Mastodon::UnexpectedResponseError, HTTP::Error, OpenSSL::SSL::SSLError next end end @@ -66,7 +66,7 @@ class ImportWorker import_rows.each do |row| begin FollowService.new.call(from_account, row.first) - rescue Mastodon::NotPermittedError, ActiveRecord::RecordNotFound, Goldfinger::Error, HTTP::Error, OpenSSL::SSL::SSLError + rescue Mastodon::NotPermittedError, ActiveRecord::RecordNotFound, Mastodon::UnexpectedResponseError, HTTP::Error, OpenSSL::SSL::SSLError next end end diff --git a/app/workers/pubsubhubbub/delivery_worker.rb b/app/workers/pubsubhubbub/delivery_worker.rb index 2e1101b93c..035a590481 100644 --- a/app/workers/pubsubhubbub/delivery_worker.rb +++ b/app/workers/pubsubhubbub/delivery_worker.rb @@ -23,7 +23,7 @@ class Pubsubhubbub::DeliveryWorker def process_delivery payload_delivery - raise "Delivery failed for #{subscription.callback_url}: HTTP #{payload_delivery.code}" unless response_successful? + raise Mastodon::UnexpectedResponseError, payload_delivery unless response_successful? subscription.touch(:last_successful_delivery_at) end diff --git a/spec/controllers/api/base_controller_spec.rb b/spec/controllers/api/base_controller_spec.rb index 7d5e0116c0..0c7ca8990d 100644 --- a/spec/controllers/api/base_controller_spec.rb +++ b/spec/controllers/api/base_controller_spec.rb @@ -32,7 +32,7 @@ describe Api::BaseController do ActiveRecord::RecordInvalid => 422, Mastodon::ValidationError => 422, ActiveRecord::RecordNotFound => 404, - Goldfinger::Error => 422, + Mastodon::UnexpectedResponseError => 503, HTTP::Error => 503, OpenSSL::SSL::SSLError => 503, Mastodon::NotPermittedError => 403, diff --git a/spec/services/resolve_remote_account_service_spec.rb b/spec/services/resolve_remote_account_service_spec.rb index c51588210f..ab5d3c6e53 100644 --- a/spec/services/resolve_remote_account_service_spec.rb +++ b/spec/services/resolve_remote_account_service_spec.rb @@ -22,11 +22,11 @@ RSpec.describe ResolveRemoteAccountService do end it 'raises error if no such user can be resolved via webfinger' do - expect { subject.call('catsrgr8@quitter.no') }.to raise_error Goldfinger::Error + expect(subject.call('catsrgr8@quitter.no')).to be_nil end it 'raises error if the domain does not have webfinger' do - expect { subject.call('catsrgr8@example.com') }.to raise_error Goldfinger::Error + expect(subject.call('catsrgr8@example.com')).to be_nil end it 'returns an already existing remote account' do @@ -58,7 +58,7 @@ RSpec.describe ResolveRemoteAccountService do end it 'prevents hijacking inexisting accounts' do - expect { subject.call('hacker2@redirected.com') }.to raise_error Goldfinger::Error + expect(subject.call('hacker2@redirected.com')).to be_nil end it 'returns a new remote account' do diff --git a/spec/services/subscribe_service_spec.rb b/spec/services/subscribe_service_spec.rb index 5db91ad99e..835be5ec53 100644 --- a/spec/services/subscribe_service_spec.rb +++ b/spec/services/subscribe_service_spec.rb @@ -33,11 +33,11 @@ RSpec.describe SubscribeService do it 'fails loudly if PuSH hub is unavailable' do stub_request(:post, 'http://hub.example.com/').to_return(status: 503) - expect { subject.call(account) }.to raise_error(/Subscription attempt failed/) + expect { subject.call(account) }.to raise_error Mastodon::UnexpectedResponseError end it 'fails loudly if rate limited' do stub_request(:post, 'http://hub.example.com/').to_return(status: 429) - expect { subject.call(account) }.to raise_error(/Subscription attempt failed/) + expect { subject.call(account) }.to raise_error Mastodon::UnexpectedResponseError end end diff --git a/spec/workers/pubsubhubbub/delivery_worker_spec.rb b/spec/workers/pubsubhubbub/delivery_worker_spec.rb index a83245786b..b720015680 100644 --- a/spec/workers/pubsubhubbub/delivery_worker_spec.rb +++ b/spec/workers/pubsubhubbub/delivery_worker_spec.rb @@ -26,7 +26,7 @@ describe Pubsubhubbub::DeliveryWorker do subscription = Fabricate(:subscription) stub_request_to_respond_with(subscription, 500) - expect { subject.perform(subscription.id, payload) }.to raise_error(/Delivery failed/) + expect { subject.perform(subscription.id, payload) }.to raise_error Mastodon::UnexpectedResponseError end it 'updates subscriptions when delivery succeeds' do