diff options
author | David Yip <yipdw@member.fsf.org> | 2018-05-18 07:53:04 -0500 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2018-05-18 08:47:10 -0500 |
commit | e0eebba46192e5ef2050347069c4098d33e9ec54 (patch) | |
tree | e58d15f7bd6d5c5f5ce53d880a7ad89bf3faaab2 /app/lib | |
parent | 4c0770d6c8dac8177b8891a6fb97ccf440100fc2 (diff) | |
parent | 57b503d4ef0754e4651eae26b628cba60e1ab4e9 (diff) |
Merge remote-tracking branch 'origin/master' into merge-upstream
Conflicts: app/controllers/follower_accounts_controller.rb app/controllers/following_accounts_controller.rb app/controllers/settings/preferences_controller.rb app/lib/user_settings_decorator.rb app/models/user.rb config/locales/simple_form.en.yml
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/activitypub/activity.rb | 9 | ||||
-rw-r--r-- | app/lib/activitypub/activity/add.rb | 5 | ||||
-rw-r--r-- | app/lib/activitypub/activity/announce.rb | 10 | ||||
-rw-r--r-- | app/lib/activitypub/activity/remove.rb | 2 | ||||
-rw-r--r-- | app/lib/user_settings_decorator.rb | 5 |
5 files changed, 18 insertions, 13 deletions
diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index 84d4b1752..03476920b 100644 --- a/app/lib/activitypub/activity.rb +++ b/app/lib/activitypub/activity.rb @@ -118,4 +118,13 @@ class ActivityPub::Activity def delete_later!(uri) redis.setex("delete_upon_arrival:#{@account.id}:#{uri}", 6.hours.seconds, uri) end + + def fetch_remote_original_status + if object_uri.start_with?('http') + return if ActivityPub::TagManager.instance.local_uri?(object_uri) + ActivityPub::FetchRemoteStatusService.new.call(object_uri, id: true, on_behalf_of: @account.followers.local.first) + elsif @object['url'].present? + ::FetchRemoteStatusService.new.call(@object['url']) + end + end end diff --git a/app/lib/activitypub/activity/add.rb b/app/lib/activitypub/activity/add.rb index ea94d2f98..688ab00b3 100644 --- a/app/lib/activitypub/activity/add.rb +++ b/app/lib/activitypub/activity/add.rb @@ -4,9 +4,10 @@ class ActivityPub::Activity::Add < ActivityPub::Activity def perform return unless @json['target'].present? && value_or_id(@json['target']) == @account.featured_collection_url - status = status_from_uri(object_uri) + status = status_from_uri(object_uri) + status ||= fetch_remote_original_status - return unless status.account_id == @account.id && !@account.pinned?(status) + return unless !status.nil? && status.account_id == @account.id && !@account.pinned?(status) StatusPin.create!(account: @account, status: status) end diff --git a/app/lib/activitypub/activity/announce.rb b/app/lib/activitypub/activity/announce.rb index f810c88a2..1147a4481 100644 --- a/app/lib/activitypub/activity/announce.rb +++ b/app/lib/activitypub/activity/announce.rb @@ -26,16 +26,6 @@ class ActivityPub::Activity::Announce < ActivityPub::Activity private - def fetch_remote_original_status - if object_uri.start_with?('http') - return if ActivityPub::TagManager.instance.local_uri?(object_uri) - - ActivityPub::FetchRemoteStatusService.new.call(object_uri, id: true, on_behalf_of: @account.followers.local.first) - elsif @object['url'].present? - ::FetchRemoteStatusService.new.call(@object['url']) - end - end - def announceable?(status) status.account_id == @account.id || status.public_visibility? || status.unlisted_visibility? end diff --git a/app/lib/activitypub/activity/remove.rb b/app/lib/activitypub/activity/remove.rb index 62a1e3196..f523ead9f 100644 --- a/app/lib/activitypub/activity/remove.rb +++ b/app/lib/activitypub/activity/remove.rb @@ -6,7 +6,7 @@ class ActivityPub::Activity::Remove < ActivityPub::Activity status = status_from_uri(object_uri) - return unless status.account_id == @account.id + return unless !status.nil? && status.account_id == @account.id pin = StatusPin.find_by(account: @account, status: status) pin&.destroy! diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index 78b3aa77c..f8bacb036 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -30,6 +30,7 @@ class UserSettingsDecorator user.settings['noindex'] = noindex_preference if change?('setting_noindex') user.settings['flavour'] = flavour_preference if change?('setting_flavour') user.settings['skin'] = skin_preference if change?('setting_skin') + user.settings['hide_network'] = hide_network_preference if change?('setting_hide_network') end def merged_notification_emails @@ -92,6 +93,10 @@ class UserSettingsDecorator settings['setting_skin'] end + def hide_network_preference + boolean_cast_setting 'setting_hide_network' + end + def boolean_cast_setting(key) ActiveModel::Type::Boolean.new.cast(settings[key]) end |