forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into verup-to-4.2.9
- Loading branch information
Showing
38 changed files
with
1,594 additions
and
17 deletions.
There are no files selected for viewing
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
71 changes: 71 additions & 0 deletions
71
app/controllers/settings/request_custom_emojis_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 Settings::RequestCustomEmojisController < Settings::BaseController | ||
include Authorization | ||
|
||
def index | ||
@is_admin = authorize? | ||
@custom_emojis = RequestCustomEmoji.order(:state, :shortcode).page(params[:page]) | ||
@form = Form::RequestCustomEmojiBatch.new | ||
end | ||
|
||
def new | ||
@custom_emoji = RequestCustomEmoji.new | ||
end | ||
|
||
def create | ||
@custom_emoji = RequestCustomEmoji.new(resource_params) | ||
@custom_emoji.account_id = current_account.id | ||
if CustomEmoji.find_by(shortcode: @custom_emoji.shortcode, domain: nil) | ||
@custom_emoji.errors.add(:shortcode, I18n.t('settings.request_custom_emoji.errors.already_exists')) | ||
render :new | ||
return | ||
end | ||
|
||
if @custom_emoji.save | ||
redirect_to settings_request_custom_emojis_path, notice: I18n.t('settings.request_custom_emoji.created_msg') | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def batch | ||
@form = Form::RequestCustomEmojiBatch.new(form_custom_emoji_batch_params.merge(current_account: current_account, action: action_from_button)) | ||
@form.save | ||
rescue ActionController::ParameterMissing | ||
flash[:alert] = I18n.t('admin.accounts.no_account_selected') | ||
rescue Mastodon::NotPermittedError | ||
flash[:alert] = I18n.t('admin.custom_emojis.not_permitted') | ||
ensure | ||
redirect_to settings_request_custom_emojis_path | ||
end | ||
|
||
private | ||
|
||
def resource_params | ||
params.require(:request_custom_emoji).permit(:shortcode, :image) | ||
end | ||
|
||
def form_custom_emoji_batch_params | ||
params.require(:form_request_custom_emoji_batch).permit(:action, request_custom_emoji_ids: []) | ||
Check failure on line 50 in app/controllers/settings/request_custom_emojis_controller.rb GitHub Actions / lint
|
||
end | ||
|
||
def action_from_button | ||
if params[:approve] | ||
'approve' | ||
elsif params[:reject] | ||
'reject' | ||
elsif params[:delete] | ||
'delete' | ||
end | ||
end | ||
|
||
def authorize? | ||
begin | ||
authorize(:custom_emoji, :index?) | ||
rescue Mastodon::NotPermittedError | ||
return false | ||
end | ||
return true | ||
Check failure on line 69 in app/controllers/settings/request_custom_emojis_controller.rb GitHub Actions / lint
|
||
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
29 changes: 29 additions & 0 deletions
29
app/javascript/mastodon/features/compose/components/literacy_caution.jsx
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,29 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
Check failure on line 2 in app/javascript/mastodon/features/compose/components/literacy_caution.jsx GitHub Actions / lint
|
||
import ImmutablePureComponent from 'react-immutable-pure-component'; | ||
import { defineMessages, injectIntl } from 'react-intl'; | ||
|
||
const messages = defineMessages({ | ||
cautionMessage: { id: 'custom.caution_message', defaultMessage: 'CAUTION' }, | ||
}); | ||
|
||
class LiteracyCaution extends ImmutablePureComponent { | ||
static propTypes = { | ||
intl: PropTypes.object.isRequired, | ||
} | ||
|
||
render() { | ||
const { intl } = this.props; | ||
return ( | ||
<div className="literacy-caution"> | ||
<a href="https://onlineguide.isc.kyutech.ac.jp/guide2020/index.php/home/2020-02-04-02-50-29/2020-03-03-01-40-44"> | ||
<p> | ||
{ intl.formatMessage(messages.cautionMessage) } | ||
</p> | ||
</a> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default injectIntl(LiteracyCaution); |
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
Oops, something went wrong.