2014-02-03 19:23:00 +00:00
|
|
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
2013-09-28 00:07:11 +00:00
|
|
|
|
|
|
|
module ApplicationModel::ActivityStreamBase
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
log activity for this object
|
|
|
|
|
|
|
|
article = Ticket::Article.find(123)
|
|
|
|
result = article.activity_stream_log( 'created', user_id )
|
|
|
|
|
2013-10-07 03:38:07 +00:00
|
|
|
# force log
|
|
|
|
result = article.activity_stream_log( 'created', user_id, true )
|
|
|
|
|
2013-09-28 00:07:11 +00:00
|
|
|
returns
|
|
|
|
|
|
|
|
result = true # false
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
2013-10-07 03:38:07 +00:00
|
|
|
def activity_stream_log (type, user_id, force = false)
|
2014-03-10 15:46:15 +00:00
|
|
|
|
|
|
|
# return if we run import mode
|
|
|
|
return if Setting.get('import_mode')
|
|
|
|
|
2014-11-06 22:54:34 +00:00
|
|
|
# return if we run on init mode
|
|
|
|
return if !Setting.get('system_init_done')
|
|
|
|
|
2013-10-07 03:38:07 +00:00
|
|
|
role = self.class.activity_stream_support_config[:role]
|
|
|
|
updated_at = self.updated_at
|
|
|
|
if force
|
|
|
|
updated_at = Time.new
|
|
|
|
end
|
2013-09-28 00:07:11 +00:00
|
|
|
ActivityStream.add(
|
2015-04-27 13:42:53 +00:00
|
|
|
o_id: self['id'],
|
|
|
|
type: type,
|
|
|
|
object: self.class.name,
|
|
|
|
group_id: self['group_id'],
|
|
|
|
role: role,
|
|
|
|
created_at: updated_at,
|
|
|
|
created_by_id: user_id,
|
2013-09-28 00:07:11 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2014-02-03 19:23:00 +00:00
|
|
|
end
|