forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 9cb3fb9d980e3ee066083076f508c5ab1447176a Author: noellabo <noel.yoshiba@gmail.com> Date: Sat Sep 5 07:15:19 2020 +0900 Move the link to the mention list to the menu commit b32dd87b43f4e09b8e2c437f1fb5d3ebd6221215 Author: noellabo <noel.yoshiba@gmail.com> Date: Sat Sep 5 00:56:12 2020 +0900 Change limited visibility icon commit 8db0d024119d1c2cef8de849f2501496a166a2dd Author: noellabo <noel.yoshiba@gmail.com> Date: Tue Sep 1 01:42:13 2020 +0900 Fix to disallow getting the list of mentions in limited replies commit 490a9d65a59a3dd0d86e81f6780e879dc4313dff Author: noellabo <noel.yoshiba@gmail.com> Date: Fri Jul 24 11:36:24 2020 +0900 Add column to list mentioned accounts of limited status commit 62a423ac2729c16f26fafe111f257bc373218df2 Author: noellabo <noel.yoshiba@gmail.com> Date: Thu Jul 23 13:30:17 2020 +0900 Fix visibility compatibility more commit a5cfa54b259054f41e89037f299fa928a2361818 Author: noellabo <noel.yoshiba@gmail.com> Date: Mon Jul 20 05:39:49 2020 +0900 Fix visibility compatibility commit 7900ca5650c77565b86ddc594a221dfa3b5321b4 Author: noellabo <noel.yoshiba@gmail.com> Date: Mon Jul 20 02:01:27 2020 +0900 Add limited visibility icon to status
- Loading branch information
Showing
24 changed files
with
291 additions
and
17 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
app/controllers/api/v1/statuses/mentioned_by_accounts_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::V1::Statuses::MentionedByAccountsController < Api::BaseController | ||
include Authorization | ||
|
||
before_action -> { doorkeeper_authorize! :read, :'read:accounts' } | ||
before_action :set_status | ||
after_action :insert_pagination_headers | ||
|
||
def index | ||
@accounts = load_accounts | ||
render json: @accounts, each_serializer: REST::AccountSerializer | ||
end | ||
|
||
private | ||
|
||
def load_accounts | ||
scope = default_accounts | ||
scope.merge(paginated_mentions).to_a | ||
end | ||
|
||
def default_accounts | ||
Account | ||
.includes(:mentions, :account_stat) | ||
.references(:mentions) | ||
.where(mentions: { status_id: @status.id, silent: true }) | ||
end | ||
|
||
def paginated_mentions | ||
Mention.paginate_by_max_id( | ||
limit_param(DEFAULT_ACCOUNTS_LIMIT), | ||
params[:max_id], | ||
params[:since_id] | ||
) | ||
end | ||
|
||
def insert_pagination_headers | ||
set_pagination_headers(next_path, prev_path) | ||
end | ||
|
||
def next_path | ||
api_v1_status_mentioned_by_index_url pagination_params(max_id: pagination_max_id) if records_continue? | ||
end | ||
|
||
def prev_path | ||
api_v1_status_mentioned_by_index_url pagination_params(since_id: pagination_since_id) unless @accounts.empty? | ||
end | ||
|
||
def pagination_max_id | ||
@accounts.last.mentions.last.id | ||
end | ||
|
||
def pagination_since_id | ||
@accounts.first.mentions.first.id | ||
end | ||
|
||
def records_continue? | ||
@accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT) | ||
end | ||
|
||
def set_status | ||
@status = Status.find(params[:status_id]) | ||
authorize @status, :show_mentions? | ||
rescue Mastodon::NotPermittedError | ||
not_found | ||
end | ||
|
||
def pagination_params(core_params) | ||
params.slice(:limit).permit(:limit).merge(core_params) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import ImmutablePureComponent from 'react-immutable-pure-component'; | ||
import PropTypes from 'prop-types'; | ||
import ImmutablePropTypes from 'react-immutable-proptypes'; | ||
import LoadingIndicator from '../../components/loading_indicator'; | ||
import { fetchMentions } from '../../actions/interactions'; | ||
import { injectIntl, FormattedMessage } from 'react-intl'; | ||
import AccountContainer from '../../containers/account_container'; | ||
import Column from '../ui/components/column'; | ||
import ScrollableList from '../../components/scrollable_list'; | ||
import ColumnHeader from '../../components/column_header'; | ||
|
||
const mapStateToProps = (state, props) => ({ | ||
accountIds: state.getIn(['user_lists', 'mentioned_by', props.params.statusId]), | ||
}); | ||
|
||
export default @connect(mapStateToProps) | ||
@injectIntl | ||
class Mentions extends ImmutablePureComponent { | ||
|
||
static propTypes = { | ||
params: PropTypes.object.isRequired, | ||
dispatch: PropTypes.func.isRequired, | ||
shouldUpdateScroll: PropTypes.func, | ||
accountIds: ImmutablePropTypes.list, | ||
multiColumn: PropTypes.bool, | ||
intl: PropTypes.object.isRequired, | ||
}; | ||
|
||
componentWillMount () { | ||
if (!this.props.accountIds) { | ||
this.props.dispatch(fetchMentions(this.props.params.statusId)); | ||
} | ||
} | ||
|
||
componentWillReceiveProps (nextProps) { | ||
if (nextProps.params.statusId !== this.props.params.statusId && nextProps.params.statusId) { | ||
this.props.dispatch(fetchMentions(nextProps.params.statusId)); | ||
} | ||
} | ||
|
||
render () { | ||
const { shouldUpdateScroll, accountIds, multiColumn } = this.props; | ||
|
||
if (!accountIds) { | ||
return ( | ||
<Column> | ||
<LoadingIndicator /> | ||
</Column> | ||
); | ||
} | ||
|
||
const emptyMessage = <FormattedMessage id='empty_column.mentions' defaultMessage='No one has mentioned this toot.' />; | ||
|
||
return ( | ||
<Column bindToDocument={!multiColumn}> | ||
<ColumnHeader | ||
showBackButton | ||
multiColumn={multiColumn} | ||
/> | ||
|
||
<ScrollableList | ||
scrollKey='mentions' | ||
shouldUpdateScroll={shouldUpdateScroll} | ||
emptyMessage={emptyMessage} | ||
bindToDocument={!multiColumn} | ||
> | ||
{accountIds.map(id => | ||
<AccountContainer key={id} id={id} withNote={false} />, | ||
)} | ||
</ScrollableList> | ||
</Column> | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.