diff --git a/install/upgrades/036-0.9_upgrade.rb b/install/upgrades/036-0.9_upgrade.rb new file mode 100644 index 0000000000..7f7995b2c2 --- /dev/null +++ b/install/upgrades/036-0.9_upgrade.rb @@ -0,0 +1,14 @@ +module AresMUSH + + puts "=======================================================================" + puts "Add timestamps to channel history. " + puts "=======================================================================" + + + Channel.all.each do |c| + messages = c.messages + new_messages = c.messages.map { |m| { message: m, timestamp: DateTime.now }} + c.update(messages: new_messages) + end + puts "Upgrade complete!" +end \ No newline at end of file diff --git a/plugins/channels/commands/channel_recall_cmd.rb b/plugins/channels/commands/channel_recall_cmd.rb index 207492c531..97f1708085 100644 --- a/plugins/channels/commands/channel_recall_cmd.rb +++ b/plugins/channels/commands/channel_recall_cmd.rb @@ -25,9 +25,9 @@ def handle Channels.with_an_enabled_channel(self.name, client, enactor) do |channel| total_messages = channel.messages.count start_message = [ (total_messages - self.num_messages), 0 ].max - messages = channel.messages[start_message, total_messages].map { |m| " #{channel.display_name} #{m}" } - - template = BorderedListTemplate.new messages, t('channels.recall_history', :name => channel.display_name(false)) + messages = channel.messages[start_message, total_messages] + list = messages.map { |m| " [#{OOCTime.local_long_timestr(enactor, m['timestamp'])}] #{channel.display_name} #{m['message']}"} + template = BorderedListTemplate.new list, t('channels.recall_history', :name => channel.display_name(false)) client.emit template.render end end diff --git a/plugins/channels/commands/channel_report_cmd.rb b/plugins/channels/commands/channel_report_cmd.rb index 894ba8976a..c19b81f383 100644 --- a/plugins/channels/commands/channel_report_cmd.rb +++ b/plugins/channels/commands/channel_report_cmd.rb @@ -17,12 +17,13 @@ def required_args def handle Channels.with_an_enabled_channel(self.name, client, enactor) do |channel| - total_messages = channel.messages.count + messages = channel.messages.map { |m| " [#{OOCTime.local_long_timestr(enactor, m['timestamp'])}] #{channel.display_name} #{m['message']}"}.join("%R") body = t('channels.channel_reported_body', :name => channel.name, :reporter => enactor_name) body << self.reason body << "%R-------%R" - body << channel.messages.map { |m| " #{m}" }.join('%R') + body << messages + Jobs.create_job(Jobs.trouble_category, t('channels.channel_reported_title'), body, Game.master.system_character) client.emit_success t('channels.channel_reported') diff --git a/plugins/channels/public/channel.rb b/plugins/channels/public/channel.rb index ebf0dbe431..f19bd54705 100644 --- a/plugins/channels/public/channel.rb +++ b/plugins/channels/public/channel.rb @@ -41,7 +41,7 @@ def display_name(include_markers = true) def add_to_history(msg) return if !self.recall_enabled - new_messages = (self.messages << msg) + new_messages = (self.messages << { message: msg, timestamp: DateTime.now }) if (new_messages.count > 25) new_messages.shift end diff --git a/plugins/channels/web/chat_request_handler.rb b/plugins/channels/web/chat_request_handler.rb index d1b9cde018..c0a3b03731 100644 --- a/plugins/channels/web/chat_request_handler.rb +++ b/plugins/channels/web/chat_request_handler.rb @@ -18,7 +18,15 @@ def handle(request) name: c.name, enabled: Channels.is_on_channel?(enactor, c), allowed: Channels.can_use_channel(enactor, c), - messages: Channels.is_on_channel?(enactor, c) ? c.messages.map { |m| WebHelpers.format_markdown_for_html(m) } : nil + who: Channels.channel_who(c).map { |w| { + name: w.name, + ooc_name: w.ooc_name, + icon: WebHelpers.icon_for_char(w), + muted: Channels.is_muted?(w, c) + }}, + messages: Channels.is_on_channel?(enactor, c) ? c.messages.map { |m| { + message: WebHelpers.format_markdown_for_html(m['message']), + timestamp: OOCTime.local_long_timestr(enactor, m['timestamp']) }} : nil }} {