Skip to content

Commit 70c4642

Browse files
committed
prevent double assignment on topic creation
1 parent a7491b3 commit 70c4642

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

plugin.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,17 @@ module ::CommunityCustomFields
4242
on(:topic_created) do |topic, _opts, user|
4343
next unless topic.archetype == "regular" && user.id > 0
4444

45-
topic.custom_fields[:assignee_id] = 0
4645
topic.custom_fields[:status] = "new"
47-
topic.custom_fields[:waiting_since] = Time.now.utc
46+
topic.custom_fields[:waiting_since] = Time.now.utc.iso8601
4847
topic.custom_fields[:waiting_id] = user.id
4948
topic.save_custom_fields
5049
end
5150

5251
on(:post_created) do |post, _opts, user|
53-
next unless post.archetype == "regular" && user.id > 0 && post.post_type == 1
52+
next unless post.archetype == "regular"
53+
next unless post.post_type == 1
54+
next if post.post_number == 1
55+
next if user.id < 0
5456

5557
topic = post.topic
5658

@@ -59,7 +61,7 @@ module ::CommunityCustomFields
5961
topic.custom_fields[:waiting_id] = nil
6062
else
6163
if user.id != topic.custom_fields[:waiting_id]
62-
topic.custom_fields[:waiting_since] = Time.now.utc
64+
topic.custom_fields[:waiting_since] = Time.now.utc.iso8601
6365
topic.custom_fields[:waiting_id] = user.id
6466
end
6567

0 commit comments

Comments
 (0)