logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe
commit: 8c0b19012bae203f41b75cf40d6baf121f67fdea
parent: e906677092ca2f38abd918436ea5967c096d555f
Author: Eugen Rochko <eugen@zeonfederated.com>
Date:   Sat, 17 Sep 2016 16:36:10 +0200

Fix #41, debug #42

Diffstat:

Mapp/assets/javascripts/components/reducers/notifications.jsx22++++++++++++++++++----
Mapp/controllers/api/follows_controller.rb2+-
Mapp/services/follow_remote_account_service.rb8+++++++-
Mapp/views/api/follows/show.rabl2+-
4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/app/assets/javascripts/components/reducers/notifications.jsx b/app/assets/javascripts/components/reducers/notifications.jsx @@ -7,6 +7,23 @@ import Immutable from 'immutable'; const initialState = Immutable.List(); +function notificationFromError(state, error) { + let n = Immutable.Map({ + message: '' + }); + + if (error.response) { + n = n.withMutations(map => { + map.set('message', error.response.statusText); + map.set('title', `${error.response.status}`); + }); + } else { + n = n.set('message', `${error}`); + } + + return state.push(n); +}; + export default function meta(state = initialState, action) { switch(action.type) { case COMPOSE_SUBMIT_FAIL: @@ -15,10 +32,7 @@ export default function meta(state = initialState, action) { case REBLOG_FAIL: case FAVOURITE_FAIL: case TIMELINE_REFRESH_FAIL: - return state.push(Immutable.fromJS({ - message: action.error.response.statusText, - title: `${action.error.response.status}` - })); + return notificationFromError(state, action.error); case NOTIFICATION_DISMISS: return state.clear(); default: diff --git a/app/controllers/api/follows_controller.rb b/app/controllers/api/follows_controller.rb @@ -7,7 +7,7 @@ class Api::FollowsController < ApiController raise ActiveRecord::RecordNotFound end - @follow = FollowService.new.(current_user.account, params[:uri]) + @account = FollowService.new.(current_user.account, params[:uri]).try(:target_account) render action: :show end end diff --git a/app/services/follow_remote_account_service.rb b/app/services/follow_remote_account_service.rb @@ -13,8 +13,10 @@ class FollowRemoteAccountService < BaseService account = Account.find_remote(username, domain) if account.nil? + Rails.logger.debug "Creating new remote account for #{uri}" account = Account.new(username: username, domain: domain) elsif account.subscribed? + Rails.logger.debug "Already subscribed to remote account #{uri}" return account end @@ -29,7 +31,10 @@ class FollowRemoteAccountService < BaseService feed = get_feed(account.remote_url) hubs = feed.xpath('//xmlns:link[@rel="hub"]') - return nil if hubs.empty? || hubs.first.attribute('href').nil? || feed.at_xpath('/xmlns:feed/xmlns:author/xmlns:uri').nil? + if hubs.empty? || hubs.first.attribute('href').nil? || feed.at_xpath('/xmlns:feed/xmlns:author/xmlns:uri').nil? + Rails.logger.debug "Cannot find PuSH hub or author for #{uri}" + return nil + end account.uri = feed.at_xpath('/xmlns:feed/xmlns:author/xmlns:uri').content account.hub_url = hubs.first.attribute('href').value @@ -49,6 +54,7 @@ class FollowRemoteAccountService < BaseService return account rescue Goldfinger::Error, HTTP::Error + Rails.logger.debug "Error while fetching data for #{uri}" nil end diff --git a/app/views/api/follows/show.rabl b/app/views/api/follows/show.rabl @@ -1,2 +1,2 @@ -object @follow.target_account +object @account extends('api/accounts/show')