2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-09-12 17:46:43 -04:00
|
|
|
class ComposerMessagesController < ApplicationController
|
2018-01-31 23:17:59 -05:00
|
|
|
requires_login
|
2013-09-12 17:46:43 -04:00
|
|
|
|
|
|
|
def index
|
2016-06-06 16:58:35 -04:00
|
|
|
finder =
|
|
|
|
ComposerMessagesFinder.new(current_user, params.slice(:composer_action, :topic_id, :post_id))
|
2016-06-06 13:52:24 -04:00
|
|
|
json = { composer_messages: [finder.find].compact }
|
2013-09-12 17:46:43 -04:00
|
|
|
|
2016-06-08 17:20:32 -04:00
|
|
|
if params[:topic_id].present?
|
2016-06-06 16:58:35 -04:00
|
|
|
topic = Topic.where(id: params[:topic_id]).first
|
|
|
|
if guardian.can_see?(topic)
|
|
|
|
json[:extras] = { duplicate_lookup: TopicLink.duplicate_lookup(topic) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-06 13:52:24 -04:00
|
|
|
render_json_dump(json, rest_serializer: true)
|
|
|
|
end
|
2022-09-27 12:36:40 -04:00
|
|
|
|
|
|
|
def user_not_seen_in_a_while
|
|
|
|
usernames = params.require(:usernames)
|
|
|
|
users = ComposerMessagesFinder.user_not_seen_in_a_while(usernames)
|
|
|
|
user_count = users.count
|
|
|
|
warning_message = nil
|
|
|
|
|
|
|
|
if user_count > 0
|
|
|
|
message_locale =
|
|
|
|
if user_count == 1
|
|
|
|
"education.user_not_seen_in_a_while.single"
|
|
|
|
else
|
|
|
|
"education.user_not_seen_in_a_while.multiple"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
json = {
|
|
|
|
user_count: user_count,
|
|
|
|
usernames: users,
|
|
|
|
time_ago:
|
|
|
|
FreedomPatches::Rails4.time_ago_in_words(
|
|
|
|
SiteSetting.pm_warn_user_last_seen_months_ago.month.ago,
|
|
|
|
true,
|
|
|
|
scope: :"datetime.distance_in_words_verbose",
|
2023-01-09 07:20:10 -05:00
|
|
|
),
|
2022-09-27 12:36:40 -04:00
|
|
|
}
|
|
|
|
render_json_dump(json)
|
|
|
|
end
|
2013-09-12 17:46:43 -04:00
|
|
|
end
|