about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.dockerignore1
-rw-r--r--.env.production.sample2
-rw-r--r--app/models/follow.rb4
-rw-r--r--db/seeds.rb2
-rw-r--r--docker-compose.yml6
-rw-r--r--lib/tasks/mastodon.rake7
6 files changed, 21 insertions, 1 deletions
diff --git a/.dockerignore b/.dockerignore
index fad29fc26..7892e503c 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -4,3 +4,4 @@ public/system
 public/assets
 node_modules
 storybook
+neo4j
diff --git a/.env.production.sample b/.env.production.sample
index 070aa0c3a..b68ba523c 100644
--- a/.env.production.sample
+++ b/.env.production.sample
@@ -6,6 +6,8 @@ DB_USER=postgres
 DB_NAME=postgres
 DB_PASS=
 DB_PORT=5432
+NEO4J_HOST=neo4j
+NEO4J_PORT=7474
 
 # Federation
 LOCAL_DOMAIN=example.com
diff --git a/app/models/follow.rb b/app/models/follow.rb
index 95b6bd146..656b28d35 100644
--- a/app/models/follow.rb
+++ b/app/models/follow.rb
@@ -26,6 +26,10 @@ class Follow < ApplicationRecord
   after_create  :add_to_graph
   after_destroy :remove_from_graph
 
+  def sync!
+    add_to_graph
+  end
+
   private
 
   def add_to_graph
diff --git a/db/seeds.rb b/db/seeds.rb
index c2bf6a16e..7e8ee8e44 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1,2 +1,2 @@
 web_app = Doorkeeper::Application.new(name: 'Web', superapp: true, redirect_uri: Doorkeeper.configuration.native_redirect_uri)
-web_app.save(validate: false)
+web_app.save!
diff --git a/docker-compose.yml b/docker-compose.yml
index b3b233713..18af16b60 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -4,6 +4,10 @@ services:
     image: postgres
   redis:
     image: redis
+  neo4j:
+    image: neo4j
+    environment:
+      - NEO4J_AUTH=none
   app:
     build: .
     env_file: .env.production
@@ -15,6 +19,7 @@ services:
     depends_on:
       - db
       - redis
+      - neo4j
     volumes:
       - ./public/assets:/mastodon/public/assets
       - ./public/system:/mastodon/public/system
@@ -24,5 +29,6 @@ services:
     depends_on:
       - db
       - redis
+      - neo4j
     volumes:
       - ./public/system:/mastodon/public/system
diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake
index 29e4494c4..aa07c0738 100644
--- a/lib/tasks/mastodon.rake
+++ b/lib/tasks/mastodon.rake
@@ -41,4 +41,11 @@ namespace :mastodon do
       $redis.keys('feed:*').each { |key| $redis.del(key) }
     end
   end
+
+  namespace :graphs do
+    desc 'Syncs all follow relationships to Neo4J'
+    task sync: :environment do
+      Follow.find_each(&:sync!)
+    end
+  end
 end