Skip to content

Commit b141ec3

Browse files
committed
prevent admin topic from setting waiting_since
1 parent a028869 commit b141ec3

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

plugin.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,24 @@ module ::CommunityCustomFields
4040
end
4141

4242
on(:topic_created) do |topic, _opts, user|
43-
next unless topic.archetype == "regular" && user.id > 0
43+
next if topic.archetype != "regular"
44+
next if user.id < 0
4445

4546
topic.custom_fields[:status] = "new"
46-
topic.custom_fields[:waiting_since] = Time.now.utc.iso8601
47-
topic.custom_fields[:waiting_id] = user.id
47+
48+
if (!user.admin) {
49+
topic.custom_fields[:waiting_since] = Time.now.utc.iso8601
50+
topic.custom_fields[:waiting_id] = user.id
51+
}
52+
4853
topic.save_custom_fields
4954
end
5055

5156
on(:post_created) do |post, _opts, user|
52-
next unless post.archetype == "regular"
53-
next unless post.post_type == 1
54-
next if post.post_number == 1
57+
next if post.archetype != "regular"
5558
next if user.id < 0
59+
next if post.post_type != 1
60+
next if post.post_number == 1
5661

5762
topic = post.topic
5863

0 commit comments

Comments
 (0)