module Waku module Trackable extend ActiveSupport::Concern included do include PublicActivity::Model end def create_notification(owner:, recipient: nil, key:, params: {}) return if owner.blank? notification = Activity.new(trackable: self, key: key) raise Activity::AcitivityTypeError unless notification.valid_trackable? data = { owner: owner, parameters: params, recipient: recipient, group: group_activity } data.each { |key, value| notification.send("#{key}=", value)} notification.save! end private def group_activity return id if is_a?(Post) post_id end end end