model_ticket.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. window.onload = function() {
  2. App.Role.refresh([
  3. {
  4. name: "Agent",
  5. permission_ids: [
  6. 48,
  7. ],
  8. group_ids: {},
  9. default_at_signup: false,
  10. note: "To work on Tickets.",
  11. active: true,
  12. updated_at: "2020-07-29T14:57:27.304Z",
  13. id: 2
  14. },
  15. {
  16. name: "Customer",
  17. permission_ids: [
  18. 49
  19. ],
  20. group_ids: {},
  21. default_at_signup: true,
  22. note: "People who create Tickets ask for help.",
  23. active: true,
  24. updated_at: "2020-07-29T14:57:27.314Z",
  25. id: 3
  26. }
  27. ])
  28. App.Permission.refresh([
  29. {
  30. name: "ticket.agent",
  31. note: "Access to Agent Tickets based on Group Access",
  32. active: true,
  33. id: 48
  34. },
  35. {
  36. name: "ticket.customer",
  37. note: "Access to Customer Tickets based on current_user and organization",
  38. active: true,
  39. id: 49
  40. },
  41. ])
  42. App.User.refresh([
  43. {
  44. login: "nicole.braun@zammad.org",
  45. firstname: "Nicole",
  46. lastname: "Braun",
  47. email: "nicole.braun@zammad.org",
  48. web: "",
  49. phone: "",
  50. fax: "",
  51. mobile: "",
  52. street: "",
  53. zip: "",
  54. city: "",
  55. country: "",
  56. organization_id: 1,
  57. department: "",
  58. note: "",
  59. role_ids: [
  60. 3
  61. ],
  62. group_ids: {},
  63. active: true,
  64. updated_at: "2023-08-23T08:59:15.437Z",
  65. organization_ids: [],
  66. address: "",
  67. vip: false,
  68. id: 2
  69. },
  70. {
  71. login: "admin@example.com",
  72. firstname: "Test Admin",
  73. lastname: "Agent",
  74. email: "admin@example.com",
  75. web: "",
  76. phone: "",
  77. fax: "",
  78. mobile: "",
  79. street: "",
  80. zip: "",
  81. city: "",
  82. country: "",
  83. organization_id: null,
  84. department: null,
  85. note: "",
  86. role_ids: [
  87. 2
  88. ],
  89. group_ids: {
  90. 1: [
  91. "full"
  92. ],
  93. 2: [
  94. "full"
  95. ]
  96. },
  97. active: true,
  98. updated_at: "2023-08-23T08:51:07.062Z",
  99. organization_ids: [],
  100. address: null,
  101. vip: false,
  102. id: 3
  103. }
  104. ])
  105. App.Group.refresh([
  106. {
  107. name: "Users",
  108. assignment_timeout: null,
  109. follow_up_possible: "yes",
  110. follow_up_assignment: true,
  111. email_address_id: 1,
  112. signature_id: 1,
  113. note: "Standard Group/Pool for Tickets.",
  114. active: true,
  115. shared_drafts: true,
  116. updated_at: "2023-08-23T08:31:24.665Z",
  117. reopen_time_in_days: null,
  118. id: 1
  119. }
  120. ])
  121. App.EmailAddress.refresh([
  122. {
  123. name: "Zammad Helpdesk",
  124. email: "zammad@localhost",
  125. channel_id: 1,
  126. note: null,
  127. active: true,
  128. updated_at: "2023-08-23T08:31:24.483Z",
  129. id: 1
  130. }
  131. ])
  132. App.Ticket.refresh([{
  133. id: 1,
  134. title: 'ticket1',
  135. state_id: 1,
  136. customer_id: 33,
  137. organization_id: 1,
  138. owner_id: 1,
  139. group_id: 1,
  140. },
  141. {
  142. id: 2,
  143. title: 'ticket2',
  144. state_id: 1,
  145. customer_id: 44,
  146. organization_id: 1,
  147. owner_id: 1,
  148. },
  149. {
  150. id: 3,
  151. title: 'ticket3',
  152. state_id: 1,
  153. customer_id: 55,
  154. organization_id: undefined,
  155. owner_id: 1,
  156. },
  157. {
  158. id: 4,
  159. title: 'ticket4',
  160. state_id: 1,
  161. customer_id: 66,
  162. organization_id: undefined,
  163. owner_id: 1,
  164. group_id: 1,
  165. },
  166. {
  167. id: 5,
  168. title: 'ticket5',
  169. state_id: 1,
  170. customer_id: 66,
  171. organization_id: 123,
  172. owner_id: 1,
  173. group_id: 1,
  174. }])
  175. App.User.refresh([{
  176. id: 33,
  177. login: 'hh@1example.com',
  178. firstname: 'Harald',
  179. lastname: 'Habebe',
  180. email: 'hh1@example.com',
  181. organization_id: 1,
  182. role_ids: [3],
  183. active: true,
  184. },
  185. {
  186. id: 44,
  187. login: 'hh2@example.com',
  188. firstname: 'Harald',
  189. lastname: 'Habebe',
  190. email: 'hh2@example.com',
  191. organization_id: 2,
  192. role_ids: [3],
  193. active: true,
  194. },
  195. {
  196. id: 55,
  197. login: 'hh3example.com',
  198. firstname: 'Harald',
  199. lastname: 'Habebe',
  200. email: 'hh3@example.com',
  201. organization_id: undefined,
  202. organization_ids: [123], // secondary organization
  203. role_ids: [3],
  204. active: true,
  205. }])
  206. App.TicketArticle.refresh([
  207. {
  208. from: "Nicole Braun <nicole.braun@zammad.org>",
  209. to: null,
  210. cc: null,
  211. subject: null,
  212. body: "from customer article",
  213. content_type: "text/plain",
  214. ticket_id: 1,
  215. type_id: 5,
  216. sender_id: 2,
  217. internal: false,
  218. in_reply_to: null,
  219. preferences: {},
  220. updated_at: "2023-08-23T08:31:12.483Z",
  221. id: 1,
  222. created_by_id: 2,
  223. },
  224. {
  225. from: "Test Admin Agent via Zammad Helpdesk <zammad@localhost>",
  226. to: "nicole.braun@zammad.org",
  227. cc: "",
  228. subject: "Welcome to Zammad!",
  229. body: "from agent article",
  230. content_type: "text/html",
  231. ticket_id: 1,
  232. type_id: 1,
  233. sender_id: 1,
  234. internal: false,
  235. in_reply_to: "",
  236. preferences: {},
  237. updated_at: "2023-08-23T08:59:21.632Z",
  238. id: 2,
  239. created_by_id: 3,
  240. },
  241. ])
  242. QUnit.test('ticket.editabe customer user #1', assert => {
  243. App.Session.set(33)
  244. ticket1 = App.Ticket.find(1);
  245. assert.ok(ticket1.editable(), 'access via customer_id');
  246. ticket2 = App.Ticket.find(2);
  247. assert.ok(ticket2.editable(), 'access via organization_id');
  248. ticket3 = App.Ticket.find(3);
  249. assert.ok(!ticket3.editable(), 'no access');
  250. ticket4 = App.Ticket.find(4);
  251. assert.ok(!ticket4.editable(), 'no access');
  252. ticket5 = App.Ticket.find(5);
  253. assert.ok(!ticket5.editable(), 'no access');
  254. });
  255. QUnit.test('ticket.editabe customer user #2', assert => {
  256. App.Session.set(44)
  257. ticket1 = App.Ticket.find(1);
  258. assert.ok(!ticket1.editable(), 'no access');
  259. ticket2 = App.Ticket.find(2);
  260. assert.ok(ticket2.editable(), 'access via customer_id');
  261. ticket3 = App.Ticket.find(3);
  262. assert.ok(!ticket3.editable(), 'no access');
  263. ticket4 = App.Ticket.find(4);
  264. assert.ok(!ticket4.editable(), 'no access');
  265. ticket5 = App.Ticket.find(5);
  266. assert.ok(!ticket5.editable(), 'no access');
  267. });
  268. QUnit.test('ticket.editabe customer user #3', assert => {
  269. App.Session.set(55)
  270. ticket1 = App.Ticket.find(1);
  271. assert.ok(!ticket1.editable(), 'no access');
  272. ticket2 = App.Ticket.find(2);
  273. assert.ok(!ticket2.editable(), 'no access');
  274. ticket3 = App.Ticket.find(3);
  275. assert.ok(ticket3.editable(), 'access via customer_id');
  276. ticket4 = App.Ticket.find(4);
  277. assert.ok(!ticket4.editable(), 'no access');
  278. ticket5 = App.Ticket.find(5);
  279. assert.ok(ticket5.editable(), 'access via secondary organization');
  280. });
  281. QUnit.test('Agent name is unintentionally exposed when reply with quote of own agent article #4768', assert => {
  282. App.Config.set('ticket_define_email_from', 'AgentNameSystemAddressName')
  283. App.Config.set('ticket_define_email_from_separator', 'via')
  284. article1 = App.TicketArticle.find(1);
  285. console.log('article1', article1)
  286. assert.equal(article1.recipientName(), 'Nicole Braun');
  287. article2 = App.TicketArticle.find(2);
  288. assert.equal(article2.recipientName(), 'Test Admin Agent via Zammad Helpdesk');
  289. App.Config.set('ticket_define_email_from', 'SystemAddressName')
  290. App.Config.set('ticket_define_email_from_separator', 'via')
  291. article1 = App.TicketArticle.find(1);
  292. assert.equal(article1.recipientName(), 'Nicole Braun');
  293. article2 = App.TicketArticle.find(2);
  294. assert.equal(article2.recipientName(), 'Zammad Helpdesk');
  295. App.Config.set('ticket_define_email_from', 'AgentName')
  296. App.Config.set('ticket_define_email_from_separator', 'via')
  297. article1 = App.TicketArticle.find(1);
  298. assert.equal(article1.recipientName(), 'Nicole Braun');
  299. article2 = App.TicketArticle.find(2);
  300. assert.equal(article2.recipientName(), 'Test Admin Agent');
  301. });
  302. }