forked from fedi/mastodon
Handle remote account mentions a little better by trying a URL lookup in the db
This commit is contained in:
parent
2a84271e85
commit
b1a670af8d
|
@ -28,7 +28,8 @@ const initialState = Immutable.Map({
|
||||||
accounts_timelines: Immutable.Map(),
|
accounts_timelines: Immutable.Map(),
|
||||||
me: null,
|
me: null,
|
||||||
ancestors: Immutable.Map(),
|
ancestors: Immutable.Map(),
|
||||||
descendants: Immutable.Map()
|
descendants: Immutable.Map(),
|
||||||
|
relationships: Immutable.Map()
|
||||||
});
|
});
|
||||||
|
|
||||||
export function selectStatus(state, id) {
|
export function selectStatus(state, id) {
|
||||||
|
@ -142,6 +143,11 @@ function normalizeAccount(state, account) {
|
||||||
return state.setIn(['accounts', account.get('id')], 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) {
|
function normalizeContext(state, status, ancestors, descendants) {
|
||||||
state = normalizeStatus(state, status);
|
state = normalizeStatus(state, status);
|
||||||
|
|
||||||
|
@ -175,10 +181,7 @@ export default function timelines(state = initialState, action) {
|
||||||
case FAVOURITE_SUCCESS:
|
case FAVOURITE_SUCCESS:
|
||||||
return normalizeStatus(state, Immutable.fromJS(action.response));
|
return normalizeStatus(state, Immutable.fromJS(action.response));
|
||||||
case ACCOUNT_SET_SELF:
|
case ACCOUNT_SET_SELF:
|
||||||
return state.withMutations(map => {
|
return setSelf(state, Immutable.fromJS(action.account));
|
||||||
map.setIn(['accounts', action.account.id], Immutable.fromJS(action.account));
|
|
||||||
map.set('me', action.account.id);
|
|
||||||
});
|
|
||||||
case ACCOUNT_FETCH_SUCCESS:
|
case ACCOUNT_FETCH_SUCCESS:
|
||||||
case FOLLOW_SUBMIT_SUCCESS:
|
case FOLLOW_SUBMIT_SUCCESS:
|
||||||
case ACCOUNT_FOLLOW_SUCCESS:
|
case ACCOUNT_FOLLOW_SUCCESS:
|
||||||
|
|
|
@ -69,9 +69,12 @@ class ProcessFeedService < BaseService
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# What to do about remote user?
|
# What to do about remote user?
|
||||||
# Are we supposed to do a search in the database by URL?
|
# This is kinda dodgy because URLs could change, we don't index them
|
||||||
# We could technically open the URL, look for LRDD tags, get webfinger that way,
|
mentioned_account = Account.find_by(url: href.to_s)
|
||||||
# finally acquire the acct:username@domain form, and then check DB
|
|
||||||
|
unless mentioned_account.nil?
|
||||||
|
mentioned_account.mentions.where(status: status).first_or_create(status: status)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue