@@ -13,14 +13,16 @@ module ::CommunityCustomFields
13
13
CUSTOM_FIELDS = {
14
14
assignee_id : :integer ,
15
15
first_assigned_to_id : :integer ,
16
- first_assigned_at : :datetime ,
16
+ first_assigned_at : :datetime ,
17
+ last_assigned_to_id : :integer ,
17
18
last_assigned_at : :datetime ,
18
- last_action_by_assignee_at : :datetime ,
19
19
priority : :string ,
20
20
product_area : :string ,
21
21
status : :string ,
22
+ outcome : :string ,
22
23
snoozed_until : :datetime ,
23
- waiting_since : :datetime
24
+ waiting_since : :datetime ,
25
+ waiting_id : :integer
24
26
}
25
27
end
26
28
@@ -43,23 +45,30 @@ module ::CommunityCustomFields
43
45
topic . custom_fields [ :assignee_id ] = 0
44
46
topic . custom_fields [ :status ] = "new"
45
47
topic . custom_fields [ :waiting_since ] = Time . now . utc
48
+ topic . custom_fields [ :waiting_id ] = user . id
46
49
topic . save_custom_fields
47
50
end
48
51
49
52
on ( :post_created ) do |post , _opts , user |
50
- next unless post . archetype == "regular" && post . post_type == 1 && user . id > 0
53
+ next unless post . archetype == "regular" && user . id > 0 && post . post_type == 1
51
54
52
55
topic = post . topic
53
56
54
57
if user . admin
55
- # check if user is an admin and update the `waiting_since` field, if so
56
- topic . custom_fields [ :waiting_since ] = Time . now . utc
57
- topic . save_custom_fields
58
- elsif topic . custom_fields [ :status ] == "snoozed"
59
- # check if new post belongs to a snoozed topic and update status
60
- topic . custom_fields [ :status ] = "open"
61
- topic . custom_fields [ :snoozed_until ] = nil
62
- topic . save_custom_fields
58
+ topic . custom_fields [ :waiting_since ] = nil
59
+ topic . custom_fields [ :waiting_id ] = nil
60
+ else
61
+ if user . id != topic . custom_fields [ :waiting_id ]
62
+ topic . custom_fields [ :waiting_since ] = Time . now . utc
63
+ topic . custom_fields [ :waiting_id ] = user . id
64
+ end
65
+
66
+ if topic . custom_fields [ :status ] == "snoozed"
67
+ topic . custom_fields [ :status ] = "open"
68
+ topic . custom_fields [ :snoozed_until ] = nil
69
+ end
63
70
end
71
+
72
+ topic . save_custom_fields
64
73
end
65
74
end
0 commit comments