Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Set topic subtype when embedding topics #198

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

megothss
Copy link
Contributor

@megothss megothss commented Apr 4, 2024

This commit registers a modifier to set the subtype of a topic to Topic::POST_VOTING_SUBTYPE during the embedding process when certain conditions are met:

  • a new topic is being created;
  • the topic will be saved to a valid category;
  • the category has either create_as_post_voting_default or only_post_voting_in_this_category set to true

This PR requires discourse/discourse#26527 to be merged in core. DO NOT MERGE before that.

This commit registers a modifier to set the subtype of a topic to `Topic::POST_VOTING_SUBTYPE` during the embedding process when certain conditions are met:

- a new topic is being created;
- the topic will be saved to a valid category;
- the category has either `create_as_post_voting_default` or
`only_post_voting_in_this_category` set to `true`
Copy link
Contributor

@markvanlan markvanlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

plugin.rb Outdated
@@ -190,6 +190,20 @@ module ::PostVoting
false
end

register_modifier(:topic_embed_import_create_args) do |args|
category_id = args[:category]
return args unless category_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda thought these returns had to be nexts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

@megothss megothss merged commit c4c1063 into main Apr 8, 2024
5 checks passed
@megothss megothss deleted the fix/set-subtype-when-embedding-topics branch April 8, 2024 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants