mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 11:35:29 +01:00
commit
de154dbd5d
@ -12,7 +12,7 @@ LOCAL_DOMAIN=example.com
|
|||||||
LOCAL_HTTPS=true
|
LOCAL_HTTPS=true
|
||||||
|
|
||||||
# Application secrets
|
# Application secrets
|
||||||
# Generate each with the `rake secret` task
|
# Generate each with the `rake secret` task (`docker-compose run --rm web rake secret` if you use docker compose)
|
||||||
PAPERCLIP_SECRET=
|
PAPERCLIP_SECRET=
|
||||||
SECRET_KEY_BASE=
|
SECRET_KEY_BASE=
|
||||||
|
|
||||||
|
34
.eslintrc
34
.eslintrc
@ -15,7 +15,37 @@
|
|||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
|
|
||||||
"ecmaFeatures": {
|
"ecmaFeatures": {
|
||||||
"jsx": true
|
"arrowFunctions": true,
|
||||||
},
|
"jsx": true,
|
||||||
|
"destructuring": true,
|
||||||
|
"modules": true,
|
||||||
|
"spread": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"rules": {
|
||||||
|
"no-cond-assign": 2,
|
||||||
|
"no-console": 1,
|
||||||
|
"no-irregular-whitespace": 2,
|
||||||
|
"no-unreachable": 2,
|
||||||
|
"valid-typeof": 2,
|
||||||
|
"consistent-return": 2,
|
||||||
|
"dot-notation": 2,
|
||||||
|
"eqeqeq": 2,
|
||||||
|
"no-fallthrough": 2,
|
||||||
|
"no-unused-expressions": 2,
|
||||||
|
"strict": 0,
|
||||||
|
"no-catch-shadow": 2,
|
||||||
|
"indent": [1, 2],
|
||||||
|
"brace-style": 1,
|
||||||
|
"comma-spacing": [1, {"before": false, "after": true}],
|
||||||
|
"comma-style": [1, "last"],
|
||||||
|
"no-mixed-spaces-and-tabs": 1,
|
||||||
|
"no-nested-ternary": 1,
|
||||||
|
"no-trailing-spaces": 1,
|
||||||
|
"react/wrap-multilines": 2,
|
||||||
|
"react/self-closing-comp": 2,
|
||||||
|
"react/prop-types": 2,
|
||||||
|
"react/no-multi-comp": 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,3 +86,4 @@ AllCops:
|
|||||||
- 'config/**/*'
|
- 'config/**/*'
|
||||||
- 'bin/*'
|
- 'bin/*'
|
||||||
- 'Rakefile'
|
- 'Rakefile'
|
||||||
|
- 'node_modules/**/*'
|
||||||
|
10
Gemfile.lock
10
Gemfile.lock
@ -39,7 +39,8 @@ GEM
|
|||||||
i18n (~> 0.7)
|
i18n (~> 0.7)
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
addressable (2.4.0)
|
addressable (2.5.0)
|
||||||
|
public_suffix (~> 2.0, >= 2.0.2)
|
||||||
arel (7.1.4)
|
arel (7.1.4)
|
||||||
ast (2.3.0)
|
ast (2.3.0)
|
||||||
autoprefixer-rails (6.5.0.2)
|
autoprefixer-rails (6.5.0.2)
|
||||||
@ -98,7 +99,7 @@ GEM
|
|||||||
warden (~> 1.2.3)
|
warden (~> 1.2.3)
|
||||||
diff-lcs (1.2.5)
|
diff-lcs (1.2.5)
|
||||||
docile (1.1.5)
|
docile (1.1.5)
|
||||||
domain_name (0.5.20160826)
|
domain_name (0.5.20161129)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
doorkeeper (4.2.0)
|
doorkeeper (4.2.0)
|
||||||
railties (>= 4.2)
|
railties (>= 4.2)
|
||||||
@ -121,7 +122,7 @@ GEM
|
|||||||
ruby-progressbar (~> 1.4)
|
ruby-progressbar (~> 1.4)
|
||||||
globalid (0.3.7)
|
globalid (0.3.7)
|
||||||
activesupport (>= 4.1.0)
|
activesupport (>= 4.1.0)
|
||||||
goldfinger (1.1.0)
|
goldfinger (1.1.2)
|
||||||
addressable (~> 2.4)
|
addressable (~> 2.4)
|
||||||
http (~> 2.0)
|
http (~> 2.0)
|
||||||
nokogiri (~> 1.6)
|
nokogiri (~> 1.6)
|
||||||
@ -138,7 +139,7 @@ GEM
|
|||||||
highline (1.7.8)
|
highline (1.7.8)
|
||||||
hiredis (0.6.1)
|
hiredis (0.6.1)
|
||||||
htmlentities (4.3.4)
|
htmlentities (4.3.4)
|
||||||
http (2.0.3)
|
http (2.1.0)
|
||||||
addressable (~> 2.3)
|
addressable (~> 2.3)
|
||||||
http-cookie (~> 1.0)
|
http-cookie (~> 1.0)
|
||||||
http-form_data (~> 1.0.1)
|
http-form_data (~> 1.0.1)
|
||||||
@ -226,6 +227,7 @@ GEM
|
|||||||
slop (~> 3.4)
|
slop (~> 3.4)
|
||||||
pry-rails (0.3.4)
|
pry-rails (0.3.4)
|
||||||
pry (>= 0.9.10)
|
pry (>= 0.9.10)
|
||||||
|
public_suffix (2.0.4)
|
||||||
puma (3.6.0)
|
puma (3.6.0)
|
||||||
rabl (0.13.1)
|
rabl (0.13.1)
|
||||||
activesupport (>= 2.3.14)
|
activesupport (>= 2.3.14)
|
||||||
|
@ -13,7 +13,7 @@ An alternative implementation of the GNU social project. Based on ActivityStream
|
|||||||
|
|
||||||
Click on the screenshot to watch a demo of the UI:
|
Click on the screenshot to watch a demo of the UI:
|
||||||
|
|
||||||
[![Screenshot](https://i.imgur.com/pNieDFp.png)][youtube_demo]
|
[![Screenshot](https://i.imgur.com/T2q5V65.png)][youtube_demo]
|
||||||
|
|
||||||
[youtube_demo]: https://www.youtube.com/watch?v=YO1jQ8_rAMU
|
[youtube_demo]: https://www.youtube.com/watch?v=YO1jQ8_rAMU
|
||||||
|
|
||||||
|
BIN
app/assets/images/mastodon-getting-started.png
Normal file
BIN
app/assets/images/mastodon-getting-started.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
Binary file not shown.
Before Width: | Height: | Size: 313 KiB After Width: | Height: | Size: 244 KiB |
@ -51,6 +51,22 @@ export const RELATIONSHIPS_FETCH_REQUEST = 'RELATIONSHIPS_FETCH_REQUEST';
|
|||||||
export const RELATIONSHIPS_FETCH_SUCCESS = 'RELATIONSHIPS_FETCH_SUCCESS';
|
export const RELATIONSHIPS_FETCH_SUCCESS = 'RELATIONSHIPS_FETCH_SUCCESS';
|
||||||
export const RELATIONSHIPS_FETCH_FAIL = 'RELATIONSHIPS_FETCH_FAIL';
|
export const RELATIONSHIPS_FETCH_FAIL = 'RELATIONSHIPS_FETCH_FAIL';
|
||||||
|
|
||||||
|
export const FOLLOW_REQUESTS_FETCH_REQUEST = 'FOLLOW_REQUESTS_FETCH_REQUEST';
|
||||||
|
export const FOLLOW_REQUESTS_FETCH_SUCCESS = 'FOLLOW_REQUESTS_FETCH_SUCCESS';
|
||||||
|
export const FOLLOW_REQUESTS_FETCH_FAIL = 'FOLLOW_REQUESTS_FETCH_FAIL';
|
||||||
|
|
||||||
|
export const FOLLOW_REQUESTS_EXPAND_REQUEST = 'FOLLOW_REQUESTS_EXPAND_REQUEST';
|
||||||
|
export const FOLLOW_REQUESTS_EXPAND_SUCCESS = 'FOLLOW_REQUESTS_EXPAND_SUCCESS';
|
||||||
|
export const FOLLOW_REQUESTS_EXPAND_FAIL = 'FOLLOW_REQUESTS_EXPAND_FAIL';
|
||||||
|
|
||||||
|
export const FOLLOW_REQUEST_AUTHORIZE_REQUEST = 'FOLLOW_REQUEST_AUTHORIZE_REQUEST';
|
||||||
|
export const FOLLOW_REQUEST_AUTHORIZE_SUCCESS = 'FOLLOW_REQUEST_AUTHORIZE_SUCCESS';
|
||||||
|
export const FOLLOW_REQUEST_AUTHORIZE_FAIL = 'FOLLOW_REQUEST_AUTHORIZE_FAIL';
|
||||||
|
|
||||||
|
export const FOLLOW_REQUEST_REJECT_REQUEST = 'FOLLOW_REQUEST_REJECT_REQUEST';
|
||||||
|
export const FOLLOW_REQUEST_REJECT_SUCCESS = 'FOLLOW_REQUEST_REJECT_SUCCESS';
|
||||||
|
export const FOLLOW_REQUEST_REJECT_FAIL = 'FOLLOW_REQUEST_REJECT_FAIL';
|
||||||
|
|
||||||
export function setAccountSelf(account) {
|
export function setAccountSelf(account) {
|
||||||
return {
|
return {
|
||||||
type: ACCOUNT_SET_SELF,
|
type: ACCOUNT_SET_SELF,
|
||||||
@ -509,3 +525,140 @@ export function fetchRelationshipsFail(error) {
|
|||||||
error
|
error
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function fetchFollowRequests() {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
dispatch(fetchFollowRequestsRequest());
|
||||||
|
|
||||||
|
api(getState).get('/api/v1/follow_requests').then(response => {
|
||||||
|
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
||||||
|
dispatch(fetchFollowRequestsSuccess(response.data, next ? next.uri : null))
|
||||||
|
}).catch(error => dispatch(fetchFollowRequestsFail(error)));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function fetchFollowRequestsRequest() {
|
||||||
|
return {
|
||||||
|
type: FOLLOW_REQUESTS_FETCH_REQUEST
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function fetchFollowRequestsSuccess(accounts, next) {
|
||||||
|
return {
|
||||||
|
type: FOLLOW_REQUESTS_FETCH_SUCCESS,
|
||||||
|
accounts,
|
||||||
|
next
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function fetchFollowRequestsFail(error) {
|
||||||
|
return {
|
||||||
|
type: FOLLOW_REQUESTS_FETCH_FAIL,
|
||||||
|
error
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function expandFollowRequests() {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
const url = getState().getIn(['user_lists', 'follow_requests', 'next']);
|
||||||
|
|
||||||
|
if (url === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatch(expandFollowRequestsRequest());
|
||||||
|
|
||||||
|
api(getState).get(url).then(response => {
|
||||||
|
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
||||||
|
dispatch(expandFollowRequestsSuccess(response.data, next ? next.uri : null))
|
||||||
|
}).catch(error => dispatch(expandFollowRequestsFail(error)));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function expandFollowRequestsRequest() {
|
||||||
|
return {
|
||||||
|
type: FOLLOW_REQUESTS_EXPAND_REQUEST
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function expandFollowRequestsSuccess(accounts, next) {
|
||||||
|
return {
|
||||||
|
type: FOLLOW_REQUESTS_EXPAND_SUCCESS,
|
||||||
|
accounts,
|
||||||
|
next
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function expandFollowRequestsFail(error) {
|
||||||
|
return {
|
||||||
|
type: FOLLOW_REQUESTS_EXPAND_FAIL,
|
||||||
|
error
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function authorizeFollowRequest(id) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
dispatch(authorizeFollowRequestRequest(id));
|
||||||
|
|
||||||
|
api(getState)
|
||||||
|
.post(`/api/v1/follow_requests/${id}/authorize`)
|
||||||
|
.then(response => dispatch(authorizeFollowRequestSuccess(id)))
|
||||||
|
.catch(error => dispatch(authorizeFollowRequestFail(id, error)));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function authorizeFollowRequestRequest(id) {
|
||||||
|
return {
|
||||||
|
type: FOLLOW_REQUEST_AUTHORIZE_REQUEST,
|
||||||
|
id
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function authorizeFollowRequestSuccess(id) {
|
||||||
|
return {
|
||||||
|
type: FOLLOW_REQUEST_AUTHORIZE_SUCCESS,
|
||||||
|
id
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function authorizeFollowRequestFail(id, error) {
|
||||||
|
return {
|
||||||
|
type: FOLLOW_REQUEST_AUTHORIZE_FAIL,
|
||||||
|
id,
|
||||||
|
error
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export function rejectFollowRequest(id) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
dispatch(rejectFollowRequestRequest(id));
|
||||||
|
|
||||||
|
api(getState)
|
||||||
|
.post(`/api/v1/follow_requests/${id}/reject`)
|
||||||
|
.then(response => dispatch(rejectFollowRequestSuccess(id)))
|
||||||
|
.catch(error => dispatch(rejectFollowRequestFail(id, error)));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function rejectFollowRequestRequest(id) {
|
||||||
|
return {
|
||||||
|
type: FOLLOW_REQUEST_REJECT_REQUEST,
|
||||||
|
id
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function rejectFollowRequestSuccess(id) {
|
||||||
|
return {
|
||||||
|
type: FOLLOW_REQUEST_REJECT_SUCCESS,
|
||||||
|
id
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function rejectFollowRequestFail(id, error) {
|
||||||
|
return {
|
||||||
|
type: FOLLOW_REQUEST_REJECT_FAIL,
|
||||||
|
id,
|
||||||
|
error
|
||||||
|
};
|
||||||
|
};
|
||||||
|
@ -14,6 +14,8 @@ export const NOTIFICATIONS_EXPAND_REQUEST = 'NOTIFICATIONS_EXPAND_REQUEST';
|
|||||||
export const NOTIFICATIONS_EXPAND_SUCCESS = 'NOTIFICATIONS_EXPAND_SUCCESS';
|
export const NOTIFICATIONS_EXPAND_SUCCESS = 'NOTIFICATIONS_EXPAND_SUCCESS';
|
||||||
export const NOTIFICATIONS_EXPAND_FAIL = 'NOTIFICATIONS_EXPAND_FAIL';
|
export const NOTIFICATIONS_EXPAND_FAIL = 'NOTIFICATIONS_EXPAND_FAIL';
|
||||||
|
|
||||||
|
export const NOTIFICATIONS_SETTING_CHANGE = 'NOTIFICATIONS_SETTING_CHANGE';
|
||||||
|
|
||||||
const fetchRelatedRelationships = (dispatch, notifications) => {
|
const fetchRelatedRelationships = (dispatch, notifications) => {
|
||||||
const accountIds = notifications.filter(item => item.type === 'follow').map(item => item.account.id);
|
const accountIds = notifications.filter(item => item.type === 'follow').map(item => item.account.id);
|
||||||
|
|
||||||
@ -23,7 +25,7 @@ const fetchRelatedRelationships = (dispatch, notifications) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function updateNotifications(notification, intlMessages, intlLocale) {
|
export function updateNotifications(notification, intlMessages, intlLocale) {
|
||||||
return dispatch => {
|
return (dispatch, getState) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: NOTIFICATIONS_UPDATE,
|
type: NOTIFICATIONS_UPDATE,
|
||||||
notification,
|
notification,
|
||||||
@ -34,7 +36,7 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
|
|||||||
fetchRelatedRelationships(dispatch, [notification]);
|
fetchRelatedRelationships(dispatch, [notification]);
|
||||||
|
|
||||||
// Desktop notifications
|
// Desktop notifications
|
||||||
if (typeof window.Notification !== 'undefined') {
|
if (typeof window.Notification !== 'undefined' && getState().getIn(['notifications', 'settings', 'alerts', notification.type], false)) {
|
||||||
const title = new IntlMessageFormat(intlMessages[`notification.${notification.type}`], intlLocale).format({ name: notification.account.display_name.length > 0 ? notification.account.display_name : notification.account.username });
|
const title = new IntlMessageFormat(intlMessages[`notification.${notification.type}`], intlLocale).format({ name: notification.account.display_name.length > 0 ? notification.account.display_name : notification.account.username });
|
||||||
const body = $('<p>').html(notification.status ? notification.status.content : '').text();
|
const body = $('<p>').html(notification.status ? notification.status.content : '').text();
|
||||||
|
|
||||||
@ -131,3 +133,11 @@ export function expandNotificationsFail(error) {
|
|||||||
error
|
error
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function changeNotificationsSetting(key, checked) {
|
||||||
|
return {
|
||||||
|
type: NOTIFICATIONS_SETTING_CHANGE,
|
||||||
|
key,
|
||||||
|
checked
|
||||||
|
};
|
||||||
|
};
|
||||||
|
@ -32,6 +32,7 @@ const AutosuggestTextarea = React.createClass({
|
|||||||
value: React.PropTypes.string,
|
value: React.PropTypes.string,
|
||||||
suggestions: ImmutablePropTypes.list,
|
suggestions: ImmutablePropTypes.list,
|
||||||
disabled: React.PropTypes.bool,
|
disabled: React.PropTypes.bool,
|
||||||
|
fileDropDate: React.PropTypes.instanceOf(Date),
|
||||||
placeholder: React.PropTypes.string,
|
placeholder: React.PropTypes.string,
|
||||||
onSuggestionSelected: React.PropTypes.func.isRequired,
|
onSuggestionSelected: React.PropTypes.func.isRequired,
|
||||||
onSuggestionsClearRequested: React.PropTypes.func.isRequired,
|
onSuggestionsClearRequested: React.PropTypes.func.isRequired,
|
||||||
@ -42,6 +43,8 @@ const AutosuggestTextarea = React.createClass({
|
|||||||
|
|
||||||
getInitialState () {
|
getInitialState () {
|
||||||
return {
|
return {
|
||||||
|
isFileDragging: false,
|
||||||
|
fileDraggingDate: undefined,
|
||||||
suggestionsHidden: false,
|
suggestionsHidden: false,
|
||||||
selectedSuggestion: 0,
|
selectedSuggestion: 0,
|
||||||
lastToken: null,
|
lastToken: null,
|
||||||
@ -120,21 +123,51 @@ const AutosuggestTextarea = React.createClass({
|
|||||||
if (nextProps.suggestions !== this.props.suggestions && nextProps.suggestions.size > 0 && this.state.suggestionsHidden) {
|
if (nextProps.suggestions !== this.props.suggestions && nextProps.suggestions.size > 0 && this.state.suggestionsHidden) {
|
||||||
this.setState({ suggestionsHidden: false });
|
this.setState({ suggestionsHidden: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fileDropDate = nextProps.fileDropDate;
|
||||||
|
const { isFileDragging, fileDraggingDate } = this.state;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We can't detect drop events, because they might not be on the textarea (the app allows dropping anywhere in the
|
||||||
|
* window). Instead, on-drop, we notify this textarea to stop its hover effect by passing in a prop with the
|
||||||
|
* drop-date.
|
||||||
|
*/
|
||||||
|
if (isFileDragging && fileDraggingDate && fileDropDate // if dragging when props updated, and dates aren't undefined
|
||||||
|
&& fileDropDate > fileDraggingDate) { // and if the drop date is now greater than when we started dragging
|
||||||
|
// then we should stop dragging
|
||||||
|
this.setState({
|
||||||
|
isFileDragging: false
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setTextarea (c) {
|
setTextarea (c) {
|
||||||
this.textarea = c;
|
this.textarea = c;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onDragEnter () {
|
||||||
|
this.setState({
|
||||||
|
isFileDragging: true,
|
||||||
|
fileDraggingDate: new Date()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
onDragExit () {
|
||||||
|
this.setState({
|
||||||
|
isFileDragging: false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { value, suggestions, disabled, placeholder, onKeyUp } = this.props;
|
const { value, suggestions, fileDropDate, disabled, placeholder, onKeyUp } = this.props;
|
||||||
const { suggestionsHidden, selectedSuggestion } = this.state;
|
const { isFileDragging, suggestionsHidden, selectedSuggestion } = this.state;
|
||||||
|
const className = isFileDragging ? 'autosuggest-textarea__textarea file-drop' : 'autosuggest-textarea__textarea';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='autosuggest-textarea'>
|
<div className='autosuggest-textarea'>
|
||||||
<textarea
|
<textarea
|
||||||
ref={this.setTextarea}
|
ref={this.setTextarea}
|
||||||
className='autosuggest-textarea__textarea'
|
className={className}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
value={value}
|
value={value}
|
||||||
@ -142,6 +175,8 @@ const AutosuggestTextarea = React.createClass({
|
|||||||
onKeyDown={this.onKeyDown}
|
onKeyDown={this.onKeyDown}
|
||||||
onKeyUp={onKeyUp}
|
onKeyUp={onKeyUp}
|
||||||
onBlur={this.onBlur}
|
onBlur={this.onBlur}
|
||||||
|
onDragEnter={this.onDragEnter}
|
||||||
|
onDragExit={this.onDragExit}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div style={{ display: (suggestions.size > 0 && !suggestionsHidden) ? 'block' : 'none' }} className='autosuggest-textarea__suggestions'>
|
<div style={{ display: (suggestions.size > 0 && !suggestionsHidden) ? 'block' : 'none' }} className='autosuggest-textarea__suggestions'>
|
||||||
|
@ -27,11 +27,11 @@ const StatusList = React.createClass({
|
|||||||
|
|
||||||
this._oldScrollPosition = scrollHeight - scrollTop;
|
this._oldScrollPosition = scrollHeight - scrollTop;
|
||||||
|
|
||||||
if (scrollTop === scrollHeight - clientHeight) {
|
if (scrollTop === scrollHeight - clientHeight && this.props.onScrollToBottom) {
|
||||||
this.props.onScrollToBottom();
|
this.props.onScrollToBottom();
|
||||||
} else if (scrollTop < 100) {
|
} else if (scrollTop < 100 && this.props.onScrollToTop) {
|
||||||
this.props.onScrollToTop();
|
this.props.onScrollToTop();
|
||||||
} else {
|
} else if (this.props.onScroll) {
|
||||||
this.props.onScroll();
|
this.props.onScroll();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -34,6 +34,7 @@ import Reblogs from '../features/reblogs';
|
|||||||
import Favourites from '../features/favourites';
|
import Favourites from '../features/favourites';
|
||||||
import HashtagTimeline from '../features/hashtag_timeline';
|
import HashtagTimeline from '../features/hashtag_timeline';
|
||||||
import Notifications from '../features/notifications';
|
import Notifications from '../features/notifications';
|
||||||
|
import FollowRequests from '../features/follow_requests';
|
||||||
import { IntlProvider, addLocaleData } from 'react-intl';
|
import { IntlProvider, addLocaleData } from 'react-intl';
|
||||||
import en from 'react-intl/locale-data/en';
|
import en from 'react-intl/locale-data/en';
|
||||||
import de from 'react-intl/locale-data/de';
|
import de from 'react-intl/locale-data/de';
|
||||||
@ -125,6 +126,8 @@ const Mastodon = React.createClass({
|
|||||||
<Route path='followers' component={Followers} />
|
<Route path='followers' component={Followers} />
|
||||||
<Route path='following' component={Following} />
|
<Route path='following' component={Following} />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
<Route path='follow_requests' component={FollowRequests} />
|
||||||
</Route>
|
</Route>
|
||||||
</Router>
|
</Router>
|
||||||
</Provider>
|
</Provider>
|
||||||
|
@ -61,10 +61,10 @@ const Header = React.createClass({
|
|||||||
const displayNameHTML = { __html: emojify(escapeTextContentForBrowser(displayName)) };
|
const displayNameHTML = { __html: emojify(escapeTextContentForBrowser(displayName)) };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ flex: '0 0 auto', background: '#2f3441', textAlign: 'center', backgroundImage: `url(${account.get('header')})`, backgroundSize: 'cover', backgroundPosition: 'center', position: 'relative' }}>
|
<div className='account__header' style={{ flex: '0 0 auto', background: '#2f3441', textAlign: 'center', backgroundImage: `url(${account.get('header')})`, backgroundSize: 'cover', backgroundPosition: 'center', position: 'relative' }}>
|
||||||
<div style={{ background: 'rgba(47, 52, 65, 0.9)', padding: '20px 10px' }}>
|
<div style={{ background: 'rgba(47, 52, 65, 0.9)', padding: '20px 10px' }}>
|
||||||
<a href={account.get('url')} target='_blank' rel='noopener' style={{ display: 'block', color: 'inherit', textDecoration: 'none' }}>
|
<a href={account.get('url')} target='_blank' rel='noopener' style={{ display: 'block', color: 'inherit', textDecoration: 'none' }}>
|
||||||
<div style={{ width: '90px', margin: '0 auto', marginBottom: '10px' }}>
|
<div className='account__header__avatar' style={{ width: '90px', margin: '0 auto', marginBottom: '10px' }}>
|
||||||
<img src={account.get('avatar')} alt='' style={{ display: 'block', width: '90px', height: '90px', borderRadius: '90px' }} />
|
<img src={account.get('avatar')} alt='' style={{ display: 'block', width: '90px', height: '90px', borderRadius: '90px' }} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -20,12 +20,14 @@ const messages = defineMessages({
|
|||||||
const ComposeForm = React.createClass({
|
const ComposeForm = React.createClass({
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
intl: React.PropTypes.object.isRequired,
|
||||||
text: React.PropTypes.string.isRequired,
|
text: React.PropTypes.string.isRequired,
|
||||||
suggestion_token: React.PropTypes.string,
|
suggestion_token: React.PropTypes.string,
|
||||||
suggestions: ImmutablePropTypes.list,
|
suggestions: ImmutablePropTypes.list,
|
||||||
sensitive: React.PropTypes.bool,
|
sensitive: React.PropTypes.bool,
|
||||||
unlisted: React.PropTypes.bool,
|
unlisted: React.PropTypes.bool,
|
||||||
private: React.PropTypes.bool,
|
private: React.PropTypes.bool,
|
||||||
|
fileDropDate: React.PropTypes.instanceOf(Date),
|
||||||
is_submitting: React.PropTypes.bool,
|
is_submitting: React.PropTypes.bool,
|
||||||
is_uploading: React.PropTypes.bool,
|
is_uploading: React.PropTypes.bool,
|
||||||
in_reply_to: ImmutablePropTypes.map,
|
in_reply_to: ImmutablePropTypes.map,
|
||||||
@ -109,6 +111,7 @@ const ComposeForm = React.createClass({
|
|||||||
ref={this.setAutosuggestTextarea}
|
ref={this.setAutosuggestTextarea}
|
||||||
placeholder={intl.formatMessage(messages.placeholder)}
|
placeholder={intl.formatMessage(messages.placeholder)}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
fileDropDate={this.props.fileDropDate}
|
||||||
value={this.props.text}
|
value={this.props.text}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
suggestions={this.props.suggestions}
|
suggestions={this.props.suggestions}
|
||||||
@ -129,7 +132,7 @@ const ComposeForm = React.createClass({
|
|||||||
<span style={{ display: 'inline-block', verticalAlign: 'middle', marginBottom: '14px', marginLeft: '8px', color: '#9baec8' }}><FormattedMessage id='compose_form.private' defaultMessage='Mark as private' /></span>
|
<span style={{ display: 'inline-block', verticalAlign: 'middle', marginBottom: '14px', marginLeft: '8px', color: '#9baec8' }}><FormattedMessage id='compose_form.private' defaultMessage='Mark as private' /></span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<Motion defaultStyle={{ opacity: 100, height: 39.5 }} style={{ opacity: spring(this.props.private ? 0 : 100), height: spring(this.props.private ? 0 : 39.5) }}>
|
<Motion defaultStyle={{ opacity: this.props.private ? 0 : 100, height: this.props.private ? 39.5 : 0 }} style={{ opacity: spring(this.props.private ? 0 : 100), height: spring(this.props.private ? 0 : 39.5) }}>
|
||||||
{({ opacity, height }) =>
|
{({ opacity, height }) =>
|
||||||
<label style={{ display: 'block', lineHeight: '24px', verticalAlign: 'middle', height: `${height}px`, overflow: 'hidden', opacity: opacity / 100 }}>
|
<label style={{ display: 'block', lineHeight: '24px', verticalAlign: 'middle', height: `${height}px`, overflow: 'hidden', opacity: opacity / 100 }}>
|
||||||
<Toggle checked={this.props.unlisted} onChange={this.handleChangeListability} />
|
<Toggle checked={this.props.unlisted} onChange={this.handleChangeListability} />
|
||||||
@ -138,7 +141,7 @@ const ComposeForm = React.createClass({
|
|||||||
}
|
}
|
||||||
</Motion>
|
</Motion>
|
||||||
|
|
||||||
<Motion defaultStyle={{ opacity: 100, height: 39.5 }} style={{ opacity: spring(this.props.media_count === 0 ? 0 : 100), height: spring(this.props.media_count === 0 ? 0 : 39.5) }}>
|
<Motion defaultStyle={{ opacity: 0, height: 0 }} style={{ opacity: spring(this.props.media_count === 0 ? 0 : 100), height: spring(this.props.media_count === 0 ? 0 : 39.5) }}>
|
||||||
{({ opacity, height }) =>
|
{({ opacity, height }) =>
|
||||||
<label style={{ display: 'block', lineHeight: '24px', verticalAlign: 'middle', height: `${height}px`, overflow: 'hidden', opacity: opacity / 100 }}>
|
<label style={{ display: 'block', lineHeight: '24px', verticalAlign: 'middle', height: `${height}px`, overflow: 'hidden', opacity: opacity / 100 }}>
|
||||||
<Toggle checked={this.props.sensitive} onChange={this.handleChangeSensitivity} />
|
<Toggle checked={this.props.sensitive} onChange={this.handleChangeSensitivity} />
|
||||||
|
@ -24,6 +24,7 @@ const makeMapStateToProps = () => {
|
|||||||
sensitive: state.getIn(['compose', 'sensitive']),
|
sensitive: state.getIn(['compose', 'sensitive']),
|
||||||
unlisted: state.getIn(['compose', 'unlisted']),
|
unlisted: state.getIn(['compose', 'unlisted']),
|
||||||
private: state.getIn(['compose', 'private']),
|
private: state.getIn(['compose', 'private']),
|
||||||
|
fileDropDate: state.getIn(['compose', 'fileDropDate']),
|
||||||
is_submitting: state.getIn(['compose', 'is_submitting']),
|
is_submitting: state.getIn(['compose', 'is_submitting']),
|
||||||
is_uploading: state.getIn(['compose', 'is_uploading']),
|
is_uploading: state.getIn(['compose', 'is_uploading']),
|
||||||
in_reply_to: getStatus(state, state.getIn(['compose', 'in_reply_to'])),
|
in_reply_to: getStatus(state, state.getIn(['compose', 'in_reply_to'])),
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import Permalink from '../../../components/permalink';
|
||||||
|
import Avatar from '../../../components/avatar';
|
||||||
|
import DisplayName from '../../../components/display_name';
|
||||||
|
import emojify from '../../../emoji';
|
||||||
|
import IconButton from '../../../components/icon_button';
|
||||||
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
authorize: { id: 'follow_request.authorize', defaultMessage: 'Authorize' },
|
||||||
|
reject: { id: 'follow_request.reject', defaultMessage: 'Reject' }
|
||||||
|
});
|
||||||
|
|
||||||
|
const outerStyle = {
|
||||||
|
padding: '14px 10px'
|
||||||
|
};
|
||||||
|
|
||||||
|
const panelStyle = {
|
||||||
|
background: '#2f3441',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'row',
|
||||||
|
borderTop: '1px solid #363c4b',
|
||||||
|
borderBottom: '1px solid #363c4b',
|
||||||
|
padding: '10px 0'
|
||||||
|
};
|
||||||
|
|
||||||
|
const btnStyle = {
|
||||||
|
flex: '1 1 auto',
|
||||||
|
textAlign: 'center'
|
||||||
|
};
|
||||||
|
|
||||||
|
const AccountAuthorize = ({ intl, account, onAuthorize, onReject }) => {
|
||||||
|
const content = { __html: emojify(account.get('note')) };
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div style={outerStyle}>
|
||||||
|
<Permalink href={account.get('url')} to={`/accounts/${account.get('id')}`} className='detailed-status__display-name' style={{ display: 'block', overflow: 'hidden', marginBottom: '15px' }}>
|
||||||
|
<div style={{ float: 'left', marginRight: '10px' }}><Avatar src={account.get('avatar')} size={48} /></div>
|
||||||
|
<DisplayName account={account} />
|
||||||
|
</Permalink>
|
||||||
|
|
||||||
|
<div style={{ color: '#616b86', fontSize: '14px' }} className='account__header__content' dangerouslySetInnerHTML={content} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style={panelStyle}>
|
||||||
|
<div style={btnStyle}><IconButton title={intl.formatMessage(messages.authorize)} icon='check' onClick={onAuthorize} /></div>
|
||||||
|
<div style={btnStyle}><IconButton title={intl.formatMessage(messages.reject)} icon='times' onClick={onReject} /></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
AccountAuthorize.propTypes = {
|
||||||
|
account: ImmutablePropTypes.map.isRequired,
|
||||||
|
onAuthorize: React.PropTypes.func.isRequired,
|
||||||
|
onReject: React.PropTypes.func.isRequired,
|
||||||
|
intl: React.PropTypes.object.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
export default injectIntl(AccountAuthorize);
|
@ -0,0 +1,26 @@
|
|||||||
|
import { connect } from 'react-redux';
|
||||||
|
import { makeGetAccount } from '../../../selectors';
|
||||||
|
import AccountAuthorize from '../components/account_authorize';
|
||||||
|
import { authorizeFollowRequest, rejectFollowRequest } from '../../../actions/accounts';
|
||||||
|
|
||||||
|
const makeMapStateToProps = () => {
|
||||||
|
const getAccount = makeGetAccount();
|
||||||
|
|
||||||
|
const mapStateToProps = (state, props) => ({
|
||||||
|
account: getAccount(state, props.id)
|
||||||
|
});
|
||||||
|
|
||||||
|
return mapStateToProps;
|
||||||
|
};
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch, { id }) => ({
|
||||||
|
onAuthorize (account) {
|
||||||
|
dispatch(authorizeFollowRequest(id));
|
||||||
|
},
|
||||||
|
|
||||||
|
onReject (account) {
|
||||||
|
dispatch(rejectFollowRequest(id));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(makeMapStateToProps, mapDispatchToProps)(AccountAuthorize);
|
@ -0,0 +1,66 @@
|
|||||||
|
import { connect } from 'react-redux';
|
||||||
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import LoadingIndicator from '../../components/loading_indicator';
|
||||||
|
import { ScrollContainer } from 'react-router-scroll';
|
||||||
|
import Column from '../ui/components/column';
|
||||||
|
import AccountAuthorizeContainer from './containers/account_authorize_container';
|
||||||
|
import { fetchFollowRequests, expandFollowRequests } from '../../actions/accounts';
|
||||||
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
heading: { id: 'column.follow_requests', defaultMessage: 'Follow requests' }
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapStateToProps = state => ({
|
||||||
|
accountIds: state.getIn(['user_lists', 'follow_requests', 'items'])
|
||||||
|
});
|
||||||
|
|
||||||
|
const FollowRequests = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
params: React.PropTypes.object.isRequired,
|
||||||
|
dispatch: React.PropTypes.func.isRequired,
|
||||||
|
accountIds: ImmutablePropTypes.list,
|
||||||
|
intl: React.PropTypes.object.isRequired
|
||||||
|
},
|
||||||
|
|
||||||
|
mixins: [PureRenderMixin],
|
||||||
|
|
||||||
|
componentWillMount () {
|
||||||
|
this.props.dispatch(fetchFollowRequests());
|
||||||
|
},
|
||||||
|
|
||||||
|
handleScroll (e) {
|
||||||
|
const { scrollTop, scrollHeight, clientHeight } = e.target;
|
||||||
|
|
||||||
|
if (scrollTop === scrollHeight - clientHeight) {
|
||||||
|
this.props.dispatch(expandFollowRequests());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { intl, accountIds } = this.props;
|
||||||
|
|
||||||
|
if (!accountIds) {
|
||||||
|
return (
|
||||||
|
<Column>
|
||||||
|
<LoadingIndicator />
|
||||||
|
</Column>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Column icon='users' heading={intl.formatMessage(messages.heading)}>
|
||||||
|
<ScrollContainer scrollKey='follow_requests'>
|
||||||
|
<div className='scrollable' onScroll={this.handleScroll}>
|
||||||
|
{accountIds.map(id =>
|
||||||
|
<AccountAuthorizeContainer key={id} id={id} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</ScrollContainer>
|
||||||
|
</Column>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps)(injectIntl(FollowRequests));
|
@ -3,15 +3,17 @@ import ColumnLink from '../ui/components/column_link';
|
|||||||
import { Link } from 'react-router';
|
import { Link } from 'react-router';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
heading: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
|
heading: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
|
||||||
public_timeline: { id: 'navigation_bar.public_timeline', defaultMessage: 'Public timeline' },
|
public_timeline: { id: 'navigation_bar.public_timeline', defaultMessage: 'Public timeline' },
|
||||||
settings: { id: 'navigation_bar.settings', defaultMessage: 'Settings' }
|
settings: { id: 'navigation_bar.settings', defaultMessage: 'Settings' },
|
||||||
|
follow_requests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' }
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
me: state.getIn(['meta', 'me'])
|
me: state.getIn(['accounts', state.getIn(['meta', 'me'])])
|
||||||
});
|
});
|
||||||
|
|
||||||
const hamburgerStyle = {
|
const hamburgerStyle = {
|
||||||
@ -26,12 +28,19 @@ const hamburgerStyle = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const GettingStarted = ({ intl, me }) => {
|
const GettingStarted = ({ intl, me }) => {
|
||||||
|
let followRequests = '';
|
||||||
|
|
||||||
|
if (me.get('locked')) {
|
||||||
|
followRequests = <ColumnLink icon='users' text={intl.formatMessage(messages.follow_requests)} to='/follow_requests' />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='asterisk' heading={intl.formatMessage(messages.heading)}>
|
<Column icon='asterisk' heading={intl.formatMessage(messages.heading)}>
|
||||||
<div style={{ position: 'relative' }}>
|
<div style={{ position: 'relative' }}>
|
||||||
<div style={hamburgerStyle}><i className='fa fa-bars' /></div>
|
<div style={hamburgerStyle}><i className='fa fa-bars' /></div>
|
||||||
<ColumnLink icon='globe' text={intl.formatMessage(messages.public_timeline)} to='/timelines/public' />
|
<ColumnLink icon='globe' text={intl.formatMessage(messages.public_timeline)} to='/timelines/public' />
|
||||||
<ColumnLink icon='cog' text={intl.formatMessage(messages.settings)} href='/settings/profile' />
|
<ColumnLink icon='cog' text={intl.formatMessage(messages.settings)} href='/settings/profile' />
|
||||||
|
{followRequests}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='static-content'>
|
<div className='static-content'>
|
||||||
@ -39,8 +48,15 @@ const GettingStarted = ({ intl, me }) => {
|
|||||||
<p><FormattedMessage id='getting_started.about_shortcuts' defaultMessage='If the target user is on the same domain as you, just the username will work. The same rule applies to mentioning people in statuses.' /></p>
|
<p><FormattedMessage id='getting_started.about_shortcuts' defaultMessage='If the target user is on the same domain as you, just the username will work. The same rule applies to mentioning people in statuses.' /></p>
|
||||||
<p><FormattedMessage id='getting_started.about_developer' defaultMessage='The developer of this project can be followed as Gargron@mastodon.social' /></p>
|
<p><FormattedMessage id='getting_started.about_developer' defaultMessage='The developer of this project can be followed as Gargron@mastodon.social' /></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className='getting-started__illustration' />
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GettingStarted.propTypes = {
|
||||||
|
intl: React.PropTypes.object.isRequired,
|
||||||
|
me: ImmutablePropTypes.map.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps)(injectIntl(GettingStarted));
|
export default connect(mapStateToProps)(injectIntl(GettingStarted));
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
updateTimeline,
|
updateTimeline,
|
||||||
deleteFromTimelines
|
deleteFromTimelines
|
||||||
} from '../../actions/timelines';
|
} from '../../actions/timelines';
|
||||||
|
import ColumnBackButton from '../public_timeline/components/column_back_button';
|
||||||
|
|
||||||
const HashtagTimeline = React.createClass({
|
const HashtagTimeline = React.createClass({
|
||||||
|
|
||||||
@ -68,6 +69,7 @@ const HashtagTimeline = React.createClass({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='hashtag' heading={id}>
|
<Column icon='hashtag' heading={id}>
|
||||||
|
<ColumnBackButton />
|
||||||
<StatusListContainer type='tag' id={id} />
|
<StatusListContainer type='tag' id={id} />
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
@ -0,0 +1,150 @@
|
|||||||
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import Toggle from 'react-toggle';
|
||||||
|
import { Motion, spring } from 'react-motion';
|
||||||
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
const outerStyle = {
|
||||||
|
background: '#373b4a',
|
||||||
|
padding: '15px'
|
||||||
|
};
|
||||||
|
|
||||||
|
const iconStyle = {
|
||||||
|
fontSize: '16px',
|
||||||
|
padding: '15px',
|
||||||
|
position: 'absolute',
|
||||||
|
right: '0',
|
||||||
|
top: '-48px',
|
||||||
|
cursor: 'pointer'
|
||||||
|
};
|
||||||
|
|
||||||
|
const labelStyle = {
|
||||||
|
display: 'block',
|
||||||
|
lineHeight: '24px',
|
||||||
|
verticalAlign: 'middle'
|
||||||
|
};
|
||||||
|
|
||||||
|
const labelSpanStyle = {
|
||||||
|
display: 'inline-block',
|
||||||
|
verticalAlign: 'middle',
|
||||||
|
marginBottom: '14px',
|
||||||
|
marginLeft: '8px',
|
||||||
|
color: '#9baec8'
|
||||||
|
};
|
||||||
|
|
||||||
|
const sectionStyle = {
|
||||||
|
cursor: 'default',
|
||||||
|
display: 'block',
|
||||||
|
fontWeight: '500',
|
||||||
|
color: '#9baec8',
|
||||||
|
marginBottom: '10px'
|
||||||
|
};
|
||||||
|
|
||||||
|
const rowStyle = {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const ColumnSettings = React.createClass({
|
||||||
|
|
||||||
|
propTypes: {
|
||||||
|
settings: ImmutablePropTypes.map.isRequired,
|
||||||
|
onChange: React.PropTypes.func.isRequired
|
||||||
|
},
|
||||||
|
|
||||||
|
getInitialState () {
|
||||||
|
return {
|
||||||
|
collapsed: true
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
mixins: [PureRenderMixin],
|
||||||
|
|
||||||
|
handleToggleCollapsed () {
|
||||||
|
this.setState({ collapsed: !this.state.collapsed });
|
||||||
|
},
|
||||||
|
|
||||||
|
handleChange (key, e) {
|
||||||
|
this.props.onChange(key, e.target.checked);
|
||||||
|
},
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { settings } = this.props;
|
||||||
|
const { collapsed } = this.state;
|
||||||
|
|
||||||
|
const alertStr = <FormattedMessage id='notifications.column_settings.alert' defaultMessage='Desktop notifications' />;
|
||||||
|
const showStr = <FormattedMessage id='notifications.column_settings.show' defaultMessage='Show in column' />;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={{ position: 'relative' }}>
|
||||||
|
<div style={{...iconStyle, color: collapsed ? '#9baec8' : '#fff', background: collapsed ? '#2f3441' : '#373b4a' }} onClick={this.handleToggleCollapsed}><i className='fa fa-sliders' /></div>
|
||||||
|
|
||||||
|
<Motion defaultStyle={{ opacity: 0, height: 0 }} style={{ opacity: spring(collapsed ? 0 : 100), height: spring(collapsed ? 0 : 458) }}>
|
||||||
|
{({ opacity, height }) =>
|
||||||
|
<div style={{ overflow: 'hidden', height: `${height}px`, opacity: opacity / 100 }}>
|
||||||
|
<div style={outerStyle}>
|
||||||
|
<span style={sectionStyle}><FormattedMessage id='notifications.column_settings.follow' defaultMessage='New followers:' /></span>
|
||||||
|
|
||||||
|
<div style={rowStyle}>
|
||||||
|
<label style={labelStyle}>
|
||||||
|
<Toggle checked={settings.getIn(['alerts', 'follow'])} onChange={this.handleChange.bind(this, ['alerts', 'follow'])} />
|
||||||
|
<span style={labelSpanStyle}>{alertStr}</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label style={labelStyle}>
|
||||||
|
<Toggle checked={settings.getIn(['shows', 'follow'])} onChange={this.handleChange.bind(this, ['shows', 'follow'])} />
|
||||||
|
<span style={labelSpanStyle}>{showStr}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span style={sectionStyle}><FormattedMessage id='notifications.column_settings.favourite' defaultMessage='Favourites:' /></span>
|
||||||
|
|
||||||
|
<div style={rowStyle}>
|
||||||
|
<label style={labelStyle}>
|
||||||
|
<Toggle checked={settings.getIn(['alerts', 'favourite'])} onChange={this.handleChange.bind(this, ['alerts', 'favourite'])} />
|
||||||
|
<span style={labelSpanStyle}>{alertStr}</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label style={labelStyle}>
|
||||||
|
<Toggle checked={settings.getIn(['shows', 'favourite'])} onChange={this.handleChange.bind(this, ['shows', 'favourite'])} />
|
||||||
|
<span style={labelSpanStyle}>{showStr}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span style={sectionStyle}><FormattedMessage id='notifications.column_settings.mention' defaultMessage='Mentions:' /></span>
|
||||||
|
|
||||||
|
<div style={rowStyle}>
|
||||||
|
<label style={labelStyle}>
|
||||||
|
<Toggle checked={settings.getIn(['alerts', 'mention'])} onChange={this.handleChange.bind(this, ['alerts', 'mention'])} />
|
||||||
|
<span style={labelSpanStyle}>{alertStr}</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label style={labelStyle}>
|
||||||
|
<Toggle checked={settings.getIn(['shows', 'mention'])} onChange={this.handleChange.bind(this, ['shows', 'mention'])} />
|
||||||
|
<span style={labelSpanStyle}>{showStr}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span style={sectionStyle}><FormattedMessage id='notifications.column_settings.reblog' defaultMessage='Boosts:' /></span>
|
||||||
|
|
||||||
|
<div style={rowStyle}>
|
||||||
|
<label style={labelStyle}>
|
||||||
|
<Toggle checked={settings.getIn(['alerts', 'reblog'])} onChange={this.handleChange.bind(this, ['alerts', 'reblog'])} />
|
||||||
|
<span style={labelSpanStyle}>{alertStr}</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label style={labelStyle}>
|
||||||
|
<Toggle checked={settings.getIn(['shows', 'reblog'])} onChange={this.handleChange.bind(this, ['shows', 'reblog'])} />
|
||||||
|
<span style={labelSpanStyle}>{showStr}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</Motion>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export default ColumnSettings;
|
@ -0,0 +1,17 @@
|
|||||||
|
import { connect } from 'react-redux';
|
||||||
|
import ColumnSettings from '../components/column_settings';
|
||||||
|
import { changeNotificationsSetting } from '../../../actions/notifications';
|
||||||
|
|
||||||
|
const mapStateToProps = state => ({
|
||||||
|
settings: state.getIn(['notifications', 'settings'])
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
|
||||||
|
onChange (key, checked) {
|
||||||
|
dispatch(changeNotificationsSetting(key, checked));
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings);
|
@ -9,13 +9,21 @@ import {
|
|||||||
import NotificationContainer from './containers/notification_container';
|
import NotificationContainer from './containers/notification_container';
|
||||||
import { ScrollContainer } from 'react-router-scroll';
|
import { ScrollContainer } from 'react-router-scroll';
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
|
import ColumnSettingsContainer from './containers/column_settings_container';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
import Immutable from 'immutable';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
title: { id: 'column.notifications', defaultMessage: 'Notifications' }
|
title: { id: 'column.notifications', defaultMessage: 'Notifications' }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getNotifications = createSelector([
|
||||||
|
state => Immutable.List(state.getIn(['notifications', 'settings', 'shows']).filter(item => !item).keys()),
|
||||||
|
state => state.getIn(['notifications', 'items'])
|
||||||
|
], (excludedTypes, notifications) => notifications.filterNot(item => excludedTypes.includes(item.get('type'))));
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
notifications: state.getIn(['notifications', 'items'])
|
notifications: getNotifications(state)
|
||||||
});
|
});
|
||||||
|
|
||||||
const Notifications = React.createClass({
|
const Notifications = React.createClass({
|
||||||
@ -23,7 +31,8 @@ const Notifications = React.createClass({
|
|||||||
propTypes: {
|
propTypes: {
|
||||||
notifications: ImmutablePropTypes.list.isRequired,
|
notifications: ImmutablePropTypes.list.isRequired,
|
||||||
dispatch: React.PropTypes.func.isRequired,
|
dispatch: React.PropTypes.func.isRequired,
|
||||||
trackScroll: React.PropTypes.bool
|
trackScroll: React.PropTypes.bool,
|
||||||
|
intl: React.PropTypes.object.isRequired
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps () {
|
getDefaultProps () {
|
||||||
@ -69,6 +78,7 @@ const Notifications = React.createClass({
|
|||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<Column icon='bell' heading={intl.formatMessage(messages.title)}>
|
<Column icon='bell' heading={intl.formatMessage(messages.title)}>
|
||||||
|
<ColumnSettingsContainer />
|
||||||
{scrollableArea}
|
{scrollableArea}
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||||
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
const outerStyle = {
|
||||||
|
position: 'absolute',
|
||||||
|
right: '0',
|
||||||
|
top: '-48px',
|
||||||
|
padding: '15px',
|
||||||
|
fontSize: '16px',
|
||||||
|
background: '#2f3441',
|
||||||
|
flex: '0 0 auto',
|
||||||
|
cursor: 'pointer',
|
||||||
|
color: '#2b90d9'
|
||||||
|
};
|
||||||
|
|
||||||
|
const iconStyle = {
|
||||||
|
display: 'inline-block',
|
||||||
|
marginRight: '5px'
|
||||||
|
};
|
||||||
|
|
||||||
|
const ColumnBackButton = React.createClass({
|
||||||
|
|
||||||
|
contextTypes: {
|
||||||
|
router: React.PropTypes.object
|
||||||
|
},
|
||||||
|
|
||||||
|
mixins: [PureRenderMixin],
|
||||||
|
|
||||||
|
handleClick () {
|
||||||
|
this.context.router.push('/');
|
||||||
|
},
|
||||||
|
|
||||||
|
render () {
|
||||||
|
return (
|
||||||
|
<div style={{ position: 'relative' }}>
|
||||||
|
<div style={outerStyle} onClick={this.handleClick} className='column-back-button'>
|
||||||
|
<i className='fa fa-fw fa-chevron-left' style={iconStyle} />
|
||||||
|
<FormattedMessage id='column_back_button.label' defaultMessage='Back' />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export default ColumnBackButton;
|
@ -8,6 +8,7 @@ import {
|
|||||||
deleteFromTimelines
|
deleteFromTimelines
|
||||||
} from '../../actions/timelines';
|
} from '../../actions/timelines';
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
|
import ColumnBackButton from './components/column_back_button';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
title: { id: 'column.public', defaultMessage: 'Public' }
|
title: { id: 'column.public', defaultMessage: 'Public' }
|
||||||
@ -16,7 +17,8 @@ const messages = defineMessages({
|
|||||||
const PublicTimeline = React.createClass({
|
const PublicTimeline = React.createClass({
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
dispatch: React.PropTypes.func.isRequired
|
dispatch: React.PropTypes.func.isRequired,
|
||||||
|
intl: React.PropTypes.object.isRequired
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [PureRenderMixin],
|
mixins: [PureRenderMixin],
|
||||||
@ -53,6 +55,7 @@ const PublicTimeline = React.createClass({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='globe' heading={intl.formatMessage(messages.title)}>
|
<Column icon='globe' heading={intl.formatMessage(messages.title)}>
|
||||||
|
<ColumnBackButton />
|
||||||
<StatusListContainer type='public' />
|
<StatusListContainer type='public' />
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
@ -40,7 +40,8 @@ const Column = React.createClass({
|
|||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
heading: React.PropTypes.string,
|
heading: React.PropTypes.string,
|
||||||
icon: React.PropTypes.string
|
icon: React.PropTypes.string,
|
||||||
|
children: React.PropTypes.node
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [PureRenderMixin],
|
mixins: [PureRenderMixin],
|
||||||
|
@ -52,7 +52,13 @@ const en = {
|
|||||||
"notification.follow": "{name} followed you",
|
"notification.follow": "{name} followed you",
|
||||||
"notification.favourite": "{name} favourited your status",
|
"notification.favourite": "{name} favourited your status",
|
||||||
"notification.reblog": "{name} boosted your status",
|
"notification.reblog": "{name} boosted your status",
|
||||||
"notification.mention": "{name} mentioned you"
|
"notification.mention": "{name} mentioned you",
|
||||||
|
"notifications.column_settings.alert": "Desktop notifications",
|
||||||
|
"notifications.column_settings.show": "Show in column",
|
||||||
|
"notifications.column_settings.follow": "New followers:",
|
||||||
|
"notifications.column_settings.favourite": "Favourites:",
|
||||||
|
"notifications.column_settings.mention": "Mentions:",
|
||||||
|
"notifications.column_settings.reblog": "Boosts:",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default en;
|
export default en;
|
||||||
|
@ -6,7 +6,8 @@ import {
|
|||||||
FOLLOWING_FETCH_SUCCESS,
|
FOLLOWING_FETCH_SUCCESS,
|
||||||
FOLLOWING_EXPAND_SUCCESS,
|
FOLLOWING_EXPAND_SUCCESS,
|
||||||
ACCOUNT_TIMELINE_FETCH_SUCCESS,
|
ACCOUNT_TIMELINE_FETCH_SUCCESS,
|
||||||
ACCOUNT_TIMELINE_EXPAND_SUCCESS
|
ACCOUNT_TIMELINE_EXPAND_SUCCESS,
|
||||||
|
FOLLOW_REQUESTS_FETCH_SUCCESS
|
||||||
} from '../actions/accounts';
|
} from '../actions/accounts';
|
||||||
import { COMPOSE_SUGGESTIONS_READY } from '../actions/compose';
|
import { COMPOSE_SUGGESTIONS_READY } from '../actions/compose';
|
||||||
import {
|
import {
|
||||||
@ -78,6 +79,7 @@ export default function accounts(state = initialState, action) {
|
|||||||
case FAVOURITES_FETCH_SUCCESS:
|
case FAVOURITES_FETCH_SUCCESS:
|
||||||
case COMPOSE_SUGGESTIONS_READY:
|
case COMPOSE_SUGGESTIONS_READY:
|
||||||
case SEARCH_SUGGESTIONS_READY:
|
case SEARCH_SUGGESTIONS_READY:
|
||||||
|
case FOLLOW_REQUESTS_FETCH_SUCCESS:
|
||||||
return normalizeAccounts(state, action.accounts);
|
return normalizeAccounts(state, action.accounts);
|
||||||
case NOTIFICATIONS_REFRESH_SUCCESS:
|
case NOTIFICATIONS_REFRESH_SUCCESS:
|
||||||
case NOTIFICATIONS_EXPAND_SUCCESS:
|
case NOTIFICATIONS_EXPAND_SUCCESS:
|
||||||
|
@ -30,6 +30,7 @@ const initialState = Immutable.Map({
|
|||||||
unlisted: false,
|
unlisted: false,
|
||||||
private: false,
|
private: false,
|
||||||
text: '',
|
text: '',
|
||||||
|
fileDropDate: null,
|
||||||
in_reply_to: null,
|
in_reply_to: null,
|
||||||
is_submitting: false,
|
is_submitting: false,
|
||||||
is_uploading: false,
|
is_uploading: false,
|
||||||
@ -116,7 +117,10 @@ export default function compose(state = initialState, action) {
|
|||||||
case COMPOSE_SUBMIT_FAIL:
|
case COMPOSE_SUBMIT_FAIL:
|
||||||
return state.set('is_submitting', false);
|
return state.set('is_submitting', false);
|
||||||
case COMPOSE_UPLOAD_REQUEST:
|
case COMPOSE_UPLOAD_REQUEST:
|
||||||
return state.set('is_uploading', true);
|
return state.withMutations(map => {
|
||||||
|
map.set('is_uploading', true);
|
||||||
|
map.set('fileDropDate', new Date());
|
||||||
|
});
|
||||||
case COMPOSE_UPLOAD_SUCCESS:
|
case COMPOSE_UPLOAD_SUCCESS:
|
||||||
return appendMedia(state, Immutable.fromJS(action.media));
|
return appendMedia(state, Immutable.fromJS(action.media));
|
||||||
case COMPOSE_UPLOAD_FAIL:
|
case COMPOSE_UPLOAD_FAIL:
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
NOTIFICATIONS_UPDATE,
|
NOTIFICATIONS_UPDATE,
|
||||||
NOTIFICATIONS_REFRESH_SUCCESS,
|
NOTIFICATIONS_REFRESH_SUCCESS,
|
||||||
NOTIFICATIONS_EXPAND_SUCCESS
|
NOTIFICATIONS_EXPAND_SUCCESS,
|
||||||
|
NOTIFICATIONS_SETTING_CHANGE
|
||||||
} from '../actions/notifications';
|
} from '../actions/notifications';
|
||||||
import { ACCOUNT_BLOCK_SUCCESS } from '../actions/accounts';
|
import { ACCOUNT_BLOCK_SUCCESS } from '../actions/accounts';
|
||||||
import Immutable from 'immutable';
|
import Immutable from 'immutable';
|
||||||
@ -9,7 +10,23 @@ import Immutable from 'immutable';
|
|||||||
const initialState = Immutable.Map({
|
const initialState = Immutable.Map({
|
||||||
items: Immutable.List(),
|
items: Immutable.List(),
|
||||||
next: null,
|
next: null,
|
||||||
loaded: false
|
loaded: false,
|
||||||
|
|
||||||
|
settings: Immutable.Map({
|
||||||
|
alerts: Immutable.Map({
|
||||||
|
follow: true,
|
||||||
|
favourite: true,
|
||||||
|
reblog: true,
|
||||||
|
mention: true
|
||||||
|
}),
|
||||||
|
|
||||||
|
shows: Immutable.Map({
|
||||||
|
follow: true,
|
||||||
|
favourite: true,
|
||||||
|
reblog: true,
|
||||||
|
mention: true
|
||||||
|
})
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const notificationToMap = notification => Immutable.Map({
|
const notificationToMap = notification => Immutable.Map({
|
||||||
@ -58,6 +75,8 @@ export default function notifications(state = initialState, action) {
|
|||||||
return appendNormalizedNotifications(state, action.notifications, action.next);
|
return appendNormalizedNotifications(state, action.notifications, action.next);
|
||||||
case ACCOUNT_BLOCK_SUCCESS:
|
case ACCOUNT_BLOCK_SUCCESS:
|
||||||
return filterNotifications(state, action.relationship);
|
return filterNotifications(state, action.relationship);
|
||||||
|
case NOTIFICATIONS_SETTING_CHANGE:
|
||||||
|
return state.setIn(['settings', ...action.key], action.checked);
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,10 @@ import {
|
|||||||
FOLLOWERS_FETCH_SUCCESS,
|
FOLLOWERS_FETCH_SUCCESS,
|
||||||
FOLLOWERS_EXPAND_SUCCESS,
|
FOLLOWERS_EXPAND_SUCCESS,
|
||||||
FOLLOWING_FETCH_SUCCESS,
|
FOLLOWING_FETCH_SUCCESS,
|
||||||
FOLLOWING_EXPAND_SUCCESS
|
FOLLOWING_EXPAND_SUCCESS,
|
||||||
|
FOLLOW_REQUESTS_FETCH_SUCCESS,
|
||||||
|
FOLLOW_REQUEST_AUTHORIZE_SUCCESS,
|
||||||
|
FOLLOW_REQUEST_REJECT_SUCCESS
|
||||||
} from '../actions/accounts';
|
} from '../actions/accounts';
|
||||||
import {
|
import {
|
||||||
REBLOGS_FETCH_SUCCESS,
|
REBLOGS_FETCH_SUCCESS,
|
||||||
@ -14,7 +17,8 @@ const initialState = Immutable.Map({
|
|||||||
followers: Immutable.Map(),
|
followers: Immutable.Map(),
|
||||||
following: Immutable.Map(),
|
following: Immutable.Map(),
|
||||||
reblogged_by: Immutable.Map(),
|
reblogged_by: Immutable.Map(),
|
||||||
favourited_by: Immutable.Map()
|
favourited_by: Immutable.Map(),
|
||||||
|
follow_requests: Immutable.Map()
|
||||||
});
|
});
|
||||||
|
|
||||||
const normalizeList = (state, type, id, accounts, next) => {
|
const normalizeList = (state, type, id, accounts, next) => {
|
||||||
@ -44,6 +48,11 @@ export default function userLists(state = initialState, action) {
|
|||||||
return state.setIn(['reblogged_by', action.id], Immutable.List(action.accounts.map(item => item.id)));
|
return state.setIn(['reblogged_by', action.id], Immutable.List(action.accounts.map(item => item.id)));
|
||||||
case FAVOURITES_FETCH_SUCCESS:
|
case FAVOURITES_FETCH_SUCCESS:
|
||||||
return state.setIn(['favourited_by', action.id], Immutable.List(action.accounts.map(item => item.id)));
|
return state.setIn(['favourited_by', action.id], Immutable.List(action.accounts.map(item => item.id)));
|
||||||
|
case FOLLOW_REQUESTS_FETCH_SUCCESS:
|
||||||
|
return state.setIn(['follow_requests', 'items'], Immutable.List(action.accounts.map(item => item.id))).setIn(['follow_requests', 'next'], action.next);
|
||||||
|
case FOLLOW_REQUEST_AUTHORIZE_SUCCESS:
|
||||||
|
case FOLLOW_REQUEST_REJECT_SUCCESS:
|
||||||
|
return state.updateIn(['follow_requests', 'items'], list => list.filterNot(item => item === action.id));
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -283,8 +283,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.name {
|
.name {
|
||||||
width: 333-20-60-15px;
|
|
||||||
float: left;
|
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
@ -326,3 +324,65 @@
|
|||||||
padding-bottom: 25px;
|
padding-bottom: 25px;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.account-card {
|
||||||
|
padding: 14px 10px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 4px;
|
||||||
|
text-align: left;
|
||||||
|
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
|
||||||
|
|
||||||
|
.detailed-status__display-name {
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
& > div {
|
||||||
|
float: left;
|
||||||
|
margin-right: 10px;
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar {
|
||||||
|
display: block;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.display-name {
|
||||||
|
display: block;
|
||||||
|
max-width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
cursor: default;
|
||||||
|
|
||||||
|
strong {
|
||||||
|
font-weight: 500;
|
||||||
|
color: #282c37;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #9baec8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
.display-name {
|
||||||
|
strong {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.account__header__content {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #282c37;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -214,11 +214,13 @@ body {
|
|||||||
.footer {
|
.footer {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: darken(#d9e1e8, 25%);
|
||||||
|
|
||||||
.domain {
|
.domain {
|
||||||
font-size: 12px;
|
//font-size: 12px;
|
||||||
font-weight: 400;
|
font-weight: 500;
|
||||||
font-family: 'Roboto Mono', monospace;
|
//font-family: 'Roboto Mono', monospace;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
@ -227,13 +229,12 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.powered-by {
|
.powered-by {
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
color: darken(#d9e1e8, 25%);
|
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
|
font-weight: 500;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
@ -147,6 +147,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-height: 800px) {
|
||||||
|
.account__header__avatar, .account__header__content {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.account__header__content {
|
.account__header__content {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
@ -332,6 +338,7 @@
|
|||||||
|
|
||||||
.column {
|
.column {
|
||||||
width: 330px;
|
width: 330px;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer {
|
.drawer {
|
||||||
@ -542,13 +549,19 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
resize: none;
|
resize: none;
|
||||||
border: none;
|
|
||||||
color: #282c37;
|
color: #282c37;
|
||||||
padding: 10px;
|
padding: 7px;
|
||||||
font-family: 'Roboto';
|
font-family: 'Roboto';
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
resize: vertical;
|
resize: vertical;
|
||||||
|
|
||||||
|
border: 3px dashed transparent;
|
||||||
|
transition: border-color 0.3s ease;
|
||||||
|
|
||||||
|
&.file-drop {
|
||||||
|
border-color: #aaa;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.autosuggest-textarea__suggestions {
|
.autosuggest-textarea__suggestions {
|
||||||
@ -575,3 +588,13 @@
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.getting-started__illustration {
|
||||||
|
width: 330px;
|
||||||
|
height: 235px;
|
||||||
|
background: image-url('mastodon-getting-started.png') no-repeat 0 0;
|
||||||
|
position: absolute;
|
||||||
|
pointer-events: none;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
@ -185,7 +185,7 @@ code {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.oauth-prompt {
|
.oauth-prompt, .follow-prompt {
|
||||||
margin-bottom: 30px;
|
margin-bottom: 30px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #9baec8;
|
color: #9baec8;
|
||||||
|
21
app/controllers/api/v1/blocks_controller.rb
Normal file
21
app/controllers/api/v1/blocks_controller.rb
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V1::BlocksController < ApiController
|
||||||
|
before_action -> { doorkeeper_authorize! :follow }
|
||||||
|
before_action :require_user!
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
|
def index
|
||||||
|
results = Block.where(account: current_account).paginate_by_max_id(DEFAULT_ACCOUNTS_LIMIT, params[:max_id], params[:since_id])
|
||||||
|
accounts = Account.where(id: results.map(&:target_account_id)).map { |a| [a.id, a] }.to_h
|
||||||
|
@accounts = results.map { |f| accounts[f.target_account_id] }
|
||||||
|
|
||||||
|
set_account_counters_maps(@accounts)
|
||||||
|
|
||||||
|
next_path = api_v1_blocks_url(max_id: results.last.id) if results.size == DEFAULT_ACCOUNTS_LIMIT
|
||||||
|
prev_path = api_v1_blocks_url(since_id: results.first.id) unless results.empty?
|
||||||
|
|
||||||
|
set_pagination_headers(next_path, prev_path)
|
||||||
|
end
|
||||||
|
end
|
21
app/controllers/api/v1/favourites_controller.rb
Normal file
21
app/controllers/api/v1/favourites_controller.rb
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V1::FavouritesController < ApiController
|
||||||
|
before_action -> { doorkeeper_authorize! :read }
|
||||||
|
before_action :require_user!
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
|
def index
|
||||||
|
results = Favourite.where(account: current_account).paginate_by_max_id(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id])
|
||||||
|
@statuses = cache_collection(Status.where(id: results.map(&:status_id)), Status)
|
||||||
|
|
||||||
|
set_maps(@statuses)
|
||||||
|
set_counters_maps(@statuses)
|
||||||
|
|
||||||
|
next_path = api_v1_favourites_url(max_id: results.last.id) if results.size == DEFAULT_ACCOUNTS_LIMIT
|
||||||
|
prev_path = api_v1_favourites_url(since_id: results.first.id) unless results.empty?
|
||||||
|
|
||||||
|
set_pagination_headers(next_path, prev_path)
|
||||||
|
end
|
||||||
|
end
|
29
app/controllers/api/v1/follow_requests_controller.rb
Normal file
29
app/controllers/api/v1/follow_requests_controller.rb
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V1::FollowRequestsController < ApiController
|
||||||
|
before_action -> { doorkeeper_authorize! :follow }
|
||||||
|
before_action :require_user!
|
||||||
|
|
||||||
|
def index
|
||||||
|
results = FollowRequest.where(target_account: current_account).paginate_by_max_id(DEFAULT_ACCOUNTS_LIMIT, params[:max_id], params[:since_id])
|
||||||
|
accounts = Account.where(id: results.map(&:account_id)).map { |a| [a.id, a] }.to_h
|
||||||
|
@accounts = results.map { |f| accounts[f.account_id] }
|
||||||
|
|
||||||
|
set_account_counters_maps(@accounts)
|
||||||
|
|
||||||
|
next_path = api_v1_follow_requests_url(max_id: results.last.id) if results.size == DEFAULT_ACCOUNTS_LIMIT
|
||||||
|
prev_path = api_v1_follow_requests_url(since_id: results.first.id) unless results.empty?
|
||||||
|
|
||||||
|
set_pagination_headers(next_path, prev_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def authorize
|
||||||
|
FollowRequest.find_by!(account_id: params[:id], target_account: current_account).authorize!
|
||||||
|
render_empty
|
||||||
|
end
|
||||||
|
|
||||||
|
def reject
|
||||||
|
FollowRequest.find_by!(account_id: params[:id], target_account: current_account).reject!
|
||||||
|
render_empty
|
||||||
|
end
|
||||||
|
end
|
@ -7,7 +7,7 @@ class Api::V1::NotificationsController < ApiController
|
|||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@notifications = Notification.where(account: current_account).paginate_by_max_id(20, params[:max_id], params[:since_id])
|
@notifications = Notification.where(account: current_account).browserable.paginate_by_max_id(20, params[:max_id], params[:since_id])
|
||||||
@notifications = cache_collection(@notifications, Notification)
|
@notifications = cache_collection(@notifications, Notification)
|
||||||
statuses = @notifications.select { |n| !n.target_status.nil? }.map(&:target_status)
|
statuses = @notifications.select { |n| !n.target_status.nil? }.map(&:target_status)
|
||||||
|
|
||||||
|
@ -49,13 +49,13 @@ class ApplicationController < ActionController::Base
|
|||||||
|
|
||||||
def not_found
|
def not_found
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.any { head 404 }
|
format.any { head 404 }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def gone
|
def gone
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.any { head 410 }
|
format.any { head 410 }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
45
app/controllers/authorize_follow_controller.rb
Normal file
45
app/controllers/authorize_follow_controller.rb
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class AuthorizeFollowController < ApplicationController
|
||||||
|
layout 'public'
|
||||||
|
|
||||||
|
before_action :authenticate_user!
|
||||||
|
|
||||||
|
def new
|
||||||
|
uri = Addressable::URI.parse(acct_param)
|
||||||
|
|
||||||
|
if uri.path && %w(http https).include?(uri.scheme)
|
||||||
|
set_account_from_url
|
||||||
|
else
|
||||||
|
set_account_from_acct
|
||||||
|
end
|
||||||
|
|
||||||
|
render :error if @account.nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@account = FollowService.new.call(current_account, acct_param).try(:target_account)
|
||||||
|
|
||||||
|
if @account.nil?
|
||||||
|
render :error
|
||||||
|
else
|
||||||
|
redirect_to web_url("accounts/#{@account.id}")
|
||||||
|
end
|
||||||
|
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermitted
|
||||||
|
render :error
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_account_from_url
|
||||||
|
@account = FetchRemoteAccountService.new.call(acct_param)
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_account_from_acct
|
||||||
|
@account = FollowRemoteAccountService.new.call(acct_param)
|
||||||
|
end
|
||||||
|
|
||||||
|
def acct_param
|
||||||
|
params[:acct].gsub(/\Aacct:/, '')
|
||||||
|
end
|
||||||
|
end
|
@ -1,28 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class FollowRequestsController < ApplicationController
|
|
||||||
layout 'auth'
|
|
||||||
|
|
||||||
before_action :authenticate_user!
|
|
||||||
before_action :set_follow_request, except: :index
|
|
||||||
|
|
||||||
def index
|
|
||||||
@follow_requests = FollowRequest.where(target_account: current_account)
|
|
||||||
end
|
|
||||||
|
|
||||||
def authorize
|
|
||||||
@follow_request.authorize!
|
|
||||||
redirect_to follow_requests_path
|
|
||||||
end
|
|
||||||
|
|
||||||
def reject
|
|
||||||
@follow_request.reject!
|
|
||||||
redirect_to follow_requests_path
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_follow_request
|
|
||||||
@follow_request = FollowRequest.find(params[:id])
|
|
||||||
end
|
|
||||||
end
|
|
47
app/controllers/remote_follow_controller.rb
Normal file
47
app/controllers/remote_follow_controller.rb
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class RemoteFollowController < ApplicationController
|
||||||
|
layout 'public'
|
||||||
|
|
||||||
|
before_action :set_account
|
||||||
|
before_action :check_account_suspension
|
||||||
|
|
||||||
|
def new
|
||||||
|
@remote_follow = RemoteFollow.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@remote_follow = RemoteFollow.new(resource_params)
|
||||||
|
|
||||||
|
if @remote_follow.valid?
|
||||||
|
resource = Goldfinger.finger("acct:#{@remote_follow.acct}")
|
||||||
|
redirect_url_link = resource&.link('http://ostatus.org/schema/1.0/subscribe')
|
||||||
|
|
||||||
|
if redirect_url_link.nil? || redirect_url_link.template.nil?
|
||||||
|
@remote_follow.errors.add(:acct, I18n.t('remote_follow.missing_resource'))
|
||||||
|
render(:new) && return
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to Addressable::Template.new(redirect_url_link.template).expand(uri: "#{@account.username}@#{Rails.configuration.x.local_domain}").to_s
|
||||||
|
else
|
||||||
|
render :new
|
||||||
|
end
|
||||||
|
rescue Goldfinger::Error
|
||||||
|
@remote_follow.errors.add(:acct, I18n.t('remote_follow.missing_resource'))
|
||||||
|
render :new
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def resource_params
|
||||||
|
params.require(:remote_follow).permit(:acct)
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_account
|
||||||
|
@account = Account.find_local!(params[:account_username])
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_account_suspension
|
||||||
|
head 410 if @account.suspended?
|
||||||
|
end
|
||||||
|
end
|
@ -8,10 +8,11 @@ class Settings::PreferencesController < ApplicationController
|
|||||||
def show; end
|
def show; end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
current_user.settings(:notification_emails).follow = user_params[:notification_emails][:follow] == '1'
|
current_user.settings(:notification_emails).follow = user_params[:notification_emails][:follow] == '1'
|
||||||
current_user.settings(:notification_emails).reblog = user_params[:notification_emails][:reblog] == '1'
|
current_user.settings(:notification_emails).follow_request = user_params[:notification_emails][:follow_request] == '1'
|
||||||
current_user.settings(:notification_emails).favourite = user_params[:notification_emails][:favourite] == '1'
|
current_user.settings(:notification_emails).reblog = user_params[:notification_emails][:reblog] == '1'
|
||||||
current_user.settings(:notification_emails).mention = user_params[:notification_emails][:mention] == '1'
|
current_user.settings(:notification_emails).favourite = user_params[:notification_emails][:favourite] == '1'
|
||||||
|
current_user.settings(:notification_emails).mention = user_params[:notification_emails][:mention] == '1'
|
||||||
|
|
||||||
current_user.settings(:interactions).must_be_follower = user_params[:interactions][:must_be_follower] == '1'
|
current_user.settings(:interactions).must_be_follower = user_params[:interactions][:must_be_follower] == '1'
|
||||||
current_user.settings(:interactions).must_be_following = user_params[:interactions][:must_be_following] == '1'
|
current_user.settings(:interactions).must_be_following = user_params[:interactions][:must_be_following] == '1'
|
||||||
@ -26,6 +27,6 @@ class Settings::PreferencesController < ApplicationController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def user_params
|
def user_params
|
||||||
params.require(:user).permit(:locale, notification_emails: [:follow, :reblog, :favourite, :mention], interactions: [:must_be_follower, :must_be_following])
|
params.require(:user).permit(:locale, notification_emails: [:follow, :follow_request, :reblog, :favourite, :mention], interactions: [:must_be_follower, :must_be_following])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
module Api::OembedHelper
|
|
||||||
end
|
|
4
app/helpers/authorize_follow_helper.rb
Normal file
4
app/helpers/authorize_follow_helper.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module AuthorizeFollowHelper
|
||||||
|
end
|
@ -1,2 +0,0 @@
|
|||||||
module FollowRequestsHelper
|
|
||||||
end
|
|
@ -10,7 +10,7 @@ module StreamEntriesHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def avatar_for_status_url(status)
|
def avatar_for_status_url(status)
|
||||||
status.reblog? ? status.reblog.account.avatar.url( :original) : status.account.avatar.url( :original)
|
status.reblog? ? status.reblog.account.avatar.url(:original) : status.account.avatar.url(:original)
|
||||||
end
|
end
|
||||||
|
|
||||||
def entry_classes(status, is_predecessor, is_successor, include_threads)
|
def entry_classes(status, is_predecessor, is_successor, include_threads)
|
||||||
|
@ -78,15 +78,15 @@ class FeedManager
|
|||||||
def filter_from_home?(status, receiver)
|
def filter_from_home?(status, receiver)
|
||||||
should_filter = false
|
should_filter = false
|
||||||
|
|
||||||
if status.reply? && !status.thread.account.nil? # Filter out if it's a reply
|
if status.reply? && !status.in_reply_to_account_id.nil? # Filter out if it's a reply
|
||||||
should_filter = !receiver.following?(status.thread.account) # and I'm not following the person it's a reply to
|
should_filter = !receiver.following?(status.in_reply_to_account) # and I'm not following the person it's a reply to
|
||||||
should_filter &&= !(receiver.id == status.thread.account_id) # and it's not a reply to me
|
should_filter &&= !(receiver.id == status.in_reply_to_account_id) # and it's not a reply to me
|
||||||
should_filter &&= !(status.account_id == status.thread.account_id) # and it's not a self-reply
|
should_filter &&= !(status.account_id == status.in_reply_to_account_id) # and it's not a self-reply
|
||||||
elsif status.reblog? # Filter out a reblog
|
elsif status.reblog? # Filter out a reblog
|
||||||
should_filter = receiver.blocking?(status.reblog.account) # if I'm blocking the reblogged person
|
should_filter = receiver.blocking?(status.reblog.account) # if I'm blocking the reblogged person
|
||||||
end
|
end
|
||||||
|
|
||||||
should_filter ||= receiver.blocking?(status.mentions.map(&:account_id)) # or if it mentions someone I blocked
|
should_filter ||= receiver.blocking?(status.mentions.map(&:account_id)) # or if it mentions someone I blocked
|
||||||
|
|
||||||
should_filter
|
should_filter
|
||||||
end
|
end
|
||||||
@ -98,8 +98,8 @@ class FeedManager
|
|||||||
should_filter ||= (status.account.silenced? && !receiver.following?(status.account)) # of if the account is silenced and I'm not following them
|
should_filter ||= (status.account.silenced? && !receiver.following?(status.account)) # of if the account is silenced and I'm not following them
|
||||||
should_filter ||= (status.private_visibility? && !receiver.following?(status.account)) # or if the mentioned account is not permitted to see the private status
|
should_filter ||= (status.private_visibility? && !receiver.following?(status.account)) # or if the mentioned account is not permitted to see the private status
|
||||||
|
|
||||||
if status.reply? && !status.thread.account.nil? # or it's a reply
|
if status.reply? && !status.in_reply_to_account_id.nil? # or it's a reply
|
||||||
should_filter ||= receiver.blocking?(status.thread.account) # to a user I blocked
|
should_filter ||= receiver.blocking?(status.in_reply_to_account) # to a user I blocked
|
||||||
end
|
end
|
||||||
|
|
||||||
should_filter
|
should_filter
|
||||||
@ -109,8 +109,8 @@ class FeedManager
|
|||||||
should_filter = receiver.blocking?(status.account)
|
should_filter = receiver.blocking?(status.account)
|
||||||
should_filter ||= receiver.blocking?(status.mentions.includes(:account).map(&:account))
|
should_filter ||= receiver.blocking?(status.mentions.includes(:account).map(&:account))
|
||||||
|
|
||||||
if status.reply? && !status.thread.account.nil?
|
if status.reply? && !status.in_reply_to_account_id.nil?
|
||||||
should_filter ||= receiver.blocking?(status.thread.account)
|
should_filter ||= receiver.blocking?(status.in_reply_to_account)
|
||||||
elsif status.reblog?
|
elsif status.reblog?
|
||||||
should_filter ||= receiver.blocking?(status.reblog.account)
|
should_filter ||= receiver.blocking?(status.reblog.account)
|
||||||
end
|
end
|
||||||
|
@ -14,6 +14,8 @@ class TagManager
|
|||||||
delete: 'http://activitystrea.ms/schema/1.0/delete',
|
delete: 'http://activitystrea.ms/schema/1.0/delete',
|
||||||
follow: 'http://activitystrea.ms/schema/1.0/follow',
|
follow: 'http://activitystrea.ms/schema/1.0/follow',
|
||||||
unfollow: 'http://ostatus.org/schema/1.0/unfollow',
|
unfollow: 'http://ostatus.org/schema/1.0/unfollow',
|
||||||
|
block: 'http://mastodon.social/schema/1.0/block',
|
||||||
|
unblock: 'http://mastodon.social/schema/1.0/unblock',
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
TYPES = {
|
TYPES = {
|
||||||
|
@ -40,4 +40,13 @@ class NotificationMailer < ApplicationMailer
|
|||||||
mail to: @me.user.email, subject: I18n.t('notification_mailer.reblog.subject', name: @account.acct)
|
mail to: @me.user.email, subject: I18n.t('notification_mailer.reblog.subject', name: @account.acct)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def follow_request(recipient, notification)
|
||||||
|
@me = recipient
|
||||||
|
@account = notification.from_account
|
||||||
|
|
||||||
|
I18n.with_locale(@me.user.locale || I18n.default_locale) do
|
||||||
|
mail to: @me.user.email, subject: I18n.t('notification_mailer.follow_request.subject', name: @account.acct)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Block < ApplicationRecord
|
class Block < ApplicationRecord
|
||||||
|
include Paginable
|
||||||
include Streamable
|
include Streamable
|
||||||
|
|
||||||
belongs_to :account
|
belongs_to :account
|
||||||
|
@ -29,6 +29,10 @@ class Favourite < ApplicationRecord
|
|||||||
thread
|
thread
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hidden?
|
||||||
|
status.private_visibility?
|
||||||
|
end
|
||||||
|
|
||||||
before_validation do
|
before_validation do
|
||||||
self.status = status.reblog if status.reblog?
|
self.status = status.reblog if status.reblog?
|
||||||
end
|
end
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class FollowRequest < ApplicationRecord
|
class FollowRequest < ApplicationRecord
|
||||||
|
include Paginable
|
||||||
|
|
||||||
belongs_to :account
|
belongs_to :account
|
||||||
belongs_to :target_account, class_name: 'Account'
|
belongs_to :target_account, class_name: 'Account'
|
||||||
|
|
||||||
|
has_one :notification, as: :activity, dependent: :destroy
|
||||||
|
|
||||||
validates :account, :target_account, presence: true
|
validates :account, :target_account, presence: true
|
||||||
validates :account_id, uniqueness: { scope: :target_account_id }
|
validates :account_id, uniqueness: { scope: :target_account_id }
|
||||||
|
|
||||||
|
@ -8,16 +8,18 @@ class Notification < ApplicationRecord
|
|||||||
belongs_to :from_account, class_name: 'Account'
|
belongs_to :from_account, class_name: 'Account'
|
||||||
belongs_to :activity, polymorphic: true
|
belongs_to :activity, polymorphic: true
|
||||||
|
|
||||||
belongs_to :mention, foreign_type: 'Mention', foreign_key: 'activity_id'
|
belongs_to :mention, foreign_type: 'Mention', foreign_key: 'activity_id'
|
||||||
belongs_to :status, foreign_type: 'Status', foreign_key: 'activity_id'
|
belongs_to :status, foreign_type: 'Status', foreign_key: 'activity_id'
|
||||||
belongs_to :follow, foreign_type: 'Follow', foreign_key: 'activity_id'
|
belongs_to :follow, foreign_type: 'Follow', foreign_key: 'activity_id'
|
||||||
belongs_to :favourite, foreign_type: 'Favourite', foreign_key: 'activity_id'
|
belongs_to :follow_request, foreign_type: 'FollowRequest', foreign_key: 'activity_id'
|
||||||
|
belongs_to :favourite, foreign_type: 'Favourite', foreign_key: 'activity_id'
|
||||||
|
|
||||||
validates :account_id, uniqueness: { scope: [:activity_type, :activity_id] }
|
validates :account_id, uniqueness: { scope: [:activity_type, :activity_id] }
|
||||||
|
|
||||||
STATUS_INCLUDES = [:account, :stream_entry, :media_attachments, :tags, mentions: :account, reblog: [:stream_entry, :account, :media_attachments, :tags, mentions: :account]].freeze
|
STATUS_INCLUDES = [:account, :stream_entry, :media_attachments, :tags, mentions: :account, reblog: [:stream_entry, :account, :media_attachments, :tags, mentions: :account]].freeze
|
||||||
|
|
||||||
scope :cache_ids, -> { select(:id, :updated_at, :activity_type, :activity_id) }
|
scope :cache_ids, -> { select(:id, :updated_at, :activity_type, :activity_id) }
|
||||||
|
scope :browserable, -> { where.not(activity_type: ['FollowRequest']) }
|
||||||
|
|
||||||
cache_associated :from_account, status: STATUS_INCLUDES, mention: [status: STATUS_INCLUDES], favourite: [:account, status: STATUS_INCLUDES], follow: :account
|
cache_associated :from_account, status: STATUS_INCLUDES, mention: [status: STATUS_INCLUDES], favourite: [:account, status: STATUS_INCLUDES], follow: :account
|
||||||
|
|
||||||
@ -30,7 +32,7 @@ class Notification < ApplicationRecord
|
|||||||
when 'Status'
|
when 'Status'
|
||||||
:reblog
|
:reblog
|
||||||
else
|
else
|
||||||
activity_type.downcase.to_sym
|
activity_type.underscore.to_sym
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -43,6 +45,10 @@ class Notification < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def browserable?
|
||||||
|
type != :follow_request
|
||||||
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def reload_stale_associations!(cached_items)
|
def reload_stale_associations!(cached_items)
|
||||||
account_ids = cached_items.map(&:from_account_id).uniq
|
account_ids = cached_items.map(&:from_account_id).uniq
|
||||||
@ -61,7 +67,7 @@ class Notification < ApplicationRecord
|
|||||||
|
|
||||||
def set_from_account
|
def set_from_account
|
||||||
case activity_type
|
case activity_type
|
||||||
when 'Status', 'Follow', 'Favourite'
|
when 'Status', 'Follow', 'Favourite', 'FollowRequest'
|
||||||
self.from_account_id = activity(false)&.account_id
|
self.from_account_id = activity(false)&.account_id
|
||||||
when 'Mention'
|
when 'Mention'
|
||||||
self.from_account_id = activity(false)&.status&.account_id
|
self.from_account_id = activity(false)&.status&.account_id
|
||||||
|
13
app/models/remote_follow.rb
Normal file
13
app/models/remote_follow.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class RemoteFollow
|
||||||
|
include ActiveModel::Validations
|
||||||
|
|
||||||
|
attr_accessor :acct
|
||||||
|
|
||||||
|
validates :acct, presence: true
|
||||||
|
|
||||||
|
def initialize(attrs = {})
|
||||||
|
@acct = attrs[:acct]
|
||||||
|
end
|
||||||
|
end
|
@ -8,6 +8,7 @@ class Status < ApplicationRecord
|
|||||||
enum visibility: [:public, :unlisted, :private], _suffix: :visibility
|
enum visibility: [:public, :unlisted, :private], _suffix: :visibility
|
||||||
|
|
||||||
belongs_to :account, inverse_of: :statuses
|
belongs_to :account, inverse_of: :statuses
|
||||||
|
belongs_to :in_reply_to_account, foreign_key: 'in_reply_to_account_id', class_name: 'Account'
|
||||||
|
|
||||||
belongs_to :thread, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :replies
|
belongs_to :thread, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :replies
|
||||||
belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs, touch: true
|
belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs, touch: true
|
||||||
@ -31,7 +32,6 @@ class Status < ApplicationRecord
|
|||||||
|
|
||||||
scope :remote, -> { where.not(uri: nil) }
|
scope :remote, -> { where.not(uri: nil) }
|
||||||
scope :local, -> { where(uri: nil) }
|
scope :local, -> { where(uri: nil) }
|
||||||
scope :permitted_for, ->(target_account, account) { account&.id == target_account.id || account&.following?(target_account) ? where('1=1') : where.not(visibility: :private) }
|
|
||||||
|
|
||||||
cache_associated :account, :media_attachments, :tags, :stream_entry, mentions: :account, reblog: [:account, :stream_entry, :tags, :media_attachments, mentions: :account], thread: :account
|
cache_associated :account, :media_attachments, :tags, :stream_entry, mentions: :account, reblog: [:account, :stream_entry, :tags, :media_attachments, mentions: :account], thread: :account
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ class Status < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def permitted?(other_account = nil)
|
def permitted?(other_account = nil)
|
||||||
private_visibility? ? (account.id == other_account&.id || other_account&.following?(account)) : true
|
private_visibility? ? (account.id == other_account&.id || other_account&.following?(account)) : other_account.nil? || !account.blocking?(other_account)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ancestors(account = nil)
|
def ancestors(account = nil)
|
||||||
@ -145,6 +145,16 @@ class Status < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def permitted_for(target_account, account)
|
||||||
|
if account&.id == target_account.id || account&.following?(target_account)
|
||||||
|
where('1 = 1')
|
||||||
|
elsif !account.nil? && target_account.blocking?(account)
|
||||||
|
where('1 = 0')
|
||||||
|
else
|
||||||
|
where.not(visibility: :private)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def filter_timeline(query, account)
|
def filter_timeline(query, account)
|
||||||
@ -161,8 +171,9 @@ class Status < ApplicationRecord
|
|||||||
|
|
||||||
before_validation do
|
before_validation do
|
||||||
text.strip!
|
text.strip!
|
||||||
self.reblog = reblog.reblog if reblog? && reblog.reblog?
|
|
||||||
self.in_reply_to_account_id = thread.account_id if reply?
|
self.reblog = reblog.reblog if reblog? && reblog.reblog?
|
||||||
|
self.in_reply_to_account_id = (thread.account_id == account_id && thread.reply? ? thread.in_reply_to_account_id : thread.account_id) if reply?
|
||||||
self.visibility = (account.locked? ? :private : :public) if visibility.nil?
|
self.visibility = (account.locked? ? :private : :public) if visibility.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class User < ApplicationRecord
|
|||||||
scope :admins, -> { where(admin: true) }
|
scope :admins, -> { where(admin: true) }
|
||||||
|
|
||||||
has_settings do |s|
|
has_settings do |s|
|
||||||
s.key :notification_emails, defaults: { follow: false, reblog: false, favourite: false, mention: false }
|
s.key :notification_emails, defaults: { follow: false, reblog: false, favourite: false, mention: false, follow_request: true }
|
||||||
s.key :interactions, defaults: { must_be_follower: false, must_be_following: false }
|
s.key :interactions, defaults: { must_be_follower: false, must_be_following: false }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -7,10 +7,12 @@ class BlockService < BaseService
|
|||||||
UnfollowService.new.call(account, target_account) if account.following?(target_account)
|
UnfollowService.new.call(account, target_account) if account.following?(target_account)
|
||||||
UnfollowService.new.call(target_account, account) if target_account.following?(account)
|
UnfollowService.new.call(target_account, account) if target_account.following?(account)
|
||||||
|
|
||||||
account.block!(target_account)
|
block = account.block!(target_account)
|
||||||
|
|
||||||
clear_timelines(account, target_account)
|
clear_timelines(account, target_account)
|
||||||
clear_notifications(account, target_account)
|
clear_notifications(account, target_account)
|
||||||
|
|
||||||
|
NotificationWorker.perform_async(block.stream_entry.id, target_account.id) unless target_account.local?
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -6,12 +6,14 @@ class FavouriteService < BaseService
|
|||||||
# @param [Status] status
|
# @param [Status] status
|
||||||
# @return [Favourite]
|
# @return [Favourite]
|
||||||
def call(account, status)
|
def call(account, status)
|
||||||
|
raise Mastodon::NotPermitted unless status.permitted?(account)
|
||||||
|
|
||||||
favourite = Favourite.create!(account: account, status: status)
|
favourite = Favourite.create!(account: account, status: status)
|
||||||
|
|
||||||
Pubsubhubbub::DistributionWorker.perform_async(favourite.stream_entry.id)
|
Pubsubhubbub::DistributionWorker.perform_async(favourite.stream_entry.id)
|
||||||
|
|
||||||
if status.local?
|
if status.local?
|
||||||
NotifyService.new.call(status.account, favourite)
|
NotifyService.new.call(favourite.status.account, favourite)
|
||||||
else
|
else
|
||||||
NotificationWorker.perform_async(favourite.stream_entry.id, status.account_id)
|
NotificationWorker.perform_async(favourite.stream_entry.id, status.account_id)
|
||||||
end
|
end
|
||||||
|
@ -20,7 +20,12 @@ class FollowService < BaseService
|
|||||||
private
|
private
|
||||||
|
|
||||||
def request_follow(source_account, target_account)
|
def request_follow(source_account, target_account)
|
||||||
FollowRequest.create!(account: source_account, target_account: target_account)
|
return unless target_account.local?
|
||||||
|
|
||||||
|
follow_request = FollowRequest.create!(account: source_account, target_account: target_account)
|
||||||
|
NotifyService.new.call(target_account, follow_request)
|
||||||
|
|
||||||
|
follow_request
|
||||||
end
|
end
|
||||||
|
|
||||||
def direct_follow(source_account, target_account)
|
def direct_follow(source_account, target_account)
|
||||||
|
@ -32,6 +32,10 @@ class NotifyService < BaseService
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def blocked_follow_request?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
def blocked?
|
def blocked?
|
||||||
blocked = @recipient.suspended? # Skip if the recipient account is suspended anyway
|
blocked = @recipient.suspended? # Skip if the recipient account is suspended anyway
|
||||||
blocked ||= @recipient.id == @notification.from_account.id # Skip for interactions with self
|
blocked ||= @recipient.id == @notification.from_account.id # Skip for interactions with self
|
||||||
@ -45,6 +49,7 @@ class NotifyService < BaseService
|
|||||||
|
|
||||||
def create_notification
|
def create_notification
|
||||||
@notification.save!
|
@notification.save!
|
||||||
|
return unless @notification.browserable?
|
||||||
FeedManager.instance.broadcast(@recipient.id, type: 'notification', message: FeedManager.instance.inline_render(@recipient, 'api/v1/notifications/show', @notification))
|
FeedManager.instance.broadcast(@recipient.id, type: 'notification', message: FeedManager.instance.inline_render(@recipient, 'api/v1/notifications/show', @notification))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class ProcessInteractionService < BaseService
|
|||||||
|
|
||||||
case verb(xml)
|
case verb(xml)
|
||||||
when :follow
|
when :follow
|
||||||
follow!(account, target_account) unless target_account.locked?
|
follow!(account, target_account) unless target_account.locked? || target_account.blocking?(account)
|
||||||
when :unfollow
|
when :unfollow
|
||||||
unfollow!(account, target_account)
|
unfollow!(account, target_account)
|
||||||
when :favorite
|
when :favorite
|
||||||
@ -41,6 +41,10 @@ class ProcessInteractionService < BaseService
|
|||||||
add_post!(body, account) unless status(xml).nil?
|
add_post!(body, account) unless status(xml).nil?
|
||||||
when :delete
|
when :delete
|
||||||
delete_post!(xml, account)
|
delete_post!(xml, account)
|
||||||
|
when :block
|
||||||
|
reflect_block!(account, target_account)
|
||||||
|
when :unblock
|
||||||
|
reflect_unblock!(account, target_account)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue Goldfinger::Error, HTTP::Error, OStatus2::BadSalmonError
|
rescue Goldfinger::Error, HTTP::Error, OStatus2::BadSalmonError
|
||||||
@ -74,6 +78,15 @@ class ProcessInteractionService < BaseService
|
|||||||
account.unfollow!(target_account)
|
account.unfollow!(target_account)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reflect_block!(account, target_account)
|
||||||
|
UnfollowService.new.call(target_account, account) if target_account.following?(account)
|
||||||
|
account.block!(target_account)
|
||||||
|
end
|
||||||
|
|
||||||
|
def reflect_unblock!(account, target_account)
|
||||||
|
UnblockService.new.call(account, target_account)
|
||||||
|
end
|
||||||
|
|
||||||
def delete_post!(xml, account)
|
def delete_post!(xml, account)
|
||||||
status = Status.find(xml.at_xpath('//xmlns:id', xmlns: TagManager::XMLNS).content)
|
status = Status.find(xml.at_xpath('//xmlns:id', xmlns: TagManager::XMLNS).content)
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@ class ReblogService < BaseService
|
|||||||
Pubsubhubbub::DistributionWorker.perform_async(reblog.stream_entry.id)
|
Pubsubhubbub::DistributionWorker.perform_async(reblog.stream_entry.id)
|
||||||
|
|
||||||
if reblogged_status.local?
|
if reblogged_status.local?
|
||||||
NotifyService.new.call(reblogged_status.account, reblog)
|
NotifyService.new.call(reblog.reblog.account, reblog)
|
||||||
else
|
else
|
||||||
NotificationWorker.perform_async(reblog.stream_entry.id, reblogged_status.account_id)
|
NotificationWorker.perform_async(reblog.stream_entry.id, reblog.reblog.account_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
reblog
|
reblog
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
class UnblockService < BaseService
|
class UnblockService < BaseService
|
||||||
def call(account, target_account)
|
def call(account, target_account)
|
||||||
account.unblock!(target_account) if account.blocking?(target_account)
|
return unless account.blocking?(target_account)
|
||||||
|
|
||||||
|
unblock = account.unblock!(target_account)
|
||||||
|
NotificationWorker.perform_async(unblock.stream_entry.id, target_account.id) unless target_account.local?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
.account-grid-card
|
.account-grid-card
|
||||||
.account-grid-card__header
|
.account-grid-card__header
|
||||||
.avatar= image_tag account.avatar.url( :original)
|
.avatar= image_tag account.avatar.url(:original)
|
||||||
.name
|
.name
|
||||||
= link_to TagManager.instance.url_for(account) do
|
= link_to TagManager.instance.url_for(account) do
|
||||||
%span.display_name= display_name(account)
|
%span.display_name= display_name(account)
|
||||||
|
@ -5,8 +5,11 @@
|
|||||||
= link_to t('accounts.unfollow'), unfollow_account_path(@account), data: { method: :post }, class: 'button'
|
= link_to t('accounts.unfollow'), unfollow_account_path(@account), data: { method: :post }, class: 'button'
|
||||||
- else
|
- else
|
||||||
= link_to t('accounts.follow'), follow_account_path(@account), data: { method: :post }, class: 'button'
|
= link_to t('accounts.follow'), follow_account_path(@account), data: { method: :post }, class: 'button'
|
||||||
|
- else
|
||||||
.avatar= image_tag @account.avatar.url( :original)
|
.controls
|
||||||
|
.remote-follow
|
||||||
|
= link_to t('accounts.remote_follow'), account_remote_follow_path(@account), class: 'button'
|
||||||
|
.avatar= image_tag @account.avatar.url(:original)
|
||||||
%h1.name
|
%h1.name
|
||||||
= display_name(@account)
|
= display_name(@account)
|
||||||
%small
|
%small
|
||||||
@ -20,12 +23,12 @@
|
|||||||
.counter{ class: active_nav_class(account_url(@account)) }
|
.counter{ class: active_nav_class(account_url(@account)) }
|
||||||
= link_to account_url(@account) do
|
= link_to account_url(@account) do
|
||||||
%span.counter-label= t('accounts.posts')
|
%span.counter-label= t('accounts.posts')
|
||||||
%span.counter-number= @account.statuses.count
|
%span.counter-number= number_with_delimiter @account.statuses.count
|
||||||
.counter{ class: active_nav_class(following_account_url(@account)) }
|
.counter{ class: active_nav_class(following_account_url(@account)) }
|
||||||
= link_to following_account_url(@account) do
|
= link_to following_account_url(@account) do
|
||||||
%span.counter-label= t('accounts.following')
|
%span.counter-label= t('accounts.following')
|
||||||
%span.counter-number= @account.following.count
|
%span.counter-number= number_with_delimiter @account.following.count
|
||||||
.counter{ class: active_nav_class(followers_account_url(@account)) }
|
.counter{ class: active_nav_class(followers_account_url(@account)) }
|
||||||
= link_to followers_account_url(@account) do
|
= link_to followers_account_url(@account) do
|
||||||
%span.counter-label= t('accounts.followers')
|
%span.counter-label= t('accounts.followers')
|
||||||
%span.counter-number= @account.followers.count
|
%span.counter-number= number_with_delimiter @account.followers.count
|
||||||
|
2
app/views/api/v1/blocks/index.rabl
Normal file
2
app/views/api/v1/blocks/index.rabl
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
collection @accounts
|
||||||
|
extends 'api/v1/accounts/show'
|
2
app/views/api/v1/favourites/index.rabl
Normal file
2
app/views/api/v1/favourites/index.rabl
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
collection @statuses
|
||||||
|
extends 'api/v1/statuses/show'
|
2
app/views/api/v1/follow_requests/index.rabl
Normal file
2
app/views/api/v1/follow_requests/index.rabl
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
collection @accounts
|
||||||
|
extends 'api/v1/accounts/show'
|
11
app/views/authorize_follow/_card.html.haml
Normal file
11
app/views/authorize_follow/_card.html.haml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
.account-card
|
||||||
|
.detailed-status__display-name
|
||||||
|
%div
|
||||||
|
= image_tag account.avatar.url(:original), alt: '', width: 48, height: 48, class: 'avatar'
|
||||||
|
|
||||||
|
%span.display-name
|
||||||
|
%strong= display_name(account)
|
||||||
|
%span= "@#{account.acct}"
|
||||||
|
|
||||||
|
- unless account.note.blank?
|
||||||
|
.account__header__content= Formatter.instance.simplified_format(account)
|
3
app/views/authorize_follow/error.html.haml
Normal file
3
app/views/authorize_follow/error.html.haml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.form-container
|
||||||
|
.flash-message#error_explanation
|
||||||
|
= t('authorize_follow.error')
|
12
app/views/authorize_follow/new.html.haml
Normal file
12
app/views/authorize_follow/new.html.haml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
- content_for :page_title do
|
||||||
|
= t('authorize_follow.title', acct: @account.acct)
|
||||||
|
|
||||||
|
.form-container
|
||||||
|
.follow-prompt
|
||||||
|
%h2= t('authorize_follow.prompt_html', self: current_account.username)
|
||||||
|
|
||||||
|
= render partial: 'card', locals: { account: @account }
|
||||||
|
|
||||||
|
= form_tag authorize_follow_path, method: :post, class: 'simple_form' do
|
||||||
|
= hidden_field_tag :acct, @account.acct
|
||||||
|
= button_tag t('authorize_follow.follow'), type: :submit
|
@ -1,16 +0,0 @@
|
|||||||
- content_for :page_title do
|
|
||||||
= t('follow_requests.title')
|
|
||||||
|
|
||||||
- if @follow_requests.empty?
|
|
||||||
%p.nothing-here= t('accounts.nothing_here')
|
|
||||||
- else
|
|
||||||
%table.table
|
|
||||||
%tbody
|
|
||||||
- @follow_requests.each do |follow_request|
|
|
||||||
%tr
|
|
||||||
%td= link_to follow_request.account.acct, web_path("accounts/#{follow_request.account.id}")
|
|
||||||
%td{ style: 'text-align: right' }
|
|
||||||
= table_link_to 'check-circle', t('follow_requests.authorize'), authorize_follow_request_path(follow_request), method: :post
|
|
||||||
= table_link_to 'times-circle', t('follow_requests.reject'), reject_follow_request_path(follow_request), method: :post
|
|
||||||
|
|
||||||
.form-footer= render "settings/shared/links"
|
|
@ -1,3 +1,6 @@
|
|||||||
|
- content_for :header_tags do
|
||||||
|
= javascript_include_tag 'application_public'
|
||||||
|
|
||||||
- content_for :content do
|
- content_for :content do
|
||||||
.admin-wrapper
|
.admin-wrapper
|
||||||
.sidebar
|
.sidebar
|
||||||
|
5
app/views/notification_mailer/follow_request.text.erb
Normal file
5
app/views/notification_mailer/follow_request.text.erb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<%= display_name(@me) %>,
|
||||||
|
|
||||||
|
<%= t('notification_mailer.follow_request.body', name: @account.acct) %>
|
||||||
|
|
||||||
|
<%= web_url("follow_requests") %>
|
@ -1,2 +1,3 @@
|
|||||||
.flash-message#error_explanation
|
.form-container
|
||||||
= @pre_auth.error_response.body[:error_description]
|
.flash-message#error_explanation
|
||||||
|
= @pre_auth.error_response.body[:error_description]
|
||||||
|
@ -1,25 +1,26 @@
|
|||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
= t('doorkeeper.authorizations.new.title')
|
= t('doorkeeper.authorizations.new.title')
|
||||||
|
|
||||||
.oauth-prompt
|
.form-container
|
||||||
%h2= t('doorkeeper.authorizations.new.prompt', client_name: @pre_auth.client.name)
|
.oauth-prompt
|
||||||
|
%h2= t('doorkeeper.authorizations.new.prompt', client_name: @pre_auth.client.name)
|
||||||
|
|
||||||
%p
|
%p
|
||||||
= t('doorkeeper.authorizations.new.able_to')
|
= t('doorkeeper.authorizations.new.able_to')
|
||||||
= @pre_auth.scopes.map { |scope| t(scope, scope: [:doorkeeper, :scopes]) }.map { |s| "<strong>#{s}</strong>"}.to_sentence.html_safe
|
= @pre_auth.scopes.map { |scope| t(scope, scope: [:doorkeeper, :scopes]) }.map { |s| "<strong>#{s}</strong>"}.to_sentence.html_safe
|
||||||
|
|
||||||
= form_tag oauth_authorization_path, method: :post, class: 'simple_form' do
|
= form_tag oauth_authorization_path, method: :post, class: 'simple_form' do
|
||||||
= hidden_field_tag :client_id, @pre_auth.client.uid
|
= hidden_field_tag :client_id, @pre_auth.client.uid
|
||||||
= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri
|
= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri
|
||||||
= hidden_field_tag :state, @pre_auth.state
|
= hidden_field_tag :state, @pre_auth.state
|
||||||
= hidden_field_tag :response_type, @pre_auth.response_type
|
= hidden_field_tag :response_type, @pre_auth.response_type
|
||||||
= hidden_field_tag :scope, @pre_auth.scope
|
= hidden_field_tag :scope, @pre_auth.scope
|
||||||
= button_tag t('doorkeeper.authorizations.buttons.authorize'), type: :submit
|
= button_tag t('doorkeeper.authorizations.buttons.authorize'), type: :submit
|
||||||
|
|
||||||
= form_tag oauth_authorization_path, method: :delete, class: 'simple_form' do
|
= form_tag oauth_authorization_path, method: :delete, class: 'simple_form' do
|
||||||
= hidden_field_tag :client_id, @pre_auth.client.uid
|
= hidden_field_tag :client_id, @pre_auth.client.uid
|
||||||
= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri
|
= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri
|
||||||
= hidden_field_tag :state, @pre_auth.state
|
= hidden_field_tag :state, @pre_auth.state
|
||||||
= hidden_field_tag :response_type, @pre_auth.response_type
|
= hidden_field_tag :response_type, @pre_auth.response_type
|
||||||
= hidden_field_tag :scope, @pre_auth.scope
|
= hidden_field_tag :scope, @pre_auth.scope
|
||||||
= button_tag t('doorkeeper.authorizations.buttons.deny'), type: :submit, class: 'negative'
|
= button_tag t('doorkeeper.authorizations.buttons.deny'), type: :submit, class: 'negative'
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
.flash-message
|
.form-container
|
||||||
%code= params[:code]
|
.flash-message
|
||||||
|
%code= params[:code]
|
||||||
|
13
app/views/remote_follow/new.html.haml
Normal file
13
app/views/remote_follow/new.html.haml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
.form-container
|
||||||
|
.follow-prompt
|
||||||
|
%h2= t('remote_follow.prompt')
|
||||||
|
|
||||||
|
= render partial: 'authorize_follow/card', locals: { account: @account }
|
||||||
|
|
||||||
|
= simple_form_for @remote_follow, as: :remote_follow, url: account_remote_follow_path(@account) do |f|
|
||||||
|
= render 'shared/error_messages', object: @remote_follow
|
||||||
|
|
||||||
|
= f.input :acct, placeholder: t('remote_follow.acct')
|
||||||
|
|
||||||
|
.actions
|
||||||
|
= f.button :button, t('remote_follow.proceed'), type: :submit
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
= f.simple_fields_for :notification_emails, current_user.settings(:notification_emails) do |ff|
|
= f.simple_fields_for :notification_emails, current_user.settings(:notification_emails) do |ff|
|
||||||
= ff.input :follow, as: :boolean, wrapper: :with_label
|
= ff.input :follow, as: :boolean, wrapper: :with_label
|
||||||
|
= ff.input :follow_request, as: :boolean, wrapper: :with_label
|
||||||
= ff.input :reblog, as: :boolean, wrapper: :with_label
|
= ff.input :reblog, as: :boolean, wrapper: :with_label
|
||||||
= ff.input :favourite, as: :boolean, wrapper: :with_label
|
= ff.input :favourite, as: :boolean, wrapper: :with_label
|
||||||
= ff.input :mention, as: :boolean, wrapper: :with_label
|
= ff.input :mention, as: :boolean, wrapper: :with_label
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
%ul.no-list
|
%ul.no-list
|
||||||
- if controller_name != 'profiles'
|
- if controller_name != 'profiles'
|
||||||
%li= link_to t('settings.edit_profile'), settings_profile_path
|
%li= link_to t('settings.edit_profile'), settings_profile_path
|
||||||
- if controller_name != 'follow_requests'
|
|
||||||
%li= link_to t('follow_requests.title'), follow_requests_path
|
|
||||||
- if controller_name != 'preferences'
|
- if controller_name != 'preferences'
|
||||||
%li= link_to t('settings.preferences'), settings_preferences_path
|
%li= link_to t('settings.preferences'), settings_preferences_path
|
||||||
- if controller_name != 'registrations'
|
- if controller_name != 'registrations'
|
||||||
|
@ -11,6 +11,7 @@ node(:links) do
|
|||||||
{ rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: TagManager.instance.url_for(@account) },
|
{ rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: TagManager.instance.url_for(@account) },
|
||||||
{ rel: 'http://schemas.google.com/g/2010#updates-from', type: 'application/atom+xml', href: account_url(@account, format: 'atom') },
|
{ rel: 'http://schemas.google.com/g/2010#updates-from', type: 'application/atom+xml', href: account_url(@account, format: 'atom') },
|
||||||
{ rel: 'salmon', href: api_salmon_url(@account.id) },
|
{ rel: 'salmon', href: api_salmon_url(@account.id) },
|
||||||
{ rel: 'magic-public-key', href: "data:application/magic-public-key,#{@magic_key}" }
|
{ rel: 'magic-public-key', href: "data:application/magic-public-key,#{@magic_key}" },
|
||||||
|
{ rel: 'http://ostatus.org/schema/1.0/subscribe', template: "#{authorize_follow_url}?acct={uri}" },
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
@ -6,5 +6,6 @@ Nokogiri::XML::Builder.new do |xml|
|
|||||||
xml.Link(rel: 'http://schemas.google.com/g/2010#updates-from', type: 'application/atom+xml', href: account_url(@account, format: 'atom'))
|
xml.Link(rel: 'http://schemas.google.com/g/2010#updates-from', type: 'application/atom+xml', href: account_url(@account, format: 'atom'))
|
||||||
xml.Link(rel: 'salmon', href: api_salmon_url(@account.id))
|
xml.Link(rel: 'salmon', href: api_salmon_url(@account.id))
|
||||||
xml.Link(rel: 'magic-public-key', href: "data:application/magic-public-key,#{@magic_key}")
|
xml.Link(rel: 'magic-public-key', href: "data:application/magic-public-key,#{@magic_key}")
|
||||||
|
xml.Link(rel: 'http://ostatus.org/schema/1.0/subscribe', template: "#{authorize_follow_url}?acct={uri}")
|
||||||
end
|
end
|
||||||
end.to_xml
|
end.to_xml
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
class ProcessingWorker
|
class ProcessingWorker
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
sidekiq_options backtrace: true
|
sidekiq_options backtrace: true
|
||||||
|
|
||||||
def perform(account_id, body)
|
def perform(account_id, body)
|
||||||
|
@ -7,9 +7,12 @@ class Pubsubhubbub::DistributionWorker
|
|||||||
|
|
||||||
def perform(stream_entry_id)
|
def perform(stream_entry_id)
|
||||||
stream_entry = StreamEntry.find(stream_entry_id)
|
stream_entry = StreamEntry.find(stream_entry_id)
|
||||||
account = stream_entry.account
|
|
||||||
renderer = AccountsController.renderer.new(method: 'get', http_host: Rails.configuration.x.local_domain, https: Rails.configuration.x.use_https)
|
return if stream_entry.hidden?
|
||||||
payload = renderer.render(:show, assigns: { account: account, entries: [stream_entry] }, formats: [:atom])
|
|
||||||
|
account = stream_entry.account
|
||||||
|
renderer = AccountsController.renderer.new(method: 'get', http_host: Rails.configuration.x.local_domain, https: Rails.configuration.x.use_https)
|
||||||
|
payload = renderer.render(:show, assigns: { account: account, entries: [stream_entry] }, formats: [:atom])
|
||||||
|
|
||||||
Subscription.where(account: account).active.select('id').find_each do |subscription|
|
Subscription.where(account: account).active.select('id').find_each do |subscription|
|
||||||
Pubsubhubbub::DeliveryWorker.perform_async(subscription.id, payload)
|
Pubsubhubbub::DeliveryWorker.perform_async(subscription.id, payload)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
class SalmonWorker
|
class SalmonWorker
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
sidekiq_options backtrace: true
|
sidekiq_options backtrace: true
|
||||||
|
|
||||||
def perform(account_id, body)
|
def perform(account_id, body)
|
||||||
|
@ -45,7 +45,7 @@ module Mastodon
|
|||||||
config.browserify_rails.commandline_options = '--transform [ babelify --presets [ es2015 react ] ] --extension=".jsx"'
|
config.browserify_rails.commandline_options = '--transform [ babelify --presets [ es2015 react ] ] --extension=".jsx"'
|
||||||
|
|
||||||
config.to_prepare do
|
config.to_prepare do
|
||||||
Doorkeeper::AuthorizationsController.layout 'auth'
|
Doorkeeper::AuthorizationsController.layout 'public'
|
||||||
end
|
end
|
||||||
|
|
||||||
config.action_dispatch.default_headers = {
|
config.action_dispatch.default_headers = {
|
||||||
|
@ -14,6 +14,7 @@ en:
|
|||||||
people_followed_by: People whom %{name} follows
|
people_followed_by: People whom %{name} follows
|
||||||
people_who_follow: People who follow %{name}
|
people_who_follow: People who follow %{name}
|
||||||
posts: Posts
|
posts: Posts
|
||||||
|
remote_follow: Remote follow
|
||||||
unfollow: Unfollow
|
unfollow: Unfollow
|
||||||
application_mailer:
|
application_mailer:
|
||||||
signature: Mastodon notifications from %{instance}
|
signature: Mastodon notifications from %{instance}
|
||||||
@ -26,6 +27,11 @@ en:
|
|||||||
resend_confirmation: Resend confirmation instructions
|
resend_confirmation: Resend confirmation instructions
|
||||||
reset_password: Reset password
|
reset_password: Reset password
|
||||||
set_new_password: Set new password
|
set_new_password: Set new password
|
||||||
|
authorize_follow:
|
||||||
|
error: Unfortunately, there was an error looking up the remote account
|
||||||
|
follow: Follow
|
||||||
|
prompt_html: 'You (<strong>%{self}</strong>) have requested to follow:'
|
||||||
|
title: Follow %{acct}
|
||||||
datetime:
|
datetime:
|
||||||
distance_in_words:
|
distance_in_words:
|
||||||
about_x_hours: "%{count}h"
|
about_x_hours: "%{count}h"
|
||||||
@ -40,10 +46,6 @@ en:
|
|||||||
x_minutes: "%{count}m"
|
x_minutes: "%{count}m"
|
||||||
x_months: "%{count}mo"
|
x_months: "%{count}mo"
|
||||||
x_seconds: "%{count}s"
|
x_seconds: "%{count}s"
|
||||||
follow_requests:
|
|
||||||
authorize: Authorize
|
|
||||||
reject: Reject
|
|
||||||
title: Follow requests
|
|
||||||
generic:
|
generic:
|
||||||
changes_saved_msg: Changes successfully saved!
|
changes_saved_msg: Changes successfully saved!
|
||||||
powered_by: powered by %{link}
|
powered_by: powered by %{link}
|
||||||
@ -58,6 +60,9 @@ en:
|
|||||||
follow:
|
follow:
|
||||||
body: "%{name} is now following you!"
|
body: "%{name} is now following you!"
|
||||||
subject: "%{name} is now following you"
|
subject: "%{name} is now following you"
|
||||||
|
follow_request:
|
||||||
|
body: "%{name} has requested to follow you"
|
||||||
|
subject: 'Pending follower: %{name}'
|
||||||
mention:
|
mention:
|
||||||
body: 'You were mentioned by %{name} in:'
|
body: 'You were mentioned by %{name} in:'
|
||||||
subject: You were mentioned by %{name}
|
subject: You were mentioned by %{name}
|
||||||
@ -67,6 +72,11 @@ en:
|
|||||||
pagination:
|
pagination:
|
||||||
next: Next
|
next: Next
|
||||||
prev: Prev
|
prev: Prev
|
||||||
|
remote_follow:
|
||||||
|
acct: Enter your username@domain you want to follow from
|
||||||
|
missing_resource: Could not find the required redirect URL for your account
|
||||||
|
proceed: Proceed to follow
|
||||||
|
prompt: 'You are going to follow:'
|
||||||
settings:
|
settings:
|
||||||
edit_profile: Edit profile
|
edit_profile: Edit profile
|
||||||
preferences: Preferences
|
preferences: Preferences
|
||||||
|
@ -25,6 +25,7 @@ en:
|
|||||||
notification_emails:
|
notification_emails:
|
||||||
favourite: Send e-mail when someone favourites your status
|
favourite: Send e-mail when someone favourites your status
|
||||||
follow: Send e-mail when someone follows you
|
follow: Send e-mail when someone follows you
|
||||||
|
follow_request: Send e-mail when someone requests to follow you
|
||||||
mention: Send e-mail when someone mentions you
|
mention: Send e-mail when someone mentions you
|
||||||
reblog: Send e-mail when someone reblogs your status
|
reblog: Send e-mail when someone reblogs your status
|
||||||
'no': 'No'
|
'no': 'No'
|
||||||
|
@ -31,6 +31,9 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get :remote_follow, to: 'remote_follow#new'
|
||||||
|
post :remote_follow, to: 'remote_follow#create'
|
||||||
|
|
||||||
member do
|
member do
|
||||||
get :followers
|
get :followers
|
||||||
get :following
|
get :following
|
||||||
@ -48,12 +51,9 @@ Rails.application.routes.draw do
|
|||||||
resources :media, only: [:show]
|
resources :media, only: [:show]
|
||||||
resources :tags, only: [:show]
|
resources :tags, only: [:show]
|
||||||
|
|
||||||
resources :follow_requests do
|
# Remote follow
|
||||||
member do
|
get :authorize_follow, to: 'authorize_follow#new'
|
||||||
post :authorize
|
post :authorize_follow, to: 'authorize_follow#create'
|
||||||
post :reject
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
resources :pubsubhubbub, only: [:index]
|
resources :pubsubhubbub, only: [:index]
|
||||||
@ -103,8 +103,17 @@ Rails.application.routes.draw do
|
|||||||
resources :follows, only: [:create]
|
resources :follows, only: [:create]
|
||||||
resources :media, only: [:create]
|
resources :media, only: [:create]
|
||||||
resources :apps, only: [:create]
|
resources :apps, only: [:create]
|
||||||
|
resources :blocks, only: [:index]
|
||||||
|
|
||||||
|
resources :follow_requests, only: [:index] do
|
||||||
|
member do
|
||||||
|
post :authorize
|
||||||
|
post :reject
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
resources :notifications, only: [:index]
|
resources :notifications, only: [:index]
|
||||||
|
resources :favourites, only: [:index]
|
||||||
|
|
||||||
resources :accounts, only: [:show] do
|
resources :accounts, only: [:show] do
|
||||||
collection do
|
collection do
|
||||||
|
@ -189,6 +189,7 @@ ActiveRecord::Schema.define(version: 20161222204147) do
|
|||||||
t.boolean "sensitive", default: false
|
t.boolean "sensitive", default: false
|
||||||
t.integer "visibility", default: 0, null: false
|
t.integer "visibility", default: 0, null: false
|
||||||
t.integer "in_reply_to_account_id"
|
t.integer "in_reply_to_account_id"
|
||||||
|
t.string "conversation_uri"
|
||||||
t.index ["account_id"], name: "index_statuses_on_account_id", using: :btree
|
t.index ["account_id"], name: "index_statuses_on_account_id", using: :btree
|
||||||
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id", using: :btree
|
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id", using: :btree
|
||||||
t.index ["reblog_of_id"], name: "index_statuses_on_reblog_of_id", using: :btree
|
t.index ["reblog_of_id"], name: "index_statuses_on_reblog_of_id", using: :btree
|
||||||
|
@ -7,7 +7,6 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
|
|||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:post, "https://pubsubhubbub.superfeedr.com/").to_return(:status => 200, :body => "", :headers => {})
|
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
19
spec/controllers/api/v1/blocks_controller_spec.rb
Normal file
19
spec/controllers/api/v1/blocks_controller_spec.rb
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Api::V1::BlocksController, type: :controller do
|
||||||
|
render_views
|
||||||
|
|
||||||
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
|
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'GET #index' do
|
||||||
|
it 'returns http success' do
|
||||||
|
get :index
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
19
spec/controllers/api/v1/favourites_controller_spec.rb
Normal file
19
spec/controllers/api/v1/favourites_controller_spec.rb
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Api::V1::FavouritesController, type: :controller do
|
||||||
|
render_views
|
||||||
|
|
||||||
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
|
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'GET #index' do
|
||||||
|
it 'returns http success' do
|
||||||
|
get :index
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
52
spec/controllers/api/v1/follow_requests_controller_spec.rb
Normal file
52
spec/controllers/api/v1/follow_requests_controller_spec.rb
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Api::V1::FollowRequestsController, type: :controller do
|
||||||
|
render_views
|
||||||
|
|
||||||
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice', locked: true)) }
|
||||||
|
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
||||||
|
let(:follower) { Fabricate(:account, username: 'bob') }
|
||||||
|
|
||||||
|
before do
|
||||||
|
FollowService.new.call(follower, user.account.acct)
|
||||||
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'GET #index' do
|
||||||
|
before do
|
||||||
|
get :index
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns http success' do
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'POST #authorize' do
|
||||||
|
before do
|
||||||
|
post :authorize, params: { id: follower.id }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns http success' do
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'allows follower to follow' do
|
||||||
|
expect(follower.following?(user.account)).to be true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'POST #reject' do
|
||||||
|
before do
|
||||||
|
post :reject, params: { id: follower.id }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns http success' do
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'removes follow request' do
|
||||||
|
expect(FollowRequest.where(target_account: user.account, account: follower).count).to eq 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -7,7 +7,6 @@ RSpec.describe Api::V1::StatusesController, type: :controller do
|
|||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:post, "https://pubsubhubbub.superfeedr.com/").to_return(:status => 200, :body => "", :headers => {})
|
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ RSpec.describe Api::V1::TimelinesController, type: :controller do
|
|||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:post, "https://pubsubhubbub.superfeedr.com/").to_return(:status => 200, :body => "", :headers => {})
|
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
6
spec/controllers/authorize_follow_controller_spec.rb
Normal file
6
spec/controllers/authorize_follow_controller_spec.rb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe AuthorizeFollowController, type: :controller do
|
||||||
|
describe 'GET #new'
|
||||||
|
describe 'POST #create'
|
||||||
|
end
|
@ -1,16 +0,0 @@
|
|||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe FollowRequestsController, type: :controller do
|
|
||||||
render_views
|
|
||||||
|
|
||||||
before do
|
|
||||||
sign_in Fabricate(:user), scope: :user
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #index' do
|
|
||||||
it 'returns http success' do
|
|
||||||
get :index
|
|
||||||
expect(response).to have_http_status(:success)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user