From 70e9dd0b5b2c4b2d695334d8b63c6d58cb1619d8 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 3 Oct 2016 18:49:52 +0200 Subject: [PATCH] Blocking will prevent e-mail notifications from blocked user, blocks in UI --- .../components/actions/accounts.jsx | 74 +++++++++++++++++++ .../components/status_action_bar.jsx | 2 + .../account/components/action_bar.jsx | 38 ++++++++-- .../components/features/account/index.jsx | 12 ++- .../components/reducers/timelines.jsx | 4 + app/assets/stylesheets/components.scss | 20 ++--- app/services/favourite_service.rb | 2 +- app/services/follow_service.rb | 2 +- app/services/process_feed_service.rb | 4 +- app/services/process_interaction_service.rb | 4 +- app/services/process_mentions_service.rb | 2 +- app/services/reblog_service.rb | 2 +- 12 files changed, 134 insertions(+), 32 deletions(-) diff --git a/app/assets/javascripts/components/actions/accounts.jsx b/app/assets/javascripts/components/actions/accounts.jsx index c4aa2d80..eeec405d 100644 --- a/app/assets/javascripts/components/actions/accounts.jsx +++ b/app/assets/javascripts/components/actions/accounts.jsx @@ -15,6 +15,14 @@ export const ACCOUNT_UNFOLLOW_REQUEST = 'ACCOUNT_UNFOLLOW_REQUEST'; export const ACCOUNT_UNFOLLOW_SUCCESS = 'ACCOUNT_UNFOLLOW_SUCCESS'; export const ACCOUNT_UNFOLLOW_FAIL = 'ACCOUNT_UNFOLLOW_FAIL'; +export const ACCOUNT_BLOCK_REQUEST = 'ACCOUNT_BLOCK_REQUEST'; +export const ACCOUNT_BLOCK_SUCCESS = 'ACCOUNT_BLOCK_SUCCESS'; +export const ACCOUNT_BLOCK_FAIL = 'ACCOUNT_BLOCK_FAIL'; + +export const ACCOUNT_UNBLOCK_REQUEST = 'ACCOUNT_UNBLOCK_REQUEST'; +export const ACCOUNT_UNBLOCK_SUCCESS = 'ACCOUNT_UNBLOCK_SUCCESS'; +export const ACCOUNT_UNBLOCK_FAIL = 'ACCOUNT_UNBLOCK_FAIL'; + export const ACCOUNT_TIMELINE_FETCH_REQUEST = 'ACCOUNT_TIMELINE_FETCH_REQUEST'; export const ACCOUNT_TIMELINE_FETCH_SUCCESS = 'ACCOUNT_TIMELINE_FETCH_SUCCESS'; export const ACCOUNT_TIMELINE_FETCH_FAIL = 'ACCOUNT_TIMELINE_FETCH_FAIL'; @@ -204,3 +212,69 @@ export function expandAccountTimelineFail(id, error) { error: error }; }; + +export function blockAccount(id) { + return (dispatch, getState) => { + dispatch(blockAccountRequest(id)); + + api(getState).post(`/api/v1/accounts/${id}/block`).then(response => { + dispatch(blockAccountSuccess(response.data)); + }).catch(error => { + dispatch(blockAccountFail(id, error)); + }); + }; +}; + +export function unblockAccount(id) { + return (dispatch, getState) => { + dispatch(unblockAccountRequest(id)); + + api(getState).post(`/api/v1/accounts/${id}/unblock`).then(response => { + dispatch(unblockAccountSuccess(response.data)); + }).catch(error => { + dispatch(unblockAccountFail(id, error)); + }); + }; +}; + +export function blockAccountRequest(id) { + return { + type: ACCOUNT_BLOCK_REQUEST, + id: id + }; +}; + +export function blockAccountSuccess(relationship) { + return { + type: ACCOUNT_BLOCK_SUCCESS, + relationship: relationship + }; +}; + +export function blockAccountFail(error) { + return { + type: ACCOUNT_BLOCK_FAIL, + error: error + }; +}; + +export function unblockAccountRequest(id) { + return { + type: ACCOUNT_UNBLOCK_REQUEST, + id: id + }; +}; + +export function unblockAccountSuccess(relationship) { + return { + type: ACCOUNT_UNBLOCK_SUCCESS, + relationship: relationship + }; +}; + +export function unblockAccountFail(error) { + return { + type: ACCOUNT_UNBLOCK_FAIL, + error: error + }; +}; diff --git a/app/assets/javascripts/components/components/status_action_bar.jsx b/app/assets/javascripts/components/components/status_action_bar.jsx index 76f0ac5f..3e826d68 100644 --- a/app/assets/javascripts/components/components/status_action_bar.jsx +++ b/app/assets/javascripts/components/components/status_action_bar.jsx @@ -41,6 +41,8 @@ const StatusActionBar = React.createClass({
  • Delete
  • ); + } else { + menu =