Skip to content

Commit

Permalink
Merge branch 'kb_lts' into kb_development
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Sep 21, 2023
2 parents f3c9ee0 + 2667e47 commit 5177e8d
Show file tree
Hide file tree
Showing 36 changed files with 337 additions and 98 deletions.
56 changes: 4 additions & 52 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,58 +33,10 @@ Sudachiインストール終了後、追加で`/etc/elasticsearch/sudachi/config
}
```

## 新規インストールの場合
## インストール手順

1. 本家Mastodonとセットアップ手順はほとんど一緒です。kmyblueが独自に必須ソフトウェアを追加したわけではありません。ただしkmyblueはMastodonの開発中コードを取り込んでいるので、Rubyなどのバージョンアップ作業が必要になる場合があります。Mastodon公式のセットアップ手順を盲信せず、画面の指示に従ってインストールを進めてください。CloudFlareを組み合わせてセットアップしたとき、サーバーに接続すると400が出るなどのトラブルが出ることがありますが、大抵はMastodon本家由来のトラブルだと思われるので基本サポートはしません
2. ただひとつ差異があります。Gitリポジトリはこのkmyblueに向けてください。`kb_development`ブランチの最新コミットではなく、`kb`で始まる最新のタグを取り込むことを強くおすすめします
[Wiki](https://github.com/kmycode/mastodon/wiki/Installation)を参照してください

## 本家Mastodonからのマイグレーションの場合
## アップデート手順

kmyblueから本家Mastodonに戻りたい場合もあると思いますので、**必ずデータベースのバックアップをとってください**

1. kmyblueのリリースノートに、kmyblueバージョンに対応した本家Mastodonのバージョンが記載されています。それを参照して、まず本家Mastodonをそのバージョンまでバージョンアップしてください
2. Gitのリモートにkmyblueを追加して、そのままチェックアウトしてください
3. データベースのマイグレーションなどを行ってください

```
sudo systemctl stop mastodon-*
bundle install
yarn install
RAILS_ENV=production bin/rails db:migrate
RAILS_ENV=production bin/rails assets:clobber
RAILS_ENV=production bin/rails assets:precompile
# ElasticSearchを使用する場合
RAILS_ENV=production bin/tootctl search deploy
RAILS_ENV=production bin/tootctl cache clear
sudo systemctl start mastodon-web mastodon-streaming mastodon-sidekiq
```

## kmyblueのバージョンをアップデートする

リリースノートを参照して、自分に必要な作業を特定してください。面倒な場合は毎回全部実行してしまっても問題ありません。(プリコンパイルが失敗する可能性があるのでご注意ください)

```
# Rubyパッケージアップデート
bundle intall
# JSパッケージアップデート
yarn install
# DBマイグレーション
RAILS_ENV=production bin/rails db:migrate
# プリコンパイル
# うまくいかない場合(エラーは出ないのにWeb表示が崩れる)はclobberしてからprecompile
# それでもうまくいかない場合はsudo systemctl stop mastodon-webしてから試す
# それでもうまくいかない場合はサーバーOSを再起動してから試す
RAILS_ENV=production bin/rails assets:clobber # プリコンパイルがうまくいかない場合
RAILS_ENV=production bin/rails assets:precompile
# サーバー再起動
sudo systemctl restart mastodon-web
sudo systemctl restart mastodon-streaming
sudo systemctl restart mastodon-sidekiq
```
[Wiki](https://github.com/kmycode/mastodon/wiki/Updation)を参照してください
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def default_accounts

def paginated_emoji_reactions
EmojiReaction.paginate_by_max_id(
limit_param(1000), # limit_param(DEFAULT_ACCOUNTS_LIMIT),
limit_param(DEFAULT_ACCOUNTS_LIMIT),
params[:max_id],
params[:since_id]
)
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/mastodon/actions/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -785,11 +785,12 @@ export function insertExpirationCompose(position, data) {
};
}

export function insertReferenceCompose(position, url) {
export function insertReferenceCompose(position, url, attributeType) {
return {
type: COMPOSE_REFERENCE_INSERT,
position,
url,
attributeType,
};
}

Expand Down
52 changes: 50 additions & 2 deletions app/javascript/mastodon/actions/interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export const EMOJI_REACTIONS_FETCH_REQUEST = 'EMOJI_REACTIONS_FETCH_REQUEST';
export const EMOJI_REACTIONS_FETCH_SUCCESS = 'EMOJI_REACTIONS_FETCH_SUCCESS';
export const EMOJI_REACTIONS_FETCH_FAIL = 'EMOJI_REACTIONS_FETCH_FAIL';

export const EMOJI_REACTIONS_EXPAND_REQUEST = 'EMOJI_REACTIONS_EXPAND_REQUEST';
export const EMOJI_REACTIONS_EXPAND_SUCCESS = 'EMOJI_REACTIONS_EXPAND_SUCCESS';
export const EMOJI_REACTIONS_EXPAND_FAIL = 'EMOJI_REACTIONS_EXPAND_FAIL';

export const PIN_REQUEST = 'PIN_REQUEST';
export const PIN_SUCCESS = 'PIN_SUCCESS';
export const PIN_FAIL = 'PIN_FAIL';
Expand Down Expand Up @@ -547,8 +551,9 @@ export function fetchEmojiReactions(id) {
dispatch(fetchEmojiReactionsRequest(id));

api(getState).get(`/api/v1/statuses/${id}/emoji_reactioned_by`).then(response => {
const next = getLinks(response).refs.find(link => link.rel === 'next');
dispatch(importFetchedAccounts(response.data.map((er) => er.account)));
dispatch(fetchEmojiReactionsSuccess(id, response.data));
dispatch(fetchEmojiReactionsSuccess(id, response.data, next ? next.uri : null));
}).catch(error => {
dispatch(fetchEmojiReactionsFail(id, error));
});
Expand All @@ -562,11 +567,12 @@ export function fetchEmojiReactionsRequest(id) {
};
}

export function fetchEmojiReactionsSuccess(id, accounts) {
export function fetchEmojiReactionsSuccess(id, accounts, next) {
return {
type: EMOJI_REACTIONS_FETCH_SUCCESS,
id,
accounts,
next,
};
}

Expand All @@ -577,6 +583,48 @@ export function fetchEmojiReactionsFail(id, error) {
};
}

export function expandEmojiReactions(id) {
return (dispatch, getState) => {
const url = getState().getIn(['user_lists', 'emoji_reactioned_by', id, 'next']);
if (url === null) {
return;
}

dispatch(expandEmojiReactionsRequest(id));

api(getState).get(url).then(response => {
const next = getLinks(response).refs.find(link => link.rel === 'next');

dispatch(importFetchedAccounts(response.data.map((er) => er.account)));
dispatch(expandEmojiReactionsSuccess(id, response.data, next ? next.uri : null));
}).catch(error => dispatch(expandEmojiReactionsFail(id, error)));
};
}

export function expandEmojiReactionsRequest(id) {
return {
type: EMOJI_REACTIONS_EXPAND_REQUEST,
id,
};
}

export function expandEmojiReactionsSuccess(id, accounts, next) {
return {
type: EMOJI_REACTIONS_EXPAND_SUCCESS,
id,
accounts,
next,
};
}

export function expandEmojiReactionsFail(id, error) {
return {
type: EMOJI_REACTIONS_EXPAND_FAIL,
id,
error,
};
}

export function fetchStatusReferences(id) {
return (dispatch, getState) => {
dispatch(fetchStatusReferencesRequest(id));
Expand Down
8 changes: 8 additions & 0 deletions app/javascript/mastodon/components/status_action_bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const messages = defineMessages({
admin_domain: { id: 'status.admin_domain', defaultMessage: 'Open moderation interface for {domain}' },
copy: { id: 'status.copy', defaultMessage: 'Copy link to post' },
reference: { id: 'status.reference', defaultMessage: 'Add reference' },
quote: { id: 'status.quote', defaultMessage: 'Add ref (quote in other servers)' },
hide: { id: 'status.hide', defaultMessage: 'Hide post' },
blockDomain: { id: 'account.block_domain', defaultMessage: 'Block domain {domain}' },
unblockDomain: { id: 'account.unblock_domain', defaultMessage: 'Unblock domain {domain}' },
Expand Down Expand Up @@ -97,6 +98,8 @@ class StatusActionBar extends ImmutablePureComponent {
onBookmarkCategoryAdder: PropTypes.func,
onFilter: PropTypes.func,
onAddFilter: PropTypes.func,
onReference: PropTypes.func,
onQuote: PropTypes.func,
onInteractionModal: PropTypes.func,
withDismiss: PropTypes.bool,
withCounters: PropTypes.bool,
Expand Down Expand Up @@ -271,6 +274,10 @@ class StatusActionBar extends ImmutablePureComponent {
this.props.onReference(this.props.status);
};

handleQuote = () => {
this.props.onQuote(this.props.status);
};

handleHideClick = () => {
this.props.onFilter();
};
Expand Down Expand Up @@ -316,6 +323,7 @@ class StatusActionBar extends ImmutablePureComponent {

if (publicStatus) {
menu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference });
menu.push({ text: intl.formatMessage(messages.quote), action: this.handleQuote });
}

menu.push({ text: intl.formatMessage(status.get('bookmarked') ? messages.removeBookmark : messages.bookmark), action: this.handleBookmarkClickOriginal });
Expand Down
6 changes: 5 additions & 1 deletion app/javascript/mastodon/containers/status_container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
},

onReference (status) {
dispatch(insertReferenceCompose(0, status.get('url')));
dispatch(insertReferenceCompose(0, status.get('url'), 'BT'));
},

onQuote (status) {
dispatch(insertReferenceCompose(0, status.get('url'), 'QT'));
},

onTranslate (status) {
Expand Down
29 changes: 18 additions & 11 deletions app/javascript/mastodon/features/emoji_reactions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { connect } from 'react-redux';

import { fetchEmojiReactions } from 'mastodon/actions/interactions';
import { debounce } from 'lodash';

import { fetchEmojiReactions, expandEmojiReactions } from 'mastodon/actions/interactions';
import ColumnHeader from 'mastodon/components/column_header';
import { Icon } from 'mastodon/components/icon';
import ScrollableList from 'mastodon/components/scrollable_list';
Expand All @@ -25,7 +27,9 @@ const messages = defineMessages({

const mapStateToProps = (state, props) => {
return {
accountIds: state.getIn(['user_lists', 'emoji_reactioned_by', props.params.statusId]),
accountIds: state.getIn(['user_lists', 'emoji_reactioned_by', props.params.statusId, 'items']),
hasMore: !!state.getIn(['user_lists', 'emoji_reactioned_by', props.params.statusId, 'next']),
isLoading: state.getIn(['user_lists', 'emoji_reactioned_by', props.params.statusId, 'isLoading'], true),
};
};

Expand All @@ -35,6 +39,8 @@ class EmojiReactions extends ImmutablePureComponent {
params: PropTypes.object.isRequired,
dispatch: PropTypes.func.isRequired,
accountIds: ImmutablePropTypes.list,
hasMore: PropTypes.bool,
isLoading: PropTypes.bool,
multiColumn: PropTypes.bool,
intl: PropTypes.object.isRequired,
};
Expand All @@ -45,18 +51,16 @@ class EmojiReactions extends ImmutablePureComponent {
}
}

componentWillReceiveProps (nextProps) {
if (nextProps.params.statusId !== this.props.params.statusId && nextProps.params.statusId) {
this.props.dispatch(fetchEmojiReactions(nextProps.params.statusId));
}
}

handleRefresh = () => {
this.props.dispatch(fetchEmojiReactions(this.props.params.statusId));
};

handleLoadMore = debounce(() => {
this.props.dispatch(expandEmojiReactions(this.props.params.statusId));
}, 300, { leading: true });

render () {
const { intl, accountIds, multiColumn } = this.props;
const { intl, accountIds, hasMore, isLoading, multiColumn } = this.props;

if (!accountIds) {
return (
Expand All @@ -68,7 +72,7 @@ class EmojiReactions extends ImmutablePureComponent {

let groups = {};
for (const emoji_reaction of accountIds) {
const key = emoji_reaction.account.id;
const key = emoji_reaction.account_id;
const value = emoji_reaction;
if (!groups[key]) groups[key] = [value];
else groups[key].push(value);
Expand All @@ -82,12 +86,15 @@ class EmojiReactions extends ImmutablePureComponent {
showBackButton
multiColumn={multiColumn}
extraButton={(
<button type='button' className='column-header__button' title={intl.formatMessage(messages.refresh)} aria-label={intl.formatMessage(messages.refresh)} onClick={this.handleRefresh}><Icon id='refresh' /></button>
<button type='button' className='column-header__button' title={intl.formatMessage(messages.refresh)} aria-label={intl.formatMessage(messages.refresh)} onClick={this.handleLoadMore}><Icon id='refresh' /></button>
)}
/>

<ScrollableList
scrollKey='emoji_reactions'
onLoadMore={this.handleLoadMore}
hasMore={hasMore}
isLoading={isLoading}
emptyMessage={emptyMessage}
bindToDocument={!multiColumn}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const messages = defineMessages({
admin_domain: { id: 'status.admin_domain', defaultMessage: 'Open moderation interface for {domain}' },
copy: { id: 'status.copy', defaultMessage: 'Copy link to post' },
reference: { id: 'status.reference', defaultMessage: 'Add reference' },
quote: { id: 'status.quote', defaultMessage: 'Add ref (quote in other servers)' },
blockDomain: { id: 'account.block_domain', defaultMessage: 'Block domain {domain}' },
unblockDomain: { id: 'account.unblock_domain', defaultMessage: 'Unblock domain {domain}' },
unmute: { id: 'account.unmute', defaultMessage: 'Unmute @{name}' },
Expand Down Expand Up @@ -74,6 +75,7 @@ class ActionBar extends PureComponent {
onFavourite: PropTypes.func.isRequired,
onEmojiReact: PropTypes.func.isRequired,
onReference: PropTypes.func.isRequired,
onQuote: PropTypes.func.isRequired,
onBookmark: PropTypes.func.isRequired,
onBookmarkCategoryAdder: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired,
Expand Down Expand Up @@ -208,6 +210,10 @@ class ActionBar extends PureComponent {
this.props.onReference(this.props.status);
};

handleQuote = () => {
this.props.onQuote(this.props.status);
};

handleEmojiPick = (data) => {
this.props.onEmojiReact(this.props.status, data);
};
Expand Down Expand Up @@ -248,6 +254,7 @@ class ActionBar extends PureComponent {

if (publicStatus) {
menu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference });
menu.push({ text: intl.formatMessage(messages.quote), action: this.handleQuote });
}
menu.push({ text: intl.formatMessage(messages.bookmark_category), action: this.handleBookmarkCategoryAdderClick });

Expand Down
7 changes: 6 additions & 1 deletion app/javascript/mastodon/features/status/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,11 @@ class Status extends ImmutablePureComponent {
};

handleReference = (status) => {
this.props.dispatch(insertReferenceCompose(0, status.get('url')));
this.props.dispatch(insertReferenceCompose(0, status.get('url'), 'BT'));
};

handleQuote = (status) => {
this.props.dispatch(insertReferenceCompose(0, status.get('url'), 'QT'));
};

handleBookmarkClick = (status) => {
Expand Down Expand Up @@ -750,6 +754,7 @@ class Status extends ImmutablePureComponent {
onReblog={this.handleReblogClick}
onReblogForceModal={this.handleReblogForceModalClick}
onReference={this.handleReference}
onQuote={this.handleQuote}
onBookmark={this.handleBookmarkClick}
onBookmarkCategoryAdder={this.handleBookmarkCategoryAdderClick}
onDelete={this.handleDeleteClick}
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@
"status.open": "Expand this post",
"status.pin": "Pin on profile",
"status.pinned": "Pinned post",
"status.quote": "Ref (quote in other servers)",
"status.read_more": "Read more",
"status.reblog": "Boost",
"status.reblog_private": "Boost with original visibility",
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@
"status.open": "詳細を表示",
"status.pin": "プロフィールに固定表示",
"status.pinned": "固定された投稿",
"status.quote": "参照 (他サーバーで引用扱い)",
"status.read_more": "もっと見る",
"status.reblog": "ブースト",
"status.reblog_private": "ブースト",
Expand Down
Loading

0 comments on commit 5177e8d

Please sign in to comment.