logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe
commit: b1a670af8d098c33a8938662f5c0bd60674ea683
parent: 2a84271e85564928c4b5e241d7d3bde69fef40ed
Author: Eugen Rochko <eugen@zeonfederated.com>
Date:   Thu, 22 Sep 2016 21:10:36 +0200

Handle remote account mentions a little  better by trying a URL lookup in the db

Diffstat:

Mapp/assets/javascripts/components/reducers/timelines.jsx13++++++++-----
Mapp/services/process_feed_service.rb9++++++---
2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/app/assets/javascripts/components/reducers/timelines.jsx b/app/assets/javascripts/components/reducers/timelines.jsx @@ -28,7 +28,8 @@ const initialState = Immutable.Map({ accounts_timelines: Immutable.Map(), me: null, ancestors: Immutable.Map(), - descendants: Immutable.Map() + descendants: Immutable.Map(), + relationships: Immutable.Map() }); export function selectStatus(state, id) { @@ -142,6 +143,11 @@ function normalizeAccount(state, account) { return state.setIn(['accounts', account.get('id')], account); }; +function setSelf(state, account) { + state = normalizeAccount(state, account); + return state.set('me', account.get('id')); +}; + function normalizeContext(state, status, ancestors, descendants) { state = normalizeStatus(state, status); @@ -175,10 +181,7 @@ export default function timelines(state = initialState, action) { case FAVOURITE_SUCCESS: return normalizeStatus(state, Immutable.fromJS(action.response)); case ACCOUNT_SET_SELF: - return state.withMutations(map => { - map.setIn(['accounts', action.account.id], Immutable.fromJS(action.account)); - map.set('me', action.account.id); - }); + return setSelf(state, Immutable.fromJS(action.account)); case ACCOUNT_FETCH_SUCCESS: case FOLLOW_SUBMIT_SUCCESS: case ACCOUNT_FOLLOW_SUCCESS: diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb @@ -69,9 +69,12 @@ class ProcessFeedService < BaseService end else # What to do about remote user? - # Are we supposed to do a search in the database by URL? - # We could technically open the URL, look for LRDD tags, get webfinger that way, - # finally acquire the acct:username@domain form, and then check DB + # This is kinda dodgy because URLs could change, we don't index them + mentioned_account = Account.find_by(url: href.to_s) + + unless mentioned_account.nil? + mentioned_account.mentions.where(status: status).first_or_create(status: status) + end end end end