Skip to content

Commit

Permalink
Merge pull request #181 from AresMUSH/dev
Browse files Browse the repository at this point in the history
v1.6.0
  • Loading branch information
lynnfaraday authored Sep 23, 2024
2 parents cc342c3 + f9dd1a2 commit c164a7c
Show file tree
Hide file tree
Showing 84 changed files with 433 additions and 269 deletions.
2 changes: 1 addition & 1 deletion bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ rvm --default use ruby-3.1.2

echo -e "${ARES_INSTALL_TEXT} Ensure proper Ruby version used at startup."

echo "source /home/ares/.rvm/scripts/rvm" >> "${HOME_DIR}/.profile"
echo "source ${HOME_DIR}/.rvm/scripts/rvm" >> "${HOME_DIR}/.profile"
echo "rvm use 3.1.2" >> "${HOME_DIR}/.profile"

# #########################################################################################
Expand Down
2 changes: 1 addition & 1 deletion bin/setup_server
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fi

# Set up redis PPA so we get a recent version

add-apt-repository -y ppa:chris-lea/redis-server
add-apt-repository -y ppa:redislabs/redis

apt-get -y update
apt-get -y install dialog apt-utils
Expand Down
6 changes: 1 addition & 5 deletions plugins/channels/events/char_created_event_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ def on_event(event)
client = event.client
char = Character[event.char_id]

channels = Global.read_config("channels", "default_channels")
Channels.add_to_channels(client, char, channels)
if (client)
client.emit_success t('channels.channel_command_hint')
end
Channels.add_to_default_channels(char, client)
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions plugins/channels/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,14 @@ def self.prune_channel_recall(channel)
msgs_to_delete.each { |m| m.delete }
end
end

def self.add_to_default_channels(char, client)
channels = Global.read_config("channels", "default_channels")
Channels.add_to_channels(client, char, channels)
if (client)
client.emit_success t('channels.channel_command_hint')
end
end

def self.notify_discord_webhook(channel, message, enactor)
debug_enabled = Global.read_config('channels', 'discord_debug')
Expand Down
25 changes: 25 additions & 0 deletions plugins/events/commands/event_scene_cmd.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module AresMUSH

module Events
class EventCreateSceneCmd
include CommandHandler

attr_accessor :num

def parse_args
self.num = integer_arg(cmd.args)
end

def required_args
[ self.num ]
end

def handle
Events.with_an_event(self.num, client, enactor) do |event|
scene = Events.create_event_scene(event, enactor)
Rooms.move_to(client, enactor, scene.room)
end
end
end
end
end
4 changes: 4 additions & 0 deletions plugins/events/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def self.get_cmd_handler(client, cmd, enactor)
return EventSignupCmd
when "cancel"
return EventCancelCmd
when "scene"
return EventCreateSceneCmd
end
end

Expand All @@ -62,6 +64,8 @@ def self.get_web_request_handler(request)
return EventRequestHandler
when "createEvent"
return CreateEventRequestHandler
when "createEventScene"
return CreateEventSceneRequestHandler
when "editEvent"
return EditEventRequestHandler
when "deleteEvent"
Expand Down
1 change: 1 addition & 0 deletions plugins/events/help/en/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The events system is an in-game calendar that lets you schedule events.
`event/edit <#>` - Grabs the current event into your edit buffer (see help edit)
`event/update <#>=<title>/<date and time>/<description>`
`event/delete <#>`
`event/scene <#>` - Creates a scene for the event and invites everyone who signed up to join it. Note: The scene will be PUBLIC, in a temp room, and the event participants will still get the choice whether to join or decline the invitation."

## Signing Up For Events

Expand Down
16 changes: 16 additions & 0 deletions plugins/events/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,21 @@ def self.can_manage_signup?(event, char, enactor)
return true if Events.can_manage_event?(enactor, event)
AresCentral.is_alt?(enactor, char)
end

def self.create_event_scene(event, enactor)
scene = Scenes.start_scene(enactor, "Event #{event.title}", false, Scenes.scene_types.first, true)
scene.update(title: event.title)

Scenes.add_participant(scene, enactor, enactor)
event.signups.each do |signup|
invitee = signup.character
if (invitee)
Scenes.invite_to_scene(scene, invitee, enactor)
end
end

scene
end

end
end
2 changes: 1 addition & 1 deletion plugins/events/web/create_event_request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def handle(request)
end

if (title.blank? || desc.blank?)
return { error: t('webportal.missing_required_fields') }
return { error: t('webportal.missing_required_fields', :fields => "title, description") }
end

begin
Expand Down
27 changes: 27 additions & 0 deletions plugins/events/web/create_event_scene_request_handler.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module AresMUSH
module Events
class CreateEventSceneRequestHandler
def handle(request)
event_id = request.args[:event_id]
enactor = request.enactor

error = Website.check_login(request)
return error if error

request.log_request

event = Event[event_id.to_i]
if (!event)
return { error: t('webportal.not_found') }
end

scene = Events.create_event_scene(event, enactor)
{
scene_id: scene.id
}
end
end
end
end


2 changes: 1 addition & 1 deletion plugins/events/web/edit_event_request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def handle(request)
end

if (title.blank? || desc.blank?)
return { error: t('webportal.missing_required_fields') }
return { error: t('webportal.missing_required_fields', :fields => "title, description") }
end

begin
Expand Down
2 changes: 1 addition & 1 deletion plugins/forum/web/add_post_request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def handle(request)
end

if (message.blank? || subject.blank?)
return { error: t('webportal.missing_required_fields' )}
return { error: t('webportal.missing_required_fields', :fields => "message, subject") }
end

formatted_message = Website.format_input_for_mush(message)
Expand Down
2 changes: 1 addition & 1 deletion plugins/forum/web/add_reply_request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def handle(request)
end

if (message.blank?)
return { error: t('webportal.missing_required_fields' )}
return { error: t('webportal.missing_required_fields', :fields => "message") }
end

formatted_message = Website.format_input_for_mush(message)
Expand Down
3 changes: 2 additions & 1 deletion plugins/fs3skills/fs3skills_config_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ def check_xp
if (level.to_i < 0 || level.to_i > 7)
@validator.add_error "fs3skills:xp_costs #{type} level #{level} is not a valid level."
end
if (level.to_i == 0)
if (level.to_i == 0 && cost != 1)
next if type == "advantage" && !Global.read_config("fs3skills", "allow_advantages_xp")
@validator.add_error "fs3skills:xp_costs #{type} level 0->1 always costs 1XP no matter what you put here."
end
end
Expand Down
2 changes: 1 addition & 1 deletion plugins/jobs/help/en/jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The Jobs system is used by the game administrators to track work requests and to
`jobs` - Lists jobs
`job <#>` - Views a job.

`jobs/filter <flter>` - Filters the jobs list. Valid filters are: active, mine, unfinished, unassigned, unread, all, or a specific category name.
`jobs/filter <flter>` - Filters the jobs list. Valid filters are: active, mine, unfinished, unassigned, unread, archived, all, or a specific category name.
`jobs/mine`, `jobs/active`, `jobs/all` - Shortcuts for the common filters.
`jobs/subscribe` and `jobs/unsubscribe` - Subscribes to new job notices, so you'll get a personal notification for any new job.

Expand Down
7 changes: 5 additions & 2 deletions plugins/jobs/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def self.accessible_jobs(char, category_filter = nil, include_archive = false)
end

def self.status_filters
base = [ "ACTIVE", "MINE", "UNREAD", "UNFINISHED", "UNASSIGNED", "ALL" ]
base = [ "ACTIVE", "MINE", "UNREAD", "UNFINISHED", "UNASSIGNED", "ARCHIVED", "ALL" ]
status_filters = (Global.read_config("jobs", "status_filters") || {})
.keys
.map { |k| k.upcase }
Expand All @@ -88,8 +88,11 @@ def self.filtered_jobs(char, filter = nil)
jobs = Jobs.accessible_jobs(char).select { |j| !j.assigned_to }
when "UNREAD"
jobs = char.unread_jobs
when "ARCHIVED"
status = Jobs.archived_status
jobs = Jobs.accessible_jobs(char, nil, true).select { |j| j.status == status }
when "ALL"
jobs = Jobs.accessible_jobs(char)
jobs = Jobs.accessible_jobs(char).select { |j| }
else
# Category or status filter
if (Jobs.status_filters.include?(filter))
Expand Down
2 changes: 1 addition & 1 deletion plugins/jobs/templates/jobs_list.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<%= right( job.id.to_s, 4) -%>
%xh<%= left( unread_status(job), 4 ) %><%= "%xn" -%>
<%= category_color(job) %><%= left( job.job_category.name, 7) %><%= "%xn" -%>
<%= status_color(job) %><%= left( job.status, 8) %><%= "%xn" -%>
<%= status_color(job) %><%= left( job.status, 7) %> <%= "%xn" -%>
<%= left( job.title, 19) -%>
<%= left( submitter(job), 17) -%>
<%= handler(job) %>
Expand Down
2 changes: 1 addition & 1 deletion plugins/jobs/web/job_create_request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def handle(request)
return error if error

if (title.blank?)
return { error: t('webportal.missing_required_fields') }
return { error: t('webportal.missing_required_fields', :fields => "title") }
end

request.log_request
Expand Down
2 changes: 1 addition & 1 deletion plugins/jobs/web/job_save_request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def handle(request)
return error if error

if (title.blank?)
return { error: t('webportal.missing_required_fields') }
return { error: t('webportal.missing_required_fields', :fields => "title") }
end

request.log_request
Expand Down
13 changes: 13 additions & 0 deletions plugins/login/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,18 @@ def self.boot_char(enactor, bootee, boot_reason)

return nil
end

def self.web_session_info(char)
{
token: char.login_api_token,
name: char.name,
id: char.id,
is_approved: char.is_approved?,
is_admin: char.is_admin?,
is_coder: char.is_coder?,
is_theme_mgr: (!char.is_admin? && Website.can_manage_theme?(char)),
screen_reader: char.screen_reader
}
end
end
end
17 changes: 13 additions & 4 deletions plugins/login/public/login_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ def self.notify(char, type, message, reference_id, data = "", notify_if_online =
else
LoginNotice.create(character: char, type: type, message: message, data: data, reference_id: reference_id, is_unread: true, timestamp: Time.now)
end
unread_count = Login.count_unread_notifs_for_all_alts(char)
Global.client_monitor.notify_web_clients(:notification_update, "#{unread_count}", true) do |c|
c && AresCentral.is_alt?(c, char)
end
Login.update_notification_count(char)
end

def self.mark_notices_read(char, type, reference_id = nil)
Expand All @@ -123,16 +120,28 @@ def self.mark_notices_read(char, type, reference_id = nil)
notices.each do |n|
n.update(is_unread: false)
end

Login.update_notification_count(char)
end

def self.count_unread_notifs_for_all_alts(char)
return if !char
count = 0
AresCentral.alts(char).each do |c|
count += c.unread_notifications.count
end
count
end

def self.update_notification_count(char)
return if !char

unread_count = Login.count_unread_notifs_for_all_alts(char)
Global.client_monitor.notify_web_clients(:notification_update, "#{unread_count}", true) do |c|
c && AresCentral.is_alt?(c, char)
end
end

def self.build_web_site_info(char, viewer)
matches = Character.all.select { |c| Login.is_site_match?(c.last_ip,
c.last_hostname,
Expand Down
2 changes: 1 addition & 1 deletion plugins/login/web/ban_add_request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def handle(request)
end

if (site.blank? || reason.blank?)
return { error: t('webportal.missing_required_fields') }
return { error: t('webportal.missing_required_fields', :fields => "site, reason") }
end

error = Login.add_site_ban(enactor, site, reason)
Expand Down
2 changes: 1 addition & 1 deletion plugins/login/web/ban_player_request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def handle(request)
end

if (reason.blank?)
return { error: t('webportal.missing_required_fields') }
return { error: t('webportal.missing_required_fields', :fields => "reason") }
end

char = Character.named(name)
Expand Down
2 changes: 1 addition & 1 deletion plugins/login/web/boot_player_request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def handle(request)
end

if (reason.blank?)
return { error: t('webportal.missing_required_fields') }
return { error: t('webportal.missing_required_fields', :fields => "reason") }
end

char = Character.named(name)
Expand Down
11 changes: 1 addition & 10 deletions plugins/login/web/check_token_request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,8 @@ def handle(request)
Login.update_site_info(request.ip_addr, request.hostname, char)
end

Login.web_session_info(char)


{
token: char.login_api_token,
name: char.name,
id: char.id,
is_approved: char.is_approved?,
is_admin: char.is_admin?,
is_coder: char.is_coder?,
is_theme_mgr: (!char.is_admin? && Website.can_manage_theme?(char))
}
end
end
end
Expand Down
10 changes: 1 addition & 9 deletions plugins/login/web/login_request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,7 @@ def handle(request)
AresCentral.sync_handle(char)
end

{
token: char.login_api_token,
name: char.name,
id: char.id,
is_approved: char.is_approved?,
is_admin: char.is_admin?,
is_coder: char.is_coder?,
is_theme_mgr: (!char.is_admin? && Website.can_manage_theme?(char))
}
Login.web_session_info(char)
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions plugins/login/web/mark_notice_read_request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def handle(request)

notice.update(is_unread: unread)

Login.update_notification_count(enactor)

{}
end
end
Expand Down
2 changes: 2 additions & 0 deletions plugins/login/web/mark_notices_read_request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def handle(request)
alt.login_notices.find(is_unread: true).each { |n| n.update(is_unread: false)}
end

Login.update_notification_count(enactor)

{}
end
end
Expand Down
Loading

0 comments on commit c164a7c

Please sign in to comment.