Skip to content

Add category moderation groups and more attributes to generic importer #32561

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

RubenOussoren
Copy link
Contributor

This PR improves the generic bulk import and base scripts by adding support for several previously unimplemented features and attributes:

  • Category Moderation Groups: Implements the import of group-based moderation settings for categories.
  • Group Attributes: Adds import support for public_admission, public_exit, allow_membership_requests, and assignable_level.
  • User Attributes: Adds import support for trust_level and primary_group_id.
  • User Option: Adds import support for the hide_profile_and_presence user option.
  • Multiple Tag Groups per Tag: Updates tag import logic to handle tags belonging to multiple tag groups.

@RubenOussoren RubenOussoren requested a review from s3lase May 2, 2025 15:25
@RubenOussoren RubenOussoren self-assigned this May 2, 2025
@RubenOussoren RubenOussoren requested a review from a team as a code owner May 2, 2025 15:25
@github-actions github-actions bot added the migrations-tooling PR which includes changes to migrations tooling label May 2, 2025
@@ -562,6 +631,7 @@ def import_user_options
email_level: row["email_level"],
email_messages_level: row["email_messages_level"],
email_digests: row["email_digests"],
hide_profile_and_presence: row["hide_profile_and_presence"] || false,
Copy link
Contributor

Choose a reason for hiding this comment

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

There seems to be some work to make this setting more granular by splitting it into hide_profile and hide_presence, but hide_profile_and_presence still appears to be kept in sync as follows:

def update_hide_profile_and_presence
if hide_profile_changed? || hide_presence_changed?
self.hide_profile_and_presence = hide_profile || hide_presence
elsif hide_profile_and_presence_changed?
self.hide_profile = hide_profile_and_presence
self.hide_presence = hide_profile_and_presence
end
end

Simply setting hide_profile_and_presence might be problematic. You could:

  1. Set both hide_profile and hide_presence to the value of hide_profile_and_presence, if it’s explicitly provided in process_user_options
  2. Update the converter framework to support to also support hide_profile and hide_presence and replicate the logic above to keep them in sync

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made a couple of updates here. Let me know if this would work? This is actually not used in the converter. It was due to an error that was caused during the import that requested this to be added if I remember correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the error:

ERROR:  null value in column "hide_profile_and_presence" of relation "user_options" violates not-null constraint

@RubenOussoren RubenOussoren requested review from s3lase and gschlager May 29, 2025 21:11
@RubenOussoren RubenOussoren force-pushed the dev/import-additional-permissions-with-fixes branch from 979c141 to 016ca7a Compare May 29, 2025 21:35
@@ -1225,6 +1243,7 @@ def process_group(group)

group[:created_at] ||= NOW
group[:updated_at] ||= group[:created_at]
group[:assignable_level] ||= Group::ALIAS_LEVELS[:nobody] if @assign_plugin_enabled
Copy link
Member

Choose a reason for hiding this comment

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

I think it's safe to set this unconditionally. There's no need for @assign_plugin_enabled in that case. A comment might be enough.

visibility_level: row["visibility_level"],
members_visibility_level: row["members_visibility_level"],
mentionable_level: row["mentionable_level"],
messageable_level: row["messageable_level"],
}
group_data[:assignable_level] = row["assignable_level"] if defined?(::DiscourseAssign)
Copy link
Member

Choose a reason for hiding this comment

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

You can remove the condition here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migrations-tooling PR which includes changes to migrations tooling
Development

Successfully merging this pull request may close these issues.

3 participants