{"size": 300, "ext": "js", "max_stars_repo_path": "bonus/websocket-adonis/academy-websocket-facebook/app/Models/Hooks/PostHook.js", "max_stars_repo_name": "Raymw1/gostack6", "max_stars_repo_stars_event_min_datetime": "2021-10-19T17:57:01.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-28T13:05:50.000Z", "max_issues_repo_path": "bonus/websocket-adonis/academy-websocket-facebook/app/Models/Hooks/PostHook.js", "max_issues_repo_name": "Raymw1/gostack6", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bonus/websocket-adonis/academy-websocket-facebook/app/Models/Hooks/PostHook.js", "max_forks_repo_name": "Raymw1/gostack6", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.4285714286, "max_line_length": 53, "alphanum_fraction": 0.65}
'use strict'

const Ws = use('Ws')

const PostHook = (exports = module.exports = {})

PostHook.sendWs = async (postInstance) => {
  const topic = Ws.getChannel('posts').topic('posts')
  if (topic) {
    await postInstance.loadMany(['user', 'comments'])
    topic.broadcast('new', postInstance)
  }
}
