- <%= item.created_by.displayName() %> <%- @T( "#{item.type}d" ) %> <%- @T( item.object_name ) %><% if item.title: %> <%= item.title %><% end %>
+ <% if item.objectNative && item.objectNative.activityMessage: %>
+ <%- item.objectNative.activityMessage(item) %>
+ <% else: %>
+ Need objectNative in item <%= item.object %>.find(<%= item.o_id %>)
+ <% end %>
<%- @humanTime(item.created_at, false, 'activity-time') %>
diff --git a/app/models/activity_stream.rb b/app/models/activity_stream.rb
index 363bb5bcd..65393eb40 100644
--- a/app/models/activity_stream.rb
+++ b/app/models/activity_stream.rb
@@ -10,12 +10,12 @@ class ActivityStream < ApplicationModel
add a new activity entry for an object
ActivityStream.add(
- :type => 'updated',
- :object => 'Ticket',
- :role => 'Admin',
- :o_id => ticket.id,
- :created_by_id => 1,
- :created_at => '2013-06-04 10:00:00',
+ type: 'update',
+ object: 'Ticket',
+ role: 'Admin',
+ o_id: ticket.id,
+ created_by_id: 1,
+ created_at: '2013-06-04 10:00:00',
)
=end
@@ -24,15 +24,15 @@ add a new activity entry for an object
# lookups
if data[:type]
- type_id = TypeLookup.by_name( data[:type] )
+ type_id = TypeLookup.by_name(data[:type])
end
if data[:object]
- object_id = ObjectLookup.by_name( data[:object] )
+ object_id = ObjectLookup.by_name(data[:object])
end
role_id = nil
if data[:role]
- role = Role.lookup( name: data[:role] )
+ role = Role.lookup(name: data[:role])
if !role
fail "No such Role #{data[:role]}"
end
@@ -49,7 +49,7 @@ add a new activity entry for an object
).order('created_at DESC, id DESC').first
# resturn if old entry is really fresh
- return result if result && result.created_at.to_i >= ( data[:created_at].to_i - 12 )
+ return result if result && result.created_at.to_i >= ( data[:created_at].to_i - 20 )
# create history
record = {
@@ -69,12 +69,12 @@ add a new activity entry for an object
remove whole activity entries of an object
- ActivityStream.remove( 'Ticket', 123 )
+ ActivityStream.remove('Ticket', 123)
=end
- def self.remove( object_name, o_id )
- object_id = ObjectLookup.by_name( object_name )
+ def self.remove(object_name, o_id)
+ object_id = ObjectLookup.by_name(object_name)
ActivityStream.where(
activity_stream_object_id: object_id,
o_id: o_id,
@@ -85,7 +85,7 @@ remove whole activity entries of an object
return all activity entries of an user
- activity_stream = ActivityStream.list( user )
+ activity_stream = ActivityStream.list(user)
=end
@@ -94,7 +94,7 @@ return all activity entries of an user
group_ids = user.group_ids
# do not return an activity stream for custoers
- customer_role = Role.lookup( name: 'Customer' )
+ customer_role = Role.lookup(name: 'Customer')
return [] if role_ids.include?(customer_role.id)
stream = if group_ids.empty?
diff --git a/app/models/application_model.rb b/app/models/application_model.rb
index 6f7313a60..68b038abb 100644
--- a/app/models/application_model.rb
+++ b/app/models/application_model.rb
@@ -826,7 +826,7 @@ log object create activity stream, if configured - will be executed automaticall
def activity_stream_create
return if !self.class.activity_stream_support_config
- activity_stream_log('created', self['created_by_id'])
+ activity_stream_log('create', self['created_by_id'])
end
=begin
@@ -867,7 +867,7 @@ log object update activity stream, if configured - will be executed automaticall
return if !log
- activity_stream_log('updated', self['updated_by_id'])
+ activity_stream_log('update', self['updated_by_id'])
end
=begin
diff --git a/app/models/application_model/activity_stream_base.rb b/app/models/application_model/activity_stream_base.rb
index e4233237b..85173eaf9 100644
--- a/app/models/application_model/activity_stream_base.rb
+++ b/app/models/application_model/activity_stream_base.rb
@@ -6,10 +6,10 @@ module ApplicationModel::ActivityStreamBase
log activity for this object
article = Ticket::Article.find(123)
- result = article.activity_stream_log( 'created', user_id )
+ result = article.activity_stream_log('create', user_id)
# force log
- result = article.activity_stream_log( 'created', user_id, true )
+ result = article.activity_stream_log('create', user_id, true)
returns
@@ -17,7 +17,7 @@ returns
=end
- def activity_stream_log (type, user_id, force = false)
+ def activity_stream_log(type, user_id, force = false)
# return if we run import mode
return if Setting.get('import_mode')
diff --git a/app/models/observer/ticket/notification/background_job.rb b/app/models/observer/ticket/notification/background_job.rb
index 304987106..78c0b9b41 100644
--- a/app/models/observer/ticket/notification/background_job.rb
+++ b/app/models/observer/ticket/notification/background_job.rb
@@ -151,9 +151,12 @@ class Observer::Ticket::Notification::BackgroundJob
if channels['online']
used_channels.push 'online'
+ created_by_id = ticket.updated_by_id || 1
+
# delete old notifications
if @p[:type] == 'reminder_reached' || @p[:type] == 'escalation'
seen = false
+ created_by_id = 1
OnlineNotification.remove_by_type('Ticket', ticket.id, @p[:type], user)
# on updates without state changes create unseen messages
@@ -168,7 +171,7 @@ class Observer::Ticket::Notification::BackgroundJob
object: 'Ticket',
o_id: ticket.id,
seen: seen,
- created_by_id: ticket.updated_by_id || 1,
+ created_by_id: created_by_id,
user_id: user.id,
)
Rails.logger.debug "sent ticket online notifiaction to agent (#{@p[:type]}/#{ticket.id}/#{user.email})"
diff --git a/app/models/ticket/activity_stream_log.rb b/app/models/ticket/activity_stream_log.rb
index 47c924d67..14f0f4897 100644
--- a/app/models/ticket/activity_stream_log.rb
+++ b/app/models/ticket/activity_stream_log.rb
@@ -6,7 +6,7 @@ module Ticket::ActivityStreamLog
log activity for this object
ticket = Ticket.find(123)
- result = ticket.activity_stream_log( 'created', user_id )
+ result = ticket.activity_stream_log('create', user_id)
returns
diff --git a/app/models/ticket/article/activity_stream_log.rb b/app/models/ticket/article/activity_stream_log.rb
index 07365d6c7..18d723c8f 100644
--- a/app/models/ticket/article/activity_stream_log.rb
+++ b/app/models/ticket/article/activity_stream_log.rb
@@ -6,7 +6,7 @@ module Ticket::Article::ActivityStreamLog
log activity for this object
article = Ticket::Article.find(123)
- result = article.activity_stream_log( 'created', user_id )
+ result = article.activity_stream_log('create', user_id)
returns
@@ -14,7 +14,7 @@ returns
=end
- def activity_stream_log (type, user_id)
+ def activity_stream_log(type, user_id)
# return if we run import mode
return if Setting.get('import_mode')
@@ -24,7 +24,7 @@ returns
return if !self.class.activity_stream_support_config
role = self.class.activity_stream_support_config[:role]
- ticket = Ticket.lookup( id: ticket_id )
+ ticket = Ticket.lookup(id: ticket_id)
ActivityStream.add(
o_id: self['id'],
type: type,
diff --git a/db/migrate/20160222000001_improved_activity_messages.rb b/db/migrate/20160222000001_improved_activity_messages.rb
new file mode 100644
index 000000000..66c318c8e
--- /dev/null
+++ b/db/migrate/20160222000001_improved_activity_messages.rb
@@ -0,0 +1,5 @@
+class ImprovedActivityMessages < ActiveRecord::Migration
+ def up
+ ActivityStream.destroy_all
+ end
+end
diff --git a/public/assets/tests/core.js b/public/assets/tests/core.js
index 110f66947..606e71bb1 100644
--- a/public/assets/tests/core.js
+++ b/public/assets/tests/core.js
@@ -271,8 +271,11 @@ test( "i18n", function() {
translated = App.i18n.translateContent('%s ago', 123);
equal( translated, 'vor 123', 'de-de - %s' );
- translated = App.i18n.translateContent('%s %s test', 123, 'xxx');
- equal( translated, '123 xxx test', 'de-de - %s %s' );
+ translated = App.i18n.translateContent('%s ago', '
quote');
+ equal( translated, 'vor <b>quote</b>', 'de-de - %s - quote' );
+
+ translated = App.i18n.translateContent('%s %s test', 123, 'xxx |B|');
+ equal( translated, '123 xxx |B| test', 'de-de - %s %s' );
translated = App.i18n.translateContent('|%s| %s test', 123, 'xxx');
equal( translated, '
123 xxx test', 'de-de - *%s* %s' );
@@ -311,11 +314,14 @@ test( "i18n", function() {
translated = App.i18n.translateContent('%s ago', 123);
equal( translated, '123 ago', 'en-us - %s' );
+ translated = App.i18n.translateContent('%s ago', '
quote');
+ equal( translated, '<b>quote</b> ago', 'en-us - %s - qupte' );
+
translated = App.i18n.translateContent('%s %s test', 123, 'xxx');
equal( translated, '123 xxx test', 'en-us - %s %s' );
- translated = App.i18n.translateContent('|%s| %s test', 123, 'xxx');
- equal( translated, '
123 xxx test', 'en-us - *%s* %s' );
+ translated = App.i18n.translateContent('|%s| %s test', 123, 'xxx |B|');
+ equal( translated, '
123 xxx |B| test', 'en-us - *%s* %s' );
translated = App.i18n.translateContent('||%s|| %s test', 123, 'xxx');
equal( translated, '
123 xxx test', 'en-us - *%s* %s' );
diff --git a/test/unit/activity_stream_test.rb b/test/unit/activity_stream_test.rb
index 31ba7443c..ef29b0c96 100644
--- a/test/unit/activity_stream_test.rb
+++ b/test/unit/activity_stream_test.rb
@@ -61,22 +61,22 @@ class ActivityStreamTest < ActiveSupport::TestCase
{
result: true,
object: 'Ticket',
- type: 'updated',
+ type: 'update',
},
{
result: true,
object: 'Ticket::Article',
- type: 'created',
+ type: 'create',
},
{
result: true,
object: 'Ticket',
- type: 'created',
+ type: 'create',
},
{
result: false,
object: 'User',
- type: 'updated',
+ type: 'update',
o_id: current_user.id,
},
]
@@ -118,7 +118,7 @@ class ActivityStreamTest < ActiveSupport::TestCase
article.update_attributes(test[:update][:article])
end
- sleep 15
+ sleep 21
if test[:update][:ticket]
ticket.update_attributes(test[:update][:ticket])
end
@@ -168,12 +168,12 @@ class ActivityStreamTest < ActiveSupport::TestCase
{
result: true,
object: 'Organization',
- type: 'updated',
+ type: 'update',
},
{
result: true,
object: 'Organization',
- type: 'created',
+ type: 'create',
},
]
},
@@ -194,7 +194,7 @@ class ActivityStreamTest < ActiveSupport::TestCase
test[:check][1][:o_id] = organization.id
test[:check][1][:updated_at] = organization.updated_at
test[:check][1][:created_by_id] = current_user.id
- sleep 13
+ sleep 19
end
if test[:update2][:organization]
@@ -240,12 +240,12 @@ class ActivityStreamTest < ActiveSupport::TestCase
{
result: true,
object: 'User',
- type: 'created',
+ type: 'create',
},
{
result: false,
object: 'User',
- type: 'updated',
+ type: 'update',
},
]
},
@@ -312,12 +312,12 @@ class ActivityStreamTest < ActiveSupport::TestCase
{
result: true,
object: 'User',
- type: 'updated',
+ type: 'update',
},
{
result: true,
object: 'User',
- type: 'created',
+ type: 'create',
},
]
},
@@ -340,7 +340,7 @@ class ActivityStreamTest < ActiveSupport::TestCase
end
# to verify update which need to be logged
- sleep 14
+ sleep 21
if test[:update2][:user]
user.update_attributes(test[:update2][:user])