Fixed issue #2218 - CTI Caller Log blocks user deletion/destroy and fails
This commit is contained in:
parent
ec74d56b77
commit
2774bc207d
3 changed files with 28 additions and 11 deletions
|
@ -98,6 +98,10 @@ returns
|
||||||
# set user id
|
# set user id
|
||||||
user_id = record[:created_by_id]
|
user_id = record[:created_by_id]
|
||||||
if model == User
|
if model == User
|
||||||
|
if record.destroyed?
|
||||||
|
Cti::CallerId.where(user_id: user_id).destroy_all
|
||||||
|
return
|
||||||
|
end
|
||||||
user_id = record.id
|
user_id = record.id
|
||||||
end
|
end
|
||||||
return if !user_id
|
return if !user_id
|
||||||
|
|
|
@ -1157,15 +1157,15 @@ raise 'Minimum one user need to have admin permissions'
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_longer_required_objects
|
def destroy_longer_required_objects
|
||||||
Authorization.where(user_id: id).destroy_all
|
::Authorization.where(user_id: id).destroy_all
|
||||||
Avatar.remove('User', id)
|
::Avatar.remove('User', id)
|
||||||
Cti::CallerId.where(user_id: id).destroy_all
|
::Cti::CallerId.where(user_id: id).destroy_all
|
||||||
Taskbar.where(user_id: id).destroy_all
|
::Taskbar.where(user_id: id).destroy_all
|
||||||
Karma::ActivityLog.where(user_id: id).destroy_all
|
::Karma::ActivityLog.where(user_id: id).destroy_all
|
||||||
Karma::User.where(user_id: id).destroy_all
|
::Karma::User.where(user_id: id).destroy_all
|
||||||
OnlineNotification.where(user_id: id).destroy_all
|
::OnlineNotification.where(user_id: id).destroy_all
|
||||||
RecentView.where(created_by_id: id).destroy_all
|
::RecentView.where(created_by_id: id).destroy_all
|
||||||
UserDevice.remove(id)
|
::UserDevice.remove(id)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -534,4 +534,17 @@ Mob: +49 333 8362222",
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test 'user delete with caller log rebuild' do
|
||||||
|
assert_equal(2, Cti::CallerId.where(user_id: @agent2.id).count)
|
||||||
|
|
||||||
|
@agent2.destroy!
|
||||||
|
|
||||||
|
assert_equal(0, Cti::CallerId.where(user_id: @agent2.id).count)
|
||||||
|
|
||||||
|
Observer::Transaction.commit
|
||||||
|
Scheduler.worker(true)
|
||||||
|
|
||||||
|
assert_equal(0, Cti::CallerId.where(user_id: @agent2.id).count)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue