Progress
Albums almost done, group, chat moderation, photo, video page updates
This commit is contained in:
@@ -7,12 +7,57 @@ module Admin
|
||||
PER_PAGE = 100
|
||||
|
||||
def index
|
||||
authorize :account, :index?
|
||||
@followers = ChatMessage.where(from_account: @account).page(params[:page]).per(PER_PAGE)
|
||||
authorize :chat_message, :index?
|
||||
|
||||
@chat_messages = ChatMessage.where(from_account: @account).page(params[:page]).per(PER_PAGE)
|
||||
@form = Form::ChatMessageBatch.new
|
||||
end
|
||||
|
||||
def show
|
||||
authorize :chat_message, :index?
|
||||
|
||||
@chat_messages = @account.chat_messages.where(id: params[:id])
|
||||
authorize @chat_messages.first, :show?
|
||||
|
||||
@form = Form::ChatMessageBatch.new
|
||||
end
|
||||
|
||||
def create
|
||||
authorize :chat_message, :update?
|
||||
|
||||
@form = Form::ChatMessageBatch.new(form_chat_message_batch_params.merge(current_account: current_account, action: action_from_button))
|
||||
flash[:alert] = I18n.t('admin.statuses.failed_to_execute') unless @form.save
|
||||
|
||||
redirect_to admin_account_chat_messages_path(@account.id, current_params)
|
||||
rescue ActionController::ParameterMissing
|
||||
flash[:alert] = I18n.t('admin.statuses.no_status_selected')
|
||||
|
||||
redirect_to admin_account_chat_messages_path(@account.id, current_params)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def form_chat_message_batch_params
|
||||
params.require(:form_chat_message_batch).permit(:action, chat_message_ids: [])
|
||||
end
|
||||
|
||||
def set_account
|
||||
@account = Account.find(params[:account_id])
|
||||
end
|
||||
|
||||
def current_params
|
||||
page = (params[:page] || 1).to_i
|
||||
|
||||
{
|
||||
media: params[:media],
|
||||
page: page > 1 && page,
|
||||
}.select { |_, value| value.present? }
|
||||
end
|
||||
|
||||
def action_from_button
|
||||
if params[:delete]
|
||||
'delete'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,7 +23,6 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController
|
||||
end
|
||||
|
||||
def hide_results?
|
||||
# : todo : where tf is this?
|
||||
(@account.user_hides_network? && current_account.id != @account.id) || (current_account && @account.blocking?(current_account))
|
||||
end
|
||||
|
||||
|
||||
@@ -19,13 +19,6 @@ class Api::V1::ChatConversationController < Api::BaseController
|
||||
end
|
||||
|
||||
def create
|
||||
# : todo :
|
||||
# check if already created
|
||||
# check if blocked
|
||||
# check if chat blocked
|
||||
# check if allow anyone to message then create with approved:true
|
||||
# unique account id, participants
|
||||
|
||||
chat_conversation_account = find_or_create_conversation
|
||||
render json: chat_conversation_account, each_serializer: REST::ChatConversationAccountSerializer
|
||||
end
|
||||
@@ -80,26 +73,8 @@ class Api::V1::ChatConversationController < Api::BaseController
|
||||
|
||||
def find_or_create_conversation
|
||||
chat = ChatConversationAccount.find_by(account: current_account, participant_account_ids: [@account.id.to_s])
|
||||
|
||||
return chat unless chat.nil?
|
||||
|
||||
chat_conversation = ChatConversation.create
|
||||
|
||||
my_chat = ChatConversationAccount.create!(
|
||||
account: current_account,
|
||||
participant_account_ids: [@account.id.to_s],
|
||||
chat_conversation: chat_conversation,
|
||||
is_approved: true
|
||||
)
|
||||
|
||||
# : todo : if multiple ids
|
||||
their_chat = ChatConversationAccount.create!(
|
||||
account: @account,
|
||||
participant_account_ids: [current_account.id.to_s],
|
||||
chat_conversation: chat_conversation,
|
||||
is_approved: false # default as request
|
||||
)
|
||||
|
||||
my_chat = CreateChatConversationService.new.call(current_account, [@account])
|
||||
return my_chat
|
||||
end
|
||||
|
||||
|
||||
@@ -34,10 +34,6 @@ class Api::V1::Groups::RemovedAccountsController < Api::BaseController
|
||||
render_empty_success
|
||||
end
|
||||
|
||||
def search
|
||||
# : todo :
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_group
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
class Api::V1::StatusesController < Api::BaseController
|
||||
include Authorization
|
||||
|
||||
# : todo : disable all oauth everything
|
||||
before_action -> { authorize_if_got_token! :read, :'read:statuses' }, except: [:create, :update, :destroy]
|
||||
before_action -> { doorkeeper_authorize! :write, :'write:statuses' }, only: [:create, :update, :destroy]
|
||||
before_action :require_user!, except: [:show, :comments, :context, :card]
|
||||
|
||||
@@ -21,9 +21,6 @@ class Settings::GroupCategoriesController < Admin::BaseController
|
||||
end
|
||||
|
||||
def destroy
|
||||
# : todo :
|
||||
# don't destroy if any groups have this category
|
||||
|
||||
@category.destroy!
|
||||
log_action :destroy, @category
|
||||
flash[:notice] = I18n.t('promotions.destroyed_msg')
|
||||
|
||||
@@ -26,6 +26,10 @@ class Settings::ProfilesController < Settings::BaseController
|
||||
else
|
||||
# : todo :
|
||||
# only allowed to change username once per day
|
||||
if params[:account][:username] && @account.username != params[:account][:username]
|
||||
Redis.current.set("username_change:#{account.id}", true)
|
||||
Redis.current.expire("username_change:#{account.id}", 24.huors.seconds)
|
||||
end
|
||||
|
||||
if UpdateAccountService.new.call(@account, account_params)
|
||||
redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg')
|
||||
|
||||
Reference in New Issue
Block a user