FEATURE: automatically sync "move to inbox" / "archive" state on messages

This commit is contained in:
Sam Saffron
2016-02-07 23:39:07 +11:00
parent d456150bb2
commit b0567f9c62
6 changed files with 48 additions and 12 deletions

View File

@@ -276,8 +276,13 @@ class PostCreator
def unarchive_message
return unless @topic.private_message? && @topic.id
UserArchivedMessage.where(topic_id: @topic.id).destroy_all
GroupArchivedMessage.where(topic_id: @topic.id).destroy_all
UserArchivedMessage.where(topic_id: @topic.id).pluck(:user_id).each do |user_id|
UserArchivedMessage.move_to_inbox!(user_id, @topic.id)
end
GroupArchivedMessage.where(topic_id: @topic.id).pluck(:group_id).each do |group_id|
GroupArchivedMessage.move_to_inbox!(group_id, @topic.id)
end
end
private