Browse Source

Merge branch 'master' into glitch-soc/merge-upstream

Thibaut Girka 4 months ago
parent
commit
dfe7322922

+ 12
- 1
Vagrantfile View File

@@ -44,7 +44,18 @@ sudo apt-get install \
44 44
 
45 45
 # Install rvm
46 46
 read RUBY_VERSION < .ruby-version
47
-gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
47
+
48
+gpg_command="gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB"
49
+$($gpg_command)
50
+if [ $? -ne 0 ];then
51
+  echo "GPG command failed, This prevented RVM from installing."
52
+  echo "Retrying once..." && $($gpg_command)
53
+  if [ $? -ne 0 ];then
54
+    echo "GPG failed for the second time, please ensure network connectivity."
55
+    echo "Exiting..." && exit 1
56
+  fi
57
+fi
58
+
48 59
 curl -sSL https://raw.githubusercontent.com/rvm/rvm/stable/binscripts/rvm-installer | bash -s stable --ruby=$RUBY_VERSION
49 60
 source /home/vagrant/.rvm/scripts/rvm
50 61
 

+ 17
- 0
app/services/suspend_account_service.rb View File

@@ -41,6 +41,7 @@ class SuspendAccountService < BaseService
41 41
     @account = account
42 42
     @options = options
43 43
 
44
+    reject_follows!
44 45
     purge_user!
45 46
     purge_profile!
46 47
     purge_content!
@@ -48,6 +49,14 @@ class SuspendAccountService < BaseService
48 49
 
49 50
   private
50 51
 
52
+  def reject_follows!
53
+    return if @account.local? || !@account.activitypub?
54
+
55
+    ActivityPub::DeliveryWorker.push_bulk(Follow.where(account: @account)) do |follow|
56
+      [build_reject_json(follow), follow.target_account_id, follow.account.inbox_url]
57
+    end
58
+  end
59
+
51 60
   def purge_user!
52 61
     return if !@account.local? || @account.user.nil?
53 62
 
@@ -120,6 +129,14 @@ class SuspendAccountService < BaseService
120 129
     @delete_actor_json = Oj.dump(ActivityPub::LinkedDataSignature.new(payload).sign!(@account))
121 130
   end
122 131
 
132
+  def build_reject_json(follow)
133
+    ActiveModelSerializers::SerializableResource.new(
134
+      follow,
135
+      serializer: ActivityPub::RejectFollowSerializer,
136
+      adapter: ActivityPub::Adapter
137
+    ).to_json
138
+  end
139
+
123 140
   def delivery_inboxes
124 141
     @delivery_inboxes ||= @account.followers.inboxes + Relay.enabled.pluck(:inbox_url)
125 142
   end

+ 1
- 1
app/views/about/_forms.html.haml View File

@@ -1,7 +1,7 @@
1 1
 - if @instance_presenter.open_registrations
2 2
   = render 'registration'
3 3
 - else
4
-  = link_to t('auth.register_elsewhere'), 'https://joinmastodon.org', class: 'button button-primary'
4
+  = link_to t('auth.register_elsewhere'), 'https://joinmastodon.org/#getting-started', class: 'button button-primary'
5 5
 
6 6
   .closed-registrations-message
7 7
     - if @instance_presenter.closed_registrations_message.blank?

+ 1
- 1
app/views/about/_links.html.haml View File

@@ -11,6 +11,6 @@
11 11
         = link_to t('auth.login'), new_user_session_path, class: 'webapp-btn'
12 12
     %li= link_to t('about.about_this'), about_more_path
13 13
     %li
14
-      = link_to 'https://joinmastodon.org/' do
14
+      = link_to 'https://joinmastodon.org/#getting-started' do
15 15
         = "#{t('about.other_instances')}"
16 16
         %i.fa.fa-external-link{ style: 'padding-left: 5px;' }

+ 43
- 1
spec/services/suspend_account_service_spec.rb View File

@@ -1,7 +1,7 @@
1 1
 require 'rails_helper'
2 2
 
3 3
 RSpec.describe SuspendAccountService, type: :service do
4
-  describe '#call' do
4
+  describe '#call on local account' do
5 5
     before do
6 6
       stub_request(:post, "https://alice.com/inbox").to_return(status: 201)
7 7
       stub_request(:post, "https://bob.com/inbox").to_return(status: 201)
@@ -43,4 +43,46 @@ RSpec.describe SuspendAccountService, type: :service do
43 43
       expect(a_request(:post, "https://bob.com/inbox")).to have_been_made.once
44 44
     end
45 45
   end
46
+
47
+  describe '#call on remote account' do
48
+    before do
49
+      stub_request(:post, "https://alice.com/inbox").to_return(status: 201)
50
+      stub_request(:post, "https://bob.com/inbox").to_return(status: 201)
51
+    end
52
+
53
+    subject do
54
+      -> { described_class.new.call(remote_bob) }
55
+    end
56
+
57
+    let!(:account) { Fabricate(:account) }
58
+    let!(:remote_alice) { Fabricate(:account, inbox_url: 'https://alice.com/inbox', protocol: :activitypub) }
59
+    let!(:remote_bob) { Fabricate(:account, inbox_url: 'https://bob.com/inbox', protocol: :activitypub) }
60
+    let!(:status) { Fabricate(:status, account: remote_bob) }
61
+    let!(:media_attachment) { Fabricate(:media_attachment, account: remote_bob) }
62
+    let!(:notification) { Fabricate(:notification, account: remote_bob) }
63
+    let!(:favourite) { Fabricate(:favourite, account: remote_bob) }
64
+    let!(:active_relationship) { Fabricate(:follow, account: remote_bob, target_account: account) }
65
+    let!(:passive_relationship) { Fabricate(:follow, target_account: remote_bob) }
66
+    let!(:subscription) { Fabricate(:subscription, account: remote_bob) }
67
+
68
+    it 'deletes associated records' do
69
+      is_expected.to change {
70
+        [
71
+          remote_bob.statuses,
72
+          remote_bob.media_attachments,
73
+          remote_bob.stream_entries,
74
+          remote_bob.notifications,
75
+          remote_bob.favourites,
76
+          remote_bob.active_relationships,
77
+          remote_bob.passive_relationships,
78
+          remote_bob.subscriptions
79
+        ].map(&:count)
80
+      }.from([1, 1, 1, 1, 1, 1, 1, 1]).to([0, 0, 0, 0, 0, 0, 0, 0])
81
+    end
82
+
83
+    it 'sends a reject follow to follwer inboxes' do
84
+      subject.call
85
+      expect(a_request(:post, remote_bob.inbox_url)).to have_been_made.once
86
+    end
87
+  end
46 88
 end

+ 5
- 9
streaming/index.js View File

@@ -24,7 +24,7 @@ const dbUrlToConfig = (dbUrl) => {
24 24
     return {};
25 25
   }
26 26
 
27
-  const params = url.parse(dbUrl);
27
+  const params = url.parse(dbUrl, true);
28 28
   const config = {};
29 29
 
30 30
   if (params.auth) {
@@ -45,8 +45,8 @@ const dbUrlToConfig = (dbUrl) => {
45 45
 
46 46
   const ssl = params.query && params.query.ssl;
47 47
 
48
-  if (ssl) {
49
-    config.ssl = ssl === 'true' || ssl === '1';
48
+  if (ssl && ssl === 'true' || ssl === '1') {
49
+    config.ssl = true;
50 50
   }
51 51
 
52 52
   return config;
@@ -89,9 +89,7 @@ const startWorker = (workerId) => {
89 89
       host:     process.env.DB_HOST || pg.defaults.host,
90 90
       port:     process.env.DB_PORT || pg.defaults.port,
91 91
       max:      10,
92
-      ssl: {
93
-        sslmode: process.env.DB_SSLMODE || 'prefer',
94
-      },
92
+      ssl:      !!process.env.DB_SSLMODE && process.env.DB_SSLMODE !== 'disable' ? true : undefined,
95 93
     },
96 94
 
97 95
     production: {
@@ -101,9 +99,7 @@ const startWorker = (workerId) => {
101 99
       host:     process.env.DB_HOST || 'localhost',
102 100
       port:     process.env.DB_PORT || 5432,
103 101
       max:      10,
104
-      ssl: {
105
-        sslmode: process.env.DB_SSLMODE || 'prefer',
106
-      },
102
+      ssl:      !!process.env.DB_SSLMODE && process.env.DB_SSLMODE !== 'disable' ? true : undefined,
107 103
     },
108 104
   };
109 105
 

Loading…
Cancel
Save