From fca183968e4a868c8930ba3ac8fe22cef0c07f54 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 24 Nov 2016 23:09:53 +0100 Subject: [PATCH 1/4] Center header in account column, hide media in "muted" status components (notifications) --- app/assets/javascripts/components/components/status.jsx | 2 +- .../components/features/account/components/header.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/components/components/status.jsx b/app/assets/javascripts/components/components/status.jsx index 603561ab38..df5f0f2c24 100644 --- a/app/assets/javascripts/components/components/status.jsx +++ b/app/assets/javascripts/components/components/status.jsx @@ -82,7 +82,7 @@ const Status = React.createClass({ ); } - if (status.get('media_attachments').size > 0) { + if (status.get('media_attachments').size > 0 && !this.props.muted) { if (status.getIn(['media_attachments', 0, 'type']) === 'video') { media = ; } else { diff --git a/app/assets/javascripts/components/features/account/components/header.jsx b/app/assets/javascripts/components/features/account/components/header.jsx index d39a060620..b890e15c19 100644 --- a/app/assets/javascripts/components/features/account/components/header.jsx +++ b/app/assets/javascripts/components/features/account/components/header.jsx @@ -47,7 +47,7 @@ const Header = React.createClass({ const displayNameHTML = { __html: emojify(escapeTextContentForBrowser(displayName)) }; return ( -
+
From 8efa081f210d72ed450c39ac4cde0fd84fb3d3fb Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 24 Nov 2016 23:46:27 +0100 Subject: [PATCH 2/4] Remove Neo4J --- Dockerfile.app => Dockerfile | 0 Dockerfile.neo4j | 17 ---- Gemfile | 1 - Gemfile.lock | 11 --- .../components/actions/suggestions.jsx | 37 -------- .../compose/components/suggestions_box.jsx | 86 ------------------- .../containers/suggestions_container.jsx | 8 -- .../components/features/compose/index.jsx | 15 +--- .../javascripts/components/locales/de.jsx | 2 - .../javascripts/components/locales/en.jsx | 2 - .../javascripts/components/locales/es.jsx | 2 - .../javascripts/components/locales/fr.jsx | 2 - .../javascripts/components/locales/pt.jsx | 2 - .../components/reducers/user_lists.jsx | 4 - app/controllers/api/v1/accounts_controller.rb | 10 --- app/models/account.rb | 9 -- app/models/follow.rb | 28 ------ app/models/follow_suggestion.rb | 50 ----------- config/initializers/neography.rb | 5 -- config/routes.rb | 2 - docker-compose.yml | 15 +--- lib/tasks/mastodon.rake | 7 -- .../api/v1/accounts_controller_spec.rb | 14 --- 23 files changed, 6 insertions(+), 323 deletions(-) rename Dockerfile.app => Dockerfile (100%) delete mode 100644 Dockerfile.neo4j delete mode 100644 app/assets/javascripts/components/actions/suggestions.jsx delete mode 100644 app/assets/javascripts/components/features/compose/components/suggestions_box.jsx delete mode 100644 app/assets/javascripts/components/features/compose/containers/suggestions_container.jsx delete mode 100644 app/models/follow_suggestion.rb delete mode 100644 config/initializers/neography.rb diff --git a/Dockerfile.app b/Dockerfile similarity index 100% rename from Dockerfile.app rename to Dockerfile diff --git a/Dockerfile.neo4j b/Dockerfile.neo4j deleted file mode 100644 index 373c2abb0f..0000000000 --- a/Dockerfile.neo4j +++ /dev/null @@ -1,17 +0,0 @@ -FROM neo4j:latest - -ENV NEO4J_AUTH=none - -RUN cd /var/lib/neo4j/plugins \ - && wget http://products.graphaware.com/download/framework-server-community/graphaware-server-community-all-3.0.6.43.jar \ - && wget http://products.graphaware.com/download/noderank/graphaware-noderank-3.0.6.43.3.jar -RUN echo "dbms.unmanaged_extension_classes=com.graphaware.server=/graphaware" >> /var/lib/neo4j/conf/neo4j.conf -RUN echo 'com.graphaware.runtime.enabled=true\n\ -com.graphaware.module.NR.1=com.graphaware.module.noderank.NodeRankModuleBootstrapper\n\ -com.graphaware.module.NR.maxTopRankNodes=10\n\ -com.graphaware.module.NR.dampingFactor=0.85\n\ -com.graphaware.module.NR.propertyKey=nodeRank\n'\ - >> /var/lib/neo4j/conf/neo4j.conf -RUN echo 'com.graphaware.runtime.stats.disabled=true\n\ -com.graphaware.server.stats.disabled=true\n'\ - >> /var/lib/neo4j/conf/neo4j.conf diff --git a/Gemfile b/Gemfile index 4abed33ffe..40f7a40022 100644 --- a/Gemfile +++ b/Gemfile @@ -43,7 +43,6 @@ gem 'rack-attack' gem 'rack-cors', require: 'rack/cors' gem 'sidekiq' gem 'ledermann-rails-settings' -gem 'neography' gem 'pg_search' gem 'react-rails' diff --git a/Gemfile.lock b/Gemfile.lock index b058ae940a..4a72b6b934 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -132,7 +132,6 @@ GEM thread thread_safe erubis (2.7.0) - excon (0.53.0) execjs (2.7.0) fabrication (2.15.2) fast_blank (1.0.0) @@ -213,19 +212,11 @@ GEM mini_portile2 (2.1.0) minitest (5.9.1) multi_json (1.12.1) - neography (1.8.0) - excon (>= 0.33.0) - json (>= 1.7.7) - multi_json (>= 1.3.2) - os (>= 0.9.6) - rake (>= 0.8.7) - rubyzip (>= 1.0.0) nio4r (1.2.1) nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) oj (2.17.3) orm_adapter (0.5.0) - os (0.9.6) ostatus2 (1.0.2) addressable (~> 2.4) http (~> 2.0) @@ -339,7 +330,6 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.8.1) - rubyzip (1.2.0) safe_yaml (1.0.4) sass (3.4.22) sass-rails (5.0.6) @@ -435,7 +425,6 @@ DEPENDENCIES letter_opener link_header lograge - neography nokogiri oj ostatus2 diff --git a/app/assets/javascripts/components/actions/suggestions.jsx b/app/assets/javascripts/components/actions/suggestions.jsx deleted file mode 100644 index 6b3aa69dd5..0000000000 --- a/app/assets/javascripts/components/actions/suggestions.jsx +++ /dev/null @@ -1,37 +0,0 @@ -import api from '../api'; - -export const SUGGESTIONS_FETCH_REQUEST = 'SUGGESTIONS_FETCH_REQUEST'; -export const SUGGESTIONS_FETCH_SUCCESS = 'SUGGESTIONS_FETCH_SUCCESS'; -export const SUGGESTIONS_FETCH_FAIL = 'SUGGESTIONS_FETCH_FAIL'; - -export function fetchSuggestions() { - return (dispatch, getState) => { - dispatch(fetchSuggestionsRequest()); - - api(getState).get('/api/v1/accounts/suggestions').then(response => { - dispatch(fetchSuggestionsSuccess(response.data)); - }).catch(error => { - dispatch(fetchSuggestionsFail(error)); - }); - }; -}; - -export function fetchSuggestionsRequest() { - return { - type: SUGGESTIONS_FETCH_REQUEST - }; -}; - -export function fetchSuggestionsSuccess(accounts) { - return { - type: SUGGESTIONS_FETCH_SUCCESS, - accounts: accounts - }; -}; - -export function fetchSuggestionsFail(error) { - return { - type: SUGGESTIONS_FETCH_FAIL, - error: error - }; -}; diff --git a/app/assets/javascripts/components/features/compose/components/suggestions_box.jsx b/app/assets/javascripts/components/features/compose/components/suggestions_box.jsx deleted file mode 100644 index 6850629ba3..0000000000 --- a/app/assets/javascripts/components/features/compose/components/suggestions_box.jsx +++ /dev/null @@ -1,86 +0,0 @@ -import PureRenderMixin from 'react-addons-pure-render-mixin'; -import ImmutablePropTypes from 'react-immutable-proptypes'; -import AccountContainer from '../../../containers/account_container'; -import { FormattedMessage } from 'react-intl'; - -const outerStyle = { - position: 'relative' -}; - -const headerStyle = { - fontSize: '14px', - fontWeight: '500', - display: 'block', - padding: '10px', - color: '#9baec8', - background: '#454b5e', - overflow: 'hidden' -}; - -const nextStyle = { - display: 'inline-block', - float: 'right', - fontWeight: '400', - color: '#2b90d9' -}; - -const SuggestionsBox = React.createClass({ - - propTypes: { - accountIds: ImmutablePropTypes.list, - perWindow: React.PropTypes.number - }, - - getInitialState () { - return { - index: 0 - }; - }, - - getDefaultProps () { - return { - perWindow: 2 - }; - }, - - mixins: [PureRenderMixin], - - handleNextClick (e) { - e.preventDefault(); - - let newIndex = this.state.index + 1; - - if (this.props.accountIds.skip(this.props.perWindow * newIndex).size === 0) { - newIndex = 0; - } - - this.setState({ index: newIndex }); - }, - - render () { - const { accountIds, perWindow } = this.props; - - if (!accountIds || accountIds.size === 0) { - return
; - } - - let nextLink = ''; - - if (accountIds.size > perWindow) { - nextLink = ; - } - - return ( -
- - {nextLink} - - - {accountIds.skip(perWindow * this.state.index).take(perWindow).map(accountId => )} -
- ); - } - -}); - -export default SuggestionsBox; diff --git a/app/assets/javascripts/components/features/compose/containers/suggestions_container.jsx b/app/assets/javascripts/components/features/compose/containers/suggestions_container.jsx deleted file mode 100644 index 944ceed85b..0000000000 --- a/app/assets/javascripts/components/features/compose/containers/suggestions_container.jsx +++ /dev/null @@ -1,8 +0,0 @@ -import { connect } from 'react-redux'; -import SuggestionsBox from '../components/suggestions_box'; - -const mapStateToProps = (state) => ({ - accountIds: state.getIn(['user_lists', 'suggestions']) -}); - -export default connect(mapStateToProps)(SuggestionsBox); diff --git a/app/assets/javascripts/components/features/compose/index.jsx b/app/assets/javascripts/components/features/compose/index.jsx index 5c1b22e008..4017c8949f 100644 --- a/app/assets/javascripts/components/features/compose/index.jsx +++ b/app/assets/javascripts/components/features/compose/index.jsx @@ -3,9 +3,7 @@ import ComposeFormContainer from './containers/compose_form_container'; import UploadFormContainer from './containers/upload_form_container'; import NavigationContainer from './containers/navigation_container'; import PureRenderMixin from 'react-addons-pure-render-mixin'; -import SuggestionsContainer from './containers/suggestions_container'; import SearchContainer from './containers/search_container'; -import { fetchSuggestions } from '../../actions/suggestions'; import { connect } from 'react-redux'; import { mountCompose, unmountCompose } from '../../actions/compose'; @@ -19,7 +17,6 @@ const Compose = React.createClass({ componentDidMount () { this.props.dispatch(mountCompose()); - this.props.dispatch(fetchSuggestions()); }, componentWillUnmount () { @@ -29,14 +26,10 @@ const Compose = React.createClass({ render () { return ( -
- - - - -
- - + + + +
); } diff --git a/app/assets/javascripts/components/locales/de.jsx b/app/assets/javascripts/components/locales/de.jsx index 85412635e0..4e2a70edbb 100644 --- a/app/assets/javascripts/components/locales/de.jsx +++ b/app/assets/javascripts/components/locales/de.jsx @@ -41,8 +41,6 @@ const en = { "search.placeholder": "Suche", "search.account": "Konto", "search.hashtag": "Hashtag", - "suggestions_box.who_to_follow": "Wem folgen", - "suggestions_box.refresh": "Aktualisieren", "upload_button.label": "Media-Datei anfügen", "upload_form.undo": "Entfernen", "notification.follow": "{name} folgt dir", diff --git a/app/assets/javascripts/components/locales/en.jsx b/app/assets/javascripts/components/locales/en.jsx index 0ea324f66f..e6ae25453c 100644 --- a/app/assets/javascripts/components/locales/en.jsx +++ b/app/assets/javascripts/components/locales/en.jsx @@ -45,8 +45,6 @@ const en = { "search.placeholder": "Search", "search.account": "Account", "search.hashtag": "Hashtag", - "suggestions_box.who_to_follow": "Who to follow", - "suggestions_box.refresh": "Refresh", "upload_button.label": "Add media", "upload_form.undo": "Undo", "notification.follow": "{name} followed you", diff --git a/app/assets/javascripts/components/locales/es.jsx b/app/assets/javascripts/components/locales/es.jsx index 47377e5aec..d4434bba7e 100644 --- a/app/assets/javascripts/components/locales/es.jsx +++ b/app/assets/javascripts/components/locales/es.jsx @@ -42,8 +42,6 @@ const es = { "search.placeholder": "Buscar", "search.account": "Cuenta", "search.hashtag": "Etiqueta", - "suggestions_box.who_to_follow": "A quién seguir", - "suggestions_box.refresh": "Refrescar", "upload_button.label": "Añadir medio", "upload_form.undo": "Deshacer", "notification.follow": "{name} le esta ahora siguiendo", diff --git a/app/assets/javascripts/components/locales/fr.jsx b/app/assets/javascripts/components/locales/fr.jsx index 0cf4c5d526..4673305f70 100644 --- a/app/assets/javascripts/components/locales/fr.jsx +++ b/app/assets/javascripts/components/locales/fr.jsx @@ -41,8 +41,6 @@ const fr = { "search.placeholder": "Chercher", "search.account": "Compte", "search.hashtag": "Mot-clé", - "suggestions_box.who_to_follow": "Suggestions", - "suggestions_box.refresh": "Rafraîchir", "upload_button.label": "Joindre un média", "upload_form.undo": "Annuler", "notification.follow": "{name} s’est abonné⋅e à vos statuts", diff --git a/app/assets/javascripts/components/locales/pt.jsx b/app/assets/javascripts/components/locales/pt.jsx index 02b21f3cb8..e67bd80acb 100644 --- a/app/assets/javascripts/components/locales/pt.jsx +++ b/app/assets/javascripts/components/locales/pt.jsx @@ -40,8 +40,6 @@ const pt = { "search.placeholder": "Busca", "search.account": "Conta", "search.hashtag": "Hashtag", - "suggestions_box.who_to_follow": "Quem seguir", - "suggestions_box.refresh": "Recarregar", "upload_button.label": "Adicionar media", "upload_form.undo": "Desfazer" }; diff --git a/app/assets/javascripts/components/reducers/user_lists.jsx b/app/assets/javascripts/components/reducers/user_lists.jsx index 65598f8a04..3608e42097 100644 --- a/app/assets/javascripts/components/reducers/user_lists.jsx +++ b/app/assets/javascripts/components/reducers/user_lists.jsx @@ -4,7 +4,6 @@ import { FOLLOWING_FETCH_SUCCESS, FOLLOWING_EXPAND_SUCCESS } from '../actions/accounts'; -import { SUGGESTIONS_FETCH_SUCCESS } from '../actions/suggestions'; import { REBLOGS_FETCH_SUCCESS, FAVOURITES_FETCH_SUCCESS @@ -14,7 +13,6 @@ import Immutable from 'immutable'; const initialState = Immutable.Map({ followers: Immutable.Map(), following: Immutable.Map(), - suggestions: Immutable.List(), reblogged_by: Immutable.Map(), favourited_by: Immutable.Map() }); @@ -42,8 +40,6 @@ export default function userLists(state = initialState, action) { return normalizeList(state, 'following', action.id, action.accounts, action.next); case FOLLOWING_EXPAND_SUCCESS: return appendToList(state, 'following', action.id, action.accounts, action.next); - case SUGGESTIONS_FETCH_SUCCESS: - return state.set('suggestions', Immutable.List(action.accounts.map(item => item.id))); case REBLOGS_FETCH_SUCCESS: return state.setIn(['reblogged_by', action.id], Immutable.List(action.accounts.map(item => item.id))); case FAVOURITES_FETCH_SUCCESS: diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb index 4ae9005830..5546ee5883 100644 --- a/app/controllers/api/v1/accounts_controller.rb +++ b/app/controllers/api/v1/accounts_controller.rb @@ -46,16 +46,6 @@ class Api::V1::AccountsController < ApiController render action: :index end - def common_followers - @accounts = @account.common_followers_with(current_user.account) - render action: :index - end - - def suggestions - @accounts = FollowSuggestion.get(current_user.account_id) - render action: :index - end - def statuses @statuses = @account.statuses.paginate_by_max_id(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]).to_a @statuses = cache(@statuses) diff --git a/app/models/account.rb b/app/models/account.rb index 16d654195f..a60a23e14e 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -130,15 +130,6 @@ class Account < ApplicationRecord username end - def common_followers_with(other_account) - results = Neography::Rest.new.execute_query('MATCH (a {account_id: {a_id}})-[:follows]->(b)-[:follows]->(c {account_id: {c_id}}) RETURN b.account_id', a_id: id, c_id: other_account.id) - ids = results['data'].map(&:first) - accounts = Account.where(id: ids).with_counters.limit(20).map { |a| [a.id, a] }.to_h - ids.map { |id| accounts[id] }.compact - rescue Neography::NeographyError, Excon::Error::Socket - [] - end - class << self def find_local!(username) find_remote!(username, nil) diff --git a/app/models/follow.rb b/app/models/follow.rb index cc5bceb752..f83490caad 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -27,32 +27,4 @@ class Follow < ApplicationRecord def title destroyed? ? "#{account.acct} is no longer following #{target_account.acct}" : "#{account.acct} started following #{target_account.acct}" end - - after_create :add_to_graph - after_destroy :remove_from_graph - - def sync! - add_to_graph - end - - private - - def add_to_graph - neo = Neography::Rest.new - - a = neo.create_unique_node('account_index', 'Account', account_id.to_s, account_id: account_id) - b = neo.create_unique_node('account_index', 'Account', target_account_id.to_s, account_id: target_account_id) - - neo.create_unique_relationship('follow_index', 'Follow', id.to_s, 'follows', a, b) - rescue Neography::NeographyError, Excon::Error::Socket => e - Rails.logger.error e - end - - def remove_from_graph - neo = Neography::Rest.new - rel = neo.get_relationship_index('follow_index', 'Follow', id.to_s) - neo.delete_relationship(rel) - rescue Neography::NeographyError, Excon::Error::Socket => e - Rails.logger.error e - end end diff --git a/app/models/follow_suggestion.rb b/app/models/follow_suggestion.rb deleted file mode 100644 index 2daa40dcb9..0000000000 --- a/app/models/follow_suggestion.rb +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -class FollowSuggestion - class << self - def get(for_account_id, limit = 10) - neo = Neography::Rest.new - - query = <(b)-[:follows]->(c) -WHERE a <> c -AND NOT (a)-[:follows]->(c) -RETURN DISTINCT c.account_id, count(b), c.nodeRank -ORDER BY count(b) DESC, c.nodeRank DESC -LIMIT {limit} -END - - results = neo.execute_query(query, id: for_account_id, limit: limit) - - if results.empty? || results['data'].empty? - results = fallback(for_account_id, limit) - elsif results['data'].size < limit - results['data'] = (results['data'] + fallback(for_account_id, limit - results['data'].size)['data']).uniq - end - - account_ids = results['data'].map(&:first) - blocked_ids = Block.where(account_id: for_account_id).pluck(:target_account_id) - accounts_map = Account.where(id: account_ids - blocked_ids).with_counters.map { |a| [a.id, a] }.to_h - - account_ids.map { |id| accounts_map[id] }.compact - rescue Neography::NeographyError, Excon::Error::Socket => e - Rails.logger.error e - return [] - end - - private - - def fallback(for_account_id, limit) - neo = Neography::Rest.new - - query = < Date: Thu, 24 Nov 2016 23:49:45 +0100 Subject: [PATCH 3/4] Fix forgotten reference --- app/assets/javascripts/components/reducers/accounts.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/javascripts/components/reducers/accounts.jsx b/app/assets/javascripts/components/reducers/accounts.jsx index 68247a98c7..a7e4a28306 100644 --- a/app/assets/javascripts/components/reducers/accounts.jsx +++ b/app/assets/javascripts/components/reducers/accounts.jsx @@ -8,7 +8,6 @@ import { ACCOUNT_TIMELINE_FETCH_SUCCESS, ACCOUNT_TIMELINE_EXPAND_SUCCESS } from '../actions/accounts'; -import { SUGGESTIONS_FETCH_SUCCESS } from '../actions/suggestions'; import { COMPOSE_SUGGESTIONS_READY } from '../actions/compose'; import { REBLOG_SUCCESS, From 543d06971e461510591ff64ebc666bd414e8e084 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 24 Nov 2016 23:56:37 +0100 Subject: [PATCH 4/4] Fix bad reference --- app/assets/javascripts/components/reducers/accounts.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/javascripts/components/reducers/accounts.jsx b/app/assets/javascripts/components/reducers/accounts.jsx index a7e4a28306..52be648b3e 100644 --- a/app/assets/javascripts/components/reducers/accounts.jsx +++ b/app/assets/javascripts/components/reducers/accounts.jsx @@ -70,7 +70,6 @@ export default function accounts(state = initialState, action) { case ACCOUNT_FETCH_SUCCESS: case NOTIFICATIONS_UPDATE: return normalizeAccount(state, action.account); - case SUGGESTIONS_FETCH_SUCCESS: case FOLLOWERS_FETCH_SUCCESS: case FOLLOWERS_EXPAND_SUCCESS: case FOLLOWING_FETCH_SUCCESS: