metamaps--metamaps/app/models/message.rb

31 lines
714 B
Ruby
Raw Normal View History

2016-09-24 03:00:46 +00:00
# frozen_string_literal: true
2017-11-25 19:23:47 +00:00
class Message < ApplicationRecord
2015-12-11 19:23:41 +00:00
belongs_to :user
belongs_to :resource, polymorphic: true
delegate :name, to: :user, prefix: true
after_create :after_created
2017-11-25 19:23:47 +00:00
# after_create :after_created_async
2015-12-11 19:23:41 +00:00
def user_image
user.image.url
2015-12-11 19:23:41 +00:00
end
def as_json(_options = {})
2017-11-25 19:23:47 +00:00
json = super(methods: %i(user_name user_image))
2015-12-11 19:23:41 +00:00
json
end
def after_created
ActionCable.server.broadcast 'map_' + resource.id.to_s, type: 'messageCreated', message: as_json
end
react-router and rebuild app structure in react (#1091) * initial restructuring * stuff * lock version number * just keep using current mapinfobox * fix map upperRightUI layout * make mapsWidth work and add mobile * remove filterBoxOpen for now * redo the mobile menu in react * get account menu and invite lightbox working * fixed maps scrolling * make other routes work * fix signed out home page * fix accountbox toggling * add metacode edit routes * lots of fixes * fix map chat layout and tab bug * improve topic card readability and fix dragging bug * fixup mapchat stuff * fix up navigation to use react-router * jquery no longer handling access requests * handle case where user hasn't loaded yet * this shouldn't have been removed * add frame for topic view * rewrite map instructions * fix toast (and sign out bug) * fix apps pages and missing routes * made our request invite page look nice * filter box in react * forgot to add one proptype * remove extra comments * handle page title and mobile title updates * reenable google analytics * make filterbox use onclickoutside * reenable topic view in react * fix csrf auth token * fix little homepage styling issue * try putting preparevizdata in a timeout * installing render log to count * little fixes * fixup filters * make filter map function names more readable * eslint helps * renaming for clarity * use onclickoutside for account/sign in box * add some logging to see whether this is source of many renders * turns out chatview was heavily hogging memory * tiimeout not needed
2017-03-16 21:58:56 +00:00
def after_created_async
FollowService.follow(resource, user, 'commented')
NotificationService.notify_followers(resource, 'map_message', self)
end
handle_asynchronously :after_created_async
2015-12-11 19:23:41 +00:00
end