Skip to content

A platform for community discussion. Free, open, simple.

DEV: Move discourse-policy to core (#33749)

Jarek Radosza64f22e72e89
diff --git a/.github/labeler.yml b/.github/labeler.yml
index bd86fe18f50..1041fd1cad8 100644
--- a/.github/labeler.yml
+++ b/.github/labeler.yml
@@ -110,6 +110,10 @@ discourse-calendar:
- changed-files:
- any-glob-to-any-file: plugins/discourse-calendar/**/*
+discourse-policy:
+ - changed-files:
+ - any-glob-to-any-file: plugins/discourse-policy/**/*
+
footnote:
- changed-files:
- any-glob-to-any-file: plugins/footnote/**/*
diff --git a/.gitignore b/.gitignore
index 57770038dd3..3c5cc1db61f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -70,6 +70,7 @@
!/plugins/discourse-hcaptcha
!/plugins/discourse-gamification
!/plugins/discourse-calendar
+!/plugins/discourse-policy
/plugins/*/auto_generated
/spec/fixtures/plugins/my_plugin/auto_generated
diff --git a/plugins/discourse-policy/README.md b/plugins/discourse-policy/README.md
new file mode 100644
index 00000000000..111a120e5a7
--- /dev/null
+++ b/plugins/discourse-policy/README.md
@@ -0,0 +1,5 @@
+# Discourse Policy Plugin
+
+Confirm your users have seen or done something with reminders
+
+For more information, please see: https://meta.discourse.org/t/discourse-policy/88557
diff --git a/plugins/discourse-policy/app/controllers/policy_controller.rb b/plugins/discourse-policy/app/controllers/policy_controller.rb
new file mode 100644
index 00000000000..e66b61d001c
--- /dev/null
+++ b/plugins/discourse-policy/app/controllers/policy_controller.rb
@@ -0,0 +1,107 @@
+# frozen_string_literal: true
+
+class DiscoursePolicy::PolicyController < ::ApplicationController
+ requires_plugin DiscoursePolicy::PLUGIN_NAME
+
+ before_action :ensure_logged_in, :set_post
+ before_action :ensure_can_accept, only: %i[accept unaccept]
+
+ def accept
+ PolicyUser.add!(current_user, @post.post_policy)
+ @post.publish_change_to_clients!(:policy_change)
+
+ if @post.post_policy.add_users_to_group.present?
+ @post.post_policy.add_users_group.add(current_user)
+ end
+
+ render json: success_json
+ end
+
+ def unaccept
+ PolicyUser.remove!(current_user, @post.post_policy)
+ @post.publish_change_to_clients!(:policy_change)
+
+ if @post.post_policy.add_users_to_group.present?
+ @post.post_policy.add_users_group.remove(current_user)
+ end
+
+ render json: success_json
+ end
+
+ def accepted
+ # Check if user has permission to see group members
+ groups = @post.post_policy.groups
+ return render_json_error(I18n.t("discourse_policy.errors.group_not_found")) if groups.blank?
+
+ guardian = Guardian.new(current_user)
+ unless guardian.can_see_groups_members?(groups)
+ return render_json_error(I18n.t("discourse_policy.error.no_permission"))
+ end
+
+ users =
+ @post
+ .post_policy
+ .accepted_by
+ .offset(params[:offset])
+ .limit(DiscoursePolicy::POLICY_USER_DEFAULT_LIMIT)
+
+ render json: { users: serialize_data(users, BasicUserSerializer) }
+ end
+
+ def not_accepted
+ @post = Post.find(params[:post_id])
+
+ # Check if user has permission to see group members
+ groups = @post.post_policy.groups
+ return render_json_error(I18n.t("discourse_policy.errors.group_not_found")) if groups.blank?
+
+ guardian = Guardian.new(current_user)
+ unless guardian.can_see_groups_members?(groups)
+ return render_json_error(I18n.t("discourse_policy.error.no_permission"))
+ end
+
+ users =
+ @post
+ .post_policy
+ .not_accepted_by
+ .offset(params[:offset])
+ .limit(DiscoursePolicy::POLICY_USER_DEFAULT_LIMIT)
+
+ render json: { users: serialize_data(users, BasicUserSerializer) }
+ end
+
+ private
+
+ def ensure_can_accept
+ if !GroupUser.where(
+ "group_id in (:group_ids) and user_id = :user_id",
+ group_ids: @group_ids,
+ user_id: current_user.id,
+ ).exists?
+ return render_json_error(I18n.t("discourse_policy.errors.user_missing"))
+ end
+
+ true
+ end
+
+ def set_post
+ raise Discourse::NotFound if !SiteSetting.policy_enabled
+
+ params.require(:post_id)
+ @post = Post.find_by(id: params[:post_id])
+
+ raise Discourse::NotFound if !@post
+
+ return render_json_error(I18n.t("discourse_policy.errors.no_policy")) if [email protected]_policy
+
+ @group_ids = @post.post_policy.groups.pluck(:id)
+
+ return render_json_error(I18n.t("discourse_policy.errors.group_not_found")) if @group_ids.blank?
+
+ if SiteSetting.policy_restrict_to_staff_posts && [email protected]&.staff?
+ return render_json_error(I18n.t("discourse_policy.errors.staff_only"))
+ end
+
+ true
+ end
+end
diff --git a/plugins/discourse-policy/app/models/policy_user.rb b/plugins/discourse-policy/app/models/policy_user.rb
new file mode 100644
index 00000000000..6db65cfc934
--- /dev/null
+++ b/plugins/discourse-policy/app/models/policy_user.rb
@@ -0,0 +1,61 @@
+# frozen_string_literal: true
+
+class PolicyUser < ActiveRecord::Base
+ belongs_to :post_policy
+ belongs_to :user
+
+ scope :accepted, -> { where.not(accepted_at: nil).where(revoked_at: nil, expired_at: nil) }
+ scope :revoked, -> { where.not(revoked_at: nil).where(accepted_at: nil, expired_at: nil) }
+ scope :with_version, ->(version) { where(version: version) }
+
+ def self.add!(user, post_policy)
+ post_policy
+ .policy_users
+ .revoked
+ .with_version(post_policy.version)
+ .where(user: user)
+ .update_all(accepted_at: Time.zone.now)
+
+ self.create!(
+ post_policy_id: post_policy.id,
+ user_id: user.id,
+ accepted_at: Time.zone.now,
+ version: post_policy.version,
+ )
+ end
+
+ def self.remove!(user, post_policy)
+ post_policy
+ .policy_users
+ .accepted
+ .with_version(post_policy.version)
+ .where(user: user)
+ .update_all(revoked_at: Time.zone.now)
+
+ self.create!(
+ post_policy_id: post_policy.id,
+ user_id: user.id,
+ revoked_at: Time.zone.now,
+ version: post_policy.version,
+ )
+ end
+end
+
+# == Schema Information
+#
+# Table name: policy_users
+#
+# id :bigint not null, primary key
+# post_policy_id :bigint not null
+# user_id :integer not null
+# accepted_at :datetime
+# revoked_at :datetime
+# expired_at :datetime
+# version :string
+# created_at :datetime not null
+# updated_at :datetime not null
+#
+# Indexes
+#
+# index_policy_users_on_post_policy_id_and_user_id (post_policy_id,user_id)
+#
diff --git a/plugins/discourse-policy/app/models/post_policy.rb b/plugins/discourse-policy/app/models/post_policy.rb
new file mode 100644
index 00000000000..8113330e9d8
--- /dev/null
+++ b/plugins/discourse-policy/app/models/post_policy.rb
@@ -0,0 +1,135 @@
+# frozen_string_literal: true
+
+class PostPolicy < ActiveRecord::Base
+ self.ignored_columns = [
+ "group_id", # TODO (sam) (2023-01-01) remove
+ ]
+
+ belongs_to :post
+
+ has_many :post_policy_groups, dependent: :destroy
+ has_many :groups, through: :post_policy_groups
+ has_many :policy_users
+
+ enum :renew_interval, { monthly: 0, quarterly: 1, yearly: 2 }
+
+ before_save :bump_policy
+
+ def accepted_by
+ return User.none if !groups.exists?
+
+ User.activated.not_suspended.where(id: accepted_policy_users.select(:user_id)).order(:id)
+ end
+
+ def revoked_by
+ return User.none if !groups.exists?
+
+ User.activated.not_suspended.where(id: revoked_policy_users.select(:user_id)).order(:id)
+ end
+
+ def not_accepted_by
+ return User.none if !groups.exists?
+
+ policy_group_users(should_order: false).where.not(id: accepted_policy_users.select(:user_id))
+ end
+
+ def emailed_by
+ return User.none unless groups.exists?
+
+ emails_enabled_users.where.not(id: accepted_policy_users.select(:user_id))
+ end
+
+ def emailed_by_always
+ return User.none unless groups.exists?
+
+ emails_enabled_always_users.where.not(id: accepted_policy_users.select(:user_id))
+ end
+
+ def emailed_by_when_away
+ return User.none unless groups.exists?
+
+ emails_enabled_when_away_users.where.not(id: accepted_policy_users.select(:user_id))
+ end
+
+ def add_users_group
+ return if add_users_to_group.nil?
+
+ Group.find_by(id: add_users_to_group)
+ end
+
+ def accepted_policy_users
+ policy_users.accepted.with_version(version)
+ end
+
+ private
+
+ def bump_policy
+ self.last_bumped_at = Time.current if version_changed?
+ end
+
+ def emails_enabled_users
+ policy_group_users(should_order: false).joins(:user_option).where(
+ "
+ (user_options.policy_email_frequency = ?)
+ OR (user_options.policy_email_frequency = ? and users.last_seen_at < ?)",
+ UserOption.policy_email_frequencies[:always],
+ UserOption.policy_email_frequencies[:when_away],
+ 10.minutes.ago,
+ )
+ end
+
+ def emails_enabled_always_users
+ policy_group_users.joins(:user_option).where(
+ "user_options.policy_email_frequency = ?",
+ UserOption.policy_email_frequencies[:always],
+ )
+ end
+
+ def emails_enabled_when_away_users
+ policy_group_users
+ .joins(:user_option)
+ .where(
+ "user_options.policy_email_frequency = ?",
+ UserOption.policy_email_frequencies[:when_away],
+ )
+ .where("users.last_seen_at < ?", 10.minutes.ago)
+ end
+
+ def revoked_policy_users
+ policy_users.revoked.with_version(version)
+ end
+
+ def policy_group_users(should_order: true)
+ query =
+ User
+ .activated
+ .not_suspended
+ .joins(:group_users)
+ .joins("JOIN post_policy_groups on post_policy_groups.group_id = group_users.group_id")
+ .where("post_policy_groups.post_policy_id = ?", id)
+ .distinct
+
+ query = query.order(:id) if should_order
+ query
+ end
+end
+
+# == Schema Information
+#
+# Table name: post_policies
+#
+# id :bigint not null, primary key
+# post_id :bigint not null
+# renew_start :datetime
+# renew_days :integer
+# next_renew_at :datetime
+# reminder :string
+# last_reminded_at :datetime
+# version :string
+# created_at :datetime not null
+# updated_at :datetime not null
+# renew_interval :integer
+# private :boolean default(FALSE), not null
+# last_bumped_at :datetime
+# add_users_to_group :integer
+#
diff --git a/plugins/discourse-policy/app/models/post_policy_group.rb b/plugins/discourse-policy/app/models/post_policy_group.rb
new file mode 100644
index 00000000000..5eed055e55d
--- /dev/null
+++ b/plugins/discourse-policy/app/models/post_policy_group.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class PostPolicyGroup < ActiveRecord::Base
+ belongs_to :group
+ belongs_to :post_policy
+end
+
+# == Schema Information
+#
+# Table name: post_policy_groups
+#
+# id :bigint not null, primary key
+# group_id :integer not null
+# post_policy_id :bigint not null
+# created_at :datetime not null
+# updated_at :datetime not null
+#
+# Indexes
+#
+# index_post_policy_groups_on_post_policy_id_and_group_id (post_policy_id,group_id) UNIQUE
+#
diff --git a/plugins/discourse-policy/app/views/connectors/unsubscribe_options/policy_email_frequencies.html.erb b/plugins/discourse-policy/app/views/connectors/unsubscribe_options/policy_email_frequencies.html.erb
new file mode 100644
index 00000000000..3c5e754cb80
--- /dev/null
+++ b/plugins/discourse-policy/app/views/connectors/unsubscribe_options/policy_email_frequencies.html.erb
@@ -0,0 +1,10 @@
+<% if @policy_email_frequencies %>
+ <p>
+ <label><%= t 'unsubscribe.policy_emails.select_title' %></label>
+ <%=
+ select_tag :policy_email_frequency,
+ options_for_select(@policy_email_frequencies, @current_policy_email_frequency),
+ class: 'combobox'
+ %>
+ </p>
+<% end %>
diff --git a/plugins/discourse-policy/app/views/user_notifications/policy_email.html.erb b/plugins/discourse-policy/app/views/user_notifications/policy_email.html.erb
new file mode 100644
index 00000000000..83681523434
--- /dev/null
+++ b/plugins/discourse-policy/app/views/user_notifications/policy_email.html.erb
@@ -0,0 +1,29 @@
+<div id='main' class=<%= @classes %>>
+ <% if SiteSetting.private_email? %>
+ <p><%= t('system_messages.contents_hidden') %></p>
+ <% else %>
+ <%= render partial: 'email/post', locals: { post: @post, use_excerpt: SiteSetting.post_excerpts_in_emails } %>
+ <% end %>
+
+ <hr>
+ <div class='footer undecorated-link-footer <%= @first_footer_classes %>'>
+ <p>
+ <%= raw(t 'user_notifications.policy_email.visit_link_to_respond',
+ visit_topic_link: link_to(t('user_notifications.policy_email.visit_topic'), "#{Discourse.base_url}#{@post.url(without_slug: SiteSetting.private_email?)}")) %>
+ </p>
+ </div>
+ <div class='footer'>
+ <p>
+ <%= raw(t 'user_notifications.policy_email.unsubscribe',
+ email_preferences_link: link_to(t('user_notifications.policy_email.your_policy_email_settings'), @preferences_path),
+ unsubscribe_link: link_to(t('user_notifications.digest.click_here'), @unsubscribe_link)) %>
+ </p>
+ </div>
+</div>
+
+<div itemscope itemtype="http://schema.org/EmailMessage" style="display:none">
+ <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
+ <link itemprop="url" href="<%= Discourse.base_url %><%= @post.url(without_slug: SiteSetting.private_email?) %>" />
+ <meta itemprop="name" content="<%= t 'read_full_topic' %>"/>
+ </div>
+</div>
diff --git a/plugins/discourse-policy/app/views/user_notifications/policy_email.text.erb b/plugins/discourse-policy/app/views/user_notifications/policy_email.text.erb
new file mode 100644
index 00000000000..d7bdb21060e
--- /dev/null
+++ b/plugins/discourse-policy/app/views/user_notifications/policy_email.text.erb
@@ -0,0 +1,16 @@
+<%- site_link = raw(@markdown_linker.create(@site_name, '/')) %>
+
+<% if SiteSetting.private_email? %>
+<%= t('system_messages.contents_hidden') %>
+<% else %>
+<%= format_for_email(@post, true) %>
+<% end %>
+
+<%= raw(t 'user_notifications.policy_email.visit_link_to_respond',
+ visit_topic_link: @markdown_linker.create(t('user_notifications.policy_email.visit_topic'), "#{Discourse.base_url}#{@post.url(without_slug: SiteSetting.private_email?)}")) %>
+
+<%= raw(t 'user_notifications.policy_email.unsubscribe',
+ email_preferences_link: @markdown_linker.create(t('user_notifications.policy_email.your_policy_email_settings'), @preferences_path),
+ unsubscribe_link: @markdown_linker.create(t('user_notifications.digest.click_here'), @unsubscribe_link)) %>
+
+<%= raw(@markdown_linker.references) %>
diff --git a/plugins/discourse-policy/assets/javascripts/discourse/components/modal/policy-builder.gjs b/plugins/discourse-policy/assets/javascripts/discourse/components/modal/policy-builder.gjs
new file mode 100644
index 00000000000..d898deda007
--- /dev/null
+++ b/plugins/discourse-policy/assets/javascripts/discourse/components/modal/policy-builder.gjs
@@ -0,0 +1,129 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { fn } from "@ember/helper";
+import { action, set } from "@ember/object";
+import { isBlank, isPresent } from "@ember/utils";
+import { TrackedObject } from "@ember-compat/tracked-built-ins";
+import DButton from "discourse/components/d-button";
+import DModal from "discourse/components/d-modal";
+import { ajax } from "discourse/lib/ajax";
+import { cook } from "discourse/lib/text";
+import { i18n } from "discourse-i18n";
+import PolicyBuilderForm from "../policy-builder-form";
+
+export default class PolicyBuilder extends Component {
+ @tracked isSaving = false;
+ @tracked flash;
+ policy =
+ this.args.model.policy || new TrackedObject({ reminder: null, version: 1 });
+
+ @action
+ insertPolicy() {
+ if (!this.validateForm()) {
+ return;
+ }
+
+ this.args.model.toolbarEvent?.addText(
+ "\n\n" +
+ `[policy ${this.markdownParams}]\n${i18n(
+ "discourse_policy.accept_policy_template"
+ )}\n[/policy]` +
+ "\n\n"
+ );
+ this.args.closeModal();
+ }
+
+ @action
+ async updatePolicy() {
+ if (!this.validateForm()) {
+ return;
+ }
+
+ this.isSaving = true;
+
+ try {
+ const result = await ajax(`/posts/${this.args.model.post.id}`);
+ const newRaw = this.replaceRaw(result.raw);
+
+ if (newRaw) {
+ this.args.model.post.save({
+ raw: newRaw,
+ cooked: (await cook(result.raw)).toString(),
+ edit_reason: i18n("discourse_policy.edit_reason"),
+ });
+ }
+ } finally {
+ this.isSaving = false;
+ this.args.closeModal();
+ }
+ }
+
+ get markdownParams() {
+ const markdownParams = [];
+ for (const [key, value] of Object.entries(this.policy)) {
+ if (isPresent(value)) {
+ markdownParams.push(`${key}="${value}"`);
+ }
+ }
+ return markdownParams.join(" ");
+ }
+
+ replaceRaw(raw) {
+ const policyRegex = new RegExp(`\\[policy\\s(.*?)\\]`, "m");
+ const policyMatches = raw.match(policyRegex);
+
+ if (policyMatches?.[1]) {
+ return raw.replace(policyRegex, `[policy ${this.markdownParams}]`);
+ }
+
+ return false;
+ }
+
+ validateForm() {
+ if (isBlank(this.policy.groups)) {
+ this.flash = i18n("discourse_policy.builder.errors.group");
+ return false;
+ }
+
+ if (isBlank(this.policy.version)) {
+ this.flash = i18n("discourse_policy.builder.errors.version");
+ return false;
+ }
+
+ return true;
+ }
+
+ <template>
+ <DModal
+ @title={{i18n "discourse_policy.builder.title"}}
+ @closeModal={{@closeModal}}
+ @flash={{this.flash}}
+ @flashType="error"
+ class="policy-builder"
+ >
+ <:body>
+ <PolicyBuilderForm
+ @policy={{this.policy}}
+ @onChange={{fn set this.policy}}
+ />
+ </:body>
+
+ <:footer>
+ {{#if @model.insertMode}}
+ <DButton
+ @label="discourse_policy.builder.insert"
+ @action={{this.insertPolicy}}
+ class="btn-primary"
+ />
+ {{else}}
+ <DButton
+ @label="discourse_policy.builder.save"
+ @action={{this.updatePolicy}}
+ @isLoading={{this.isSaving}}
+ class="btn-primary"
+ />
+ {{/if}}
+ </:footer>
+ </DModal>
+ </template>
+}
diff --git a/plugins/discourse-policy/assets/javascripts/discourse/components/policy-builder-form.gjs b/plugins/discourse-policy/assets/javascripts/discourse/components/policy-builder-form.gjs
new file mode 100644
index 00000000000..19cd5ce21ce
--- /dev/null
+++ b/plugins/discourse-policy/assets/javascripts/discourse/components/policy-builder-form.gjs
@@ -0,0 +1,97 @@
+import Component from "@glimmer/component";
+import { fn } from "@ember/helper";
+import { on } from "@ember/modifier";
+import { action, get } from "@ember/object";
+import PolicyFormField from "./policy-form-field";
+import PolicyGroupInput from "./policy-group-input";
+import PolicyReminderInput from "./policy-reminder-input";
+
+export default class PolicyBuilderForm extends Component {
+ @action
+ changeValue(field, event) {
+ this.args.onChange(field, event.target.value);
+ }
+
+ @action
+ changeBoolValue(field, event) {
+ this.args.onChange(field, event.target.checked);
+ }
+
+ <template>
+ <PolicyFormField @name="groups" @required={{true}}>
+ <PolicyGroupInput
+ @groups={{@policy.groups}}
+ @onChangeGroup={{fn @onChange "groups"}}
+ />
+ </PolicyFormField>
+
+ <PolicyFormField @name="version" @required={{true}}>
+ <input
+ name="version"
+ type="number"
+ value={{readonly @policy.version}}
+ {{on "input" (fn this.changeValue "version")}}
+ />
+ </PolicyFormField>
+
+ <PolicyFormField @name="renew">
+ <input
+ name="renew"
+ type="number"
+ value={{readonly @policy.renew}}
+ {{on "input" (fn this.changeValue "renew")}}
+ />
+ </PolicyFormField>
+
+ <PolicyFormField @name="renew-start">
+ <input
+ type="date"
+ placeholder="2020-03-31"
+ name="renew-start"
+ value={{readonly (get @policy "renew-start")}}
+ {{on "input" (fn this.changeValue "renew-start")}}
+ />
+ </PolicyFormField>
+
+ <PolicyFormField @name="reminder">
+ <PolicyReminderInput
+ @reminder={{@policy.reminder}}
+ @onChangeReminder={{fn @onChange "reminder"}}
+ />
+ </PolicyFormField>
+
+ <PolicyFormField @name="accept">
+ <input
+ type="text"
+ name="accept"
+ value={{readonly @policy.accept}}
+ {{on "input" (fn this.changeValue "accept")}}
+ />
+ </PolicyFormField>
+
+ <PolicyFormField @name="revoke">
+ <input
+ type="text"
+ name="revoke"
+ value={{readonly @policy.revoke}}
+ {{on "input" (fn this.changeValue "revoke")}}
+ />
+ </PolicyFormField>
+
+ <PolicyFormField @name="add-users-to-group">
+ <PolicyGroupInput
+ @groups={{get @policy "add-users-to-group"}}
+ @onChangeGroup={{fn @onChange "add-users-to-group"}}
+ />
+ </PolicyFormField>
+
+ <PolicyFormField @name="private">
+ <input
+ type="checkbox"
+ name="private"
+ checked={{readonly @policy.private}}
+ {{on "click" (fn this.changeBoolValue "private")}}
+ />
+ </PolicyFormField>
+ </template>
+}
diff --git a/plugins/discourse-policy/assets/javascripts/discourse/components/policy-form-field.gjs b/plugins/discourse-policy/assets/javascripts/discourse/components/policy-form-field.gjs
new file mode 100644
index 00000000000..a87a357da97
--- /dev/null
+++ b/plugins/discourse-policy/assets/javascripts/discourse/components/policy-form-field.gjs
@@ -0,0 +1,27 @@
+import { concat } from "@ember/helper";
+import { i18n } from "discourse-i18n";
+
+const PolicyFormFields = <template>
+ <div class="policy-field {{@name}}">
+ <div class="policy-field-label">
+ <span class="label">
+ {{i18n (concat "discourse_policy.builder." @name ".label")}}
+ {{#if @required}}
+ <span class="required-field">*</span>
+ {{/if}}
+ </span>
+ </div>
+
+ <div class="policy-field-control">
+ {{yield}}
+ </div>
+
+ <span class="policy-field-description">
+ <span class="description">
+ {{i18n (concat "discourse_policy.builder." @name ".description")}}
+ </span>
+ </span>
+ </div>
+</template>;
+
+export default PolicyFormFields;
diff --git a/plugins/discourse-policy/assets/javascripts/discourse/components/policy-group-input.gjs b/plugins/discourse-policy/assets/javascripts/discourse/components/policy-group-input.gjs
new file mode 100644
index 00000000000..1d125c54d55
--- /dev/null
+++ b/plugins/discourse-policy/assets/javascripts/discourse/components/policy-group-input.gjs
@@ -0,0 +1,36 @@
+import Component from "@glimmer/component";
+import { action } from "@ember/object";
+import { service } from "@ember/service";
+import GroupChooser from "select-kit/components/group-chooser";
+
+export default class PolicyGroupInput extends Component {
+ @service site;
+
+ get selectedGroups() {
+ return (this.args.groups || "").split(",").filter(Boolean);
+ }
+
+ get availableGroups() {
+ return (this.site.groups || [])
+ .map((g) =>
+ // prevents group "everyone" to be listed
+ g.id === 0 ? null : g.name
+ )
+ .filter(Boolean);
+ }
+
+ @action
+ onChange(values) {
+ this.args.onChangeGroup?.(values.join(","));
+ }
+
+ <template>
+ <GroupChooser
+ @content={{this.availableGroups}}
+ @valueProperty={{null}}
+ @nameProperty={{null}}
+ @value={{this.selectedGroups}}
+ @onChange={{this.onChange}}
+ />
+ </template>
+}
diff --git a/plugins/discourse-policy/assets/javascripts/discourse/components/policy-reminder-input.gjs b/plugins/discourse-policy/assets/javascripts/discourse/components/policy-reminder-input.gjs
new file mode 100644
index 00000000000..3c5c05b2d65
--- /dev/null
+++ b/plugins/discourse-policy/assets/javascripts/discourse/components/policy-reminder-input.gjs
@@ -0,0 +1,25 @@
+import { hash } from "@ember/helper";
+import { i18n } from "discourse-i18n";
+import ComboBox from "select-kit/components/combo-box";
+
+const VALID_REMINDERS = [
+ {
+ id: "daily",
+ name: i18n("daily"),
+ },
+ {
+ id: "weekly",
+ name: i18n("weekly"),
+ },
+];
+
+const PolicyReminderInput = <template>
+ <ComboBox
+ @value={{@reminder}}
+ @content={{VALID_REMINDERS}}
+ @options={{hash none="discourse_policy.builder.reminder.no_reminder"}}
+ @onChange={{@onChangeReminder}}
+ />
+</template>;
+
+export default PolicyReminderInput;
diff --git a/plugins/discourse-policy/assets/javascripts/discourse/components/post-policy.gjs b/plugins/discourse-policy/assets/javascripts/discourse/components/post-policy.gjs
new file mode 100644
index 00000000000..31d6196505a
--- /dev/null
+++ b/plugins/discourse-policy/assets/javascripts/discourse/components/post-policy.gjs
@@ -0,0 +1,375 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { on } from "@ember/modifier";
+import { action } from "@ember/object";
+import { service } from "@ember/service";
+import { and, not } from "truth-helpers";
+import DButton from "discourse/components/d-button";
+import avatar from "discourse/helpers/bound-avatar-template";
+import icon from "discourse/helpers/d-icon";
+import { ajax } from "discourse/lib/ajax";
+import { popupAjaxError } from "discourse/lib/ajax-error";
+import { bind } from "discourse/lib/decorators";
+import { i18n } from "discourse-i18n";
+import PolicyBuilder from "./modal/policy-builder";
+
+export default class PostPolicy extends Component {
+ @service appEvents;
+ @service currentUser;
+ @service modal;
+
+ @tracked isLoading = false;
+ @tracked showNotAccepted = false;
+
+ constructor() {
+ super(...arguments);
+
+ this.post?.setProperties({
+ policy_accepted_by: this.post?.policy_accepted_by || [],
+ policy_not_accepted_by: this.post?.policy_not_accepted_by || [],
+ });
+
+ this.appEvents.on("policy:changed", this, "policyChanged");
+ }
+
+ willDestroy() {
+ super.willDestroy(...arguments);
+ this.appEvents.off("policy:changed", this, "policyChanged");
+ }
+
+ get post() {
+ return this.args.post;
+ }
+
+ get policy() {
+ return this.args.policy;
+ }
+
+ @bind
+ async policyChanged(data) {
+ if (data.message.id !== this.post.id) {
+ return;
+ }
+
+ const stream = data.controller.get("model.postStream");
+ const post = stream.findLoadedPost(data.message.id);
+
+ if (post) {
+ const result = await ajax(`/posts/${post.id}.json`);
+
+ this.post.setProperties({
+ policy_can_accept: result.policy_can_accept,
+ policy_can_revoke: result.policy_can_revoke,
+ policy_accepted: result.policy_accepted,
+ policy_revoked: result.policy_revoked,
+ policy_not_accepted_by: result.policy_not_accepted_by || [],
+ policy_not_accepted_by_count: result.policy_not_accepted_by_count,
+ policy_accepted_by: result.policy_accepted_by || [],
+ policy_accepted_by_count: result.policy_accepted_by_count,
+ });
+ }
+ }
+
+ get policyHasUsers() {
+ return (
+ (this.post?.policy_not_accepted_by_count ||
+ 0 + this.post?.policy_accepted_by_count ||
+ 0) > 0
+ );
+ }
+
+ get acceptButtonClasses() {
+ let classes = "accept btn-accept-policy";
+ if (!this.post?.policy_accepted || this.post?.policy_revoked) {
+ classes += " btn-primary";
+ }
+ return classes;
+ }
+
+ get revokeButtonClasses() {
+ let classes = "revoke btn-revoke-policy";
+ if (!this.post?.policy_revoked || this.post?.policy_accepted) {
+ classes += " btn-danger";
+ }
+ return classes;
+ }
+
+ get remainingAcceptedUsers() {
+ return (
+ (this.post?.policy_accepted_by_count || 0) -
+ (this.post?.policy_accepted_by || []).length
+ );
+ }
+
+ get acceptedUsers() {
+ return this.post?.policy_accepted_by || [];
+ }
+
+ get remainingNotAcceptedUsers() {
+ return (
+ (this.post?.get("policy_not_accepted_by_count") || 0) -
+ (this.post?.get("policy_not_accepted_by") || []).length
+ );
+ }
+
+ get notAcceptedUsers() {
+ return this.post?.get("policy_not_accepted_by") || [];
+ }
+
+ get canManagePolicy() {
+ return (
+ this.currentUser &&
+ (this.currentUser.staff ||
+ this.currentUser.id === this.post?.get("user_id"))
+ );
+ }
+
+ @action
+ revokePolicy() {
+ this.post.policy_not_accepted_by.pushObject(this.currentUser);
+ this.post.set(
+ "policy_not_accepted_by_count",
+ this.post.policy_not_accepted_by_count + 1
+ );
+
+ const obj = this.post.policy_accepted_by.findBy("id", this.currentUser.id);
+ if (obj) {
+ this.post.policy_accepted_by.removeObject(obj);
+ this.post.set(
+ "policy_accepted_by_count",
+ this.post.policy_accepted_by_count - 1
+ );
+ }
+
+ if (this.post.policy_can_accept !== this.post.policy_can_revoke) {
+ this.post.setProperties({
+ policy_can_accept: true,
+ policy_can_revoke: false,
+ policy_accepted: false,
+ policy_revoked: true,
+ });
+ }
+
+ this._updatePolicy("unaccept", this.post.id);
+ }
+
+ @action
+ acceptPolicy() {
+ this.post.policy_accepted_by.pushObject(this.currentUser);
+ this.post.set(
+ "policy_accepted_by_count",
+ this.post.policy_accepted_by_count + 1
+ );
+
+ const obj = this.post.policy_not_accepted_by.findBy(
+ "id",
+ this.currentUser.id
+ );
+
+ if (obj) {
+ this.post.policy_not_accepted_by.removeObject(obj);
+ this.post.set(
+ "policy_not_accepted_by_count",
+ this.post.policy_not_accepted_by_count - 1
+ );
+ }
+
+ if (this.post.policy_can_accept !== this.post.policy_can_revoke) {
+ this.post.setProperties({
+ policy_can_accept: false,
+ policy_can_revoke: true,
+ policy_accepted: true,
+ policy_revoked: false,
+ });
+ }
+
+ this._updatePolicy("accept", this.post.id);
+ }
+
+ @action
+ async loadRemainingAcceptedUsers(event) {
+ event.preventDefault();
+
+ try {
+ const result = await ajax(`/policy/accepted`, {
+ data: {
+ post_id: this.post.id,
+ offset: this.post.policy_accepted_by.length,
+ },
+ });
+
+ result.users.forEach((user) => {
+ this.post.policy_accepted_by.pushObject(user);
+ });
+ } catch (e) {
+ popupAjaxError(e);
+ }
+ }
+
+ @action
+ async loadRemainingNotAcceptedUsers(event) {
+ event.preventDefault();
+
+ try {
+ const result = await ajax(`/policy/accepted`, {
+ data: {
+ post_id: this.post.id,
+ offset: this.post.policy_not_accepted_by.length,
+ },
+ });
+ result.users.forEach((user) => {
+ this.post.policy_not_accepted_by.pushObject(user);
+ });
+ } catch (e) {
+ popupAjaxError(e);
+ }
+ }
+
+ @action
+ editPolicy() {
+ this.modal.show(PolicyBuilder, {
+ model: {
+ insertMode: false,
+ post: this.post,
+ policy: this.policy,
+ },
+ });
+ }
+
+ @action
+ toggleShowUsers(event) {
+ event.preventDefault();
+ this.showNotAccepted = !this.showNotAccepted;
+ }
+
+ async _updatePolicy(policyAction, id) {
+ this.isLoading = true;
+
+ try {
+ await ajax(`/policy/${policyAction}`, {
+ type: "PUT",
+ data: { post_id: id },
+ });
+ } catch (e) {
+ popupAjaxError(e);
+ } finally {
+ this.isLoading = false;
+ }
+ }
+
+ <template>
+ {{#if this.post}}
+ <div class="policy-footer">
+ <div class="policy-actions">
+ {{#if this.post.policy_can_accept}}
+ <DButton
+ @isLoading={{this.isLoading}}
+ @action={{this.acceptPolicy}}
+ class={{this.acceptButtonClasses}}
+ @translatedLabel={{this.policy.accept}}
+ @icon={{if this.post.policy_accepted "check"}}
+ />
+ {{/if}}
+
+ {{#if this.post.policy_can_revoke}}
+ <DButton
+ @isLoading={{this.isLoading}}
+ @action={{this.revokePolicy}}
+ class={{this.revokeButtonClasses}}
+ @translatedLabel={{this.policy.revoke}}
+ @icon={{if this.post.policy_revoked "check"}}
+ />
+ {{/if}}
+ </div>
+
+ <div class="user-lists">
+ {{#if (and (not this.policyHasUsers) this.post.policy_stats)}}
+ <span class="no-possible-users">
+ {{i18n "discourse_policy.no_possible_users"}}
+ </span>
+ {{/if}}
+
+ {{#if this.post.policy_accepted_by_count}}
+ <a
+ href
+ {{on "click" this.toggleShowUsers}}
+ title={{i18n "discourse_policy.accepted_tooltip"}}
+ class="toggle toggle-accepted"
+ >
+ <span class="user-count">
+ {{this.post.policy_accepted_by_count}}
+ </span>
+ {{icon "user-check"}}
+ </a>
+
+ {{#unless this.showNotAccepted}}
+ {{#if this.acceptedUsers.length}}
+ <div class="users accepted">
+ {{#each this.acceptedUsers as |acceptedUser|}}
+ {{avatar acceptedUser.avatar_template "tiny"}}
+ {{/each}}
+
+ {{#if this.remainingAcceptedUsers}}
+ <a
+ href
+ {{on "click" this.loadRemainingAcceptedUsers}}
+ class="load-more-users"
+ >
+ +
+ {{this.remainingAcceptedUsers}}
+ {{icon "user"}}
+ </a>
+ {{/if}}
+ </div>
+ {{/if}}
+ {{/unless}}
+ {{/if}}
+
+ {{#if this.post.policy_not_accepted_by_count}}
+ <div class="separator"></div>
+
+ <a
+ href
+ {{on "click" this.toggleShowUsers}}
+ title={{i18n "discourse_policy.not_accepted_tooltip"}}
+ class="toggle toggle-not-accepted"
+ >
+ <span class="user-count">
+ {{this.post.policy_not_accepted_by_count}}
+ </span>
+ {{icon "user-xmark"}}
+ </a>
+
+ {{#if this.showNotAccepted}}
+ <div class="users not-accepted">
+ {{#each this.notAcceptedUsers as |notAcceptedUser|}}
+ {{avatar notAcceptedUser.avatar_template "tiny"}}
+ {{/each}}
+
+ {{#if this.remainingNotAcceptedUsers}}
+ <a
+ href
+ {{on "click" this.loadRemainingNotAcceptedUsers}}
+ class="load-more-users"
+ >
+ +
+ {{this.remainingNotAcceptedUsers}}
+ {{icon "user"}}
+ </a>
+ {{/if}}
+ </div>
+ {{/if}}
+ {{/if}}
+ </div>
+
+ {{#if this.canManagePolicy}}
+ <DButton
+ @action={{this.editPolicy}}
+ @icon="gear"
+ class="no-text btn-default edit-policy-settings-btn"
+ />
+ {{/if}}
+ </div>
+ {{/if}}
+ </template>
+}
diff --git a/plugins/discourse-policy/assets/javascripts/discourse/connectors/user-preferences-emails-pref-email-settings/preferences-policy-emails.gjs b/plugins/discourse-policy/assets/javascripts/discourse/connectors/user-preferences-emails-pref-email-settings/preferences-policy-emails.gjs
new file mode 100644
index 00000000000..19feec26225
--- /dev/null
+++ b/plugins/discourse-policy/assets/javascripts/discourse/connectors/user-preferences-emails-pref-email-settings/preferences-policy-emails.gjs
@@ -0,0 +1,59 @@
+import { fn } from "@ember/helper";
+import { eq } from "truth-helpers";
+import { i18n } from "discourse-i18n";
+import ComboBox from "select-kit/components/combo-box";
+
+const EMAIL_FREQUENCY_OPTIONS = [
+ {
+ name: i18n(
+ "discourse_policy.preferences.policy_emails.email_frequency_options.never"
+ ),
+ value: "never",
+ },
+ {
+ name: i18n(
+ "discourse_policy.preferences.policy_emails.email_frequency_options.when_away"
+ ),
+ value: "when_away",
+ },
+ {
+ name: i18n(
+ "discourse_policy.preferences.policy_emails.email_frequency_options.always"
+ ),
+ value: "always",
+ },
+];
+
+const PreferencesPolicyEmails = <template>
+ <h3>{{i18n "discourse_policy.preferences.title"}}</h3>
+
+ <div class="control-group policy-setting controls-dropdown">
+ <label for="user_policy_email_frequency">
+ {{i18n "discourse_policy.preferences.policy_emails.label"}}
+ </label>
+
+ <ComboBox
+ @valueProperty="value"
+ @content={{EMAIL_FREQUENCY_OPTIONS}}
+ @value={{@outletArgs.model.user_option.policy_email_frequency}}
+ @onChange={{fn
+ (mut @outletArgs.model.user_option.policy_email_frequency)
+ }}
+ @id="user_policy_email_frequency"
+ />
+
+ {{#if (eq @outletArgs.model.user_option.policy_email_frequency "always")}}
+ <div class="control-instructions">
+ {{i18n "discourse_policy.preferences.policy_emails.always_description"}}
+ </div>
+ {{else if
+ (eq @outletArgs.model.user_option.policy_email_frequency "when_away")
+ }}
+ <div class="control-instructions">
+ {{i18n "discourse_policy.preferences.policy_emails.away_description"}}
+ </div>
+ {{/if}}
+ </div>
+</template>;
+
+export default PreferencesPolicyEmails;
diff --git a/plugins/discourse-policy/assets/javascripts/discourse/initializers/add-policy-builder.js b/plugins/discourse-policy/assets/javascripts/discourse/initializers/add-policy-builder.js
new file mode 100644
index 00000000000..1c922cb8213
--- /dev/null
+++ b/plugins/discourse-policy/assets/javascripts/discourse/initializers/add-policy-builder.js
@@ -0,0 +1,38 @@
+import { withPluginApi } from "discourse/lib/plugin-api";
+import PolicyBuilder from "../components/modal/policy-builder";
+
+function initializePolicyBuilder(api, container) {
+ const currentUser = api.getCurrentUser();
+ const siteSettings = container.lookup("service:site-settings");
+ const modal = container.lookup("service:modal");
+
+ if (currentUser) {
+ api.addComposerToolbarPopupMenuOption({
+ label: "discourse_policy.builder.attach",
+ icon: "file-signature",
+ group: "insertions",
+ action: (toolbarEvent) => {
+ modal.show(PolicyBuilder, {
+ model: {
+ insertMode: true,
+ post: null,
+ toolbarEvent,
+ },
+ });
+ },
+ condition: () =>
+ !siteSettings.policy_restrict_to_staff_posts || currentUser.staff,
+ });
+ }
+}
+
+export default {
+ name: "add-discourse-policy-builder",
+
+ initialize(container) {
+ const siteSettings = container.lookup("service:site-settings");
+ if (siteSettings.policy_enabled) {
+ withPluginApi("1.13.0", (api) => initializePolicyBuilder(api, container));
+ }
+ },
+};
diff --git a/plugins/discourse-policy/assets/javascripts/discourse/initializers/extend-for-policy.gjs b/plugins/discourse-policy/assets/javascripts/discourse/initializers/extend-for-policy.gjs
new file mode 100644
index 00000000000..c0f214a5d12
--- /dev/null
+++ b/plugins/discourse-policy/assets/javascripts/discourse/initializers/extend-for-policy.gjs
@@ -0,0 +1,105 @@
+import EmberObject from "@ember/object";
+import { withPluginApi } from "discourse/lib/plugin-api";
+import { escapeExpression } from "discourse/lib/utilities";
+import { i18n } from "discourse-i18n";
+import PostPolicy from "../components/post-policy";
+
+const SETTINGS = [
+ { name: "groups" },
+ { name: "version" },
+ { name: "renew" },
+ {
+ name: "renew-start",
+ camelName: "renewStart",
+ },
+ { name: "reminder" },
+ {
+ name: "accept",
+ default: i18n("discourse_policy.accept_policy"),
+ escape: true,
+ },
+ {
+ name: "revoke",
+ default: i18n("discourse_policy.revoke_policy"),
+ escape: true,
+ },
+ {
+ name: "add-users-to-group",
+ camelName: "addUsersToGroup",
+ },
+];
+
+const PolicyWrapper = <template>
+ <PostPolicy @post={{@data.post}} @policy={{@data.policy}} />
+</template>;
+
+function _buildPolicyAttributes(policy) {
+ const form = {};
+ SETTINGS.forEach((setting) => {
+ form[setting.name] =
+ policy.dataset[setting.camelName || setting.name] ||
+ setting.default ||
+ "";
+
+ if (setting.escape) {
+ form[setting.name] = escapeExpression(form[setting.name]);
+ }
+ });
+
+ if (!form.version || parseInt(form.version, 10) < 1) {
+ form.version = 1;
+ }
+
+ form.private = policy.dataset.private === "true";
+
+ return EmberObject.create(form);
+}
+
+function attachPolicy(cooked, helper) {
+ const policy = cooked.querySelector(".policy");
+
+ if (!policy) {
+ return;
+ }
+
+ policy.innerHTML = `<div class="policy-body">${policy.innerHTML}</div>`;
+
+ const post = helper?.getModel();
+
+ if (!post) {
+ // if no post it means we are decorating the preview, make it clear it's a policy
+ const policyPreview = document.createElement("div");
+ policyPreview.classList.add("policy-preview");
+ policyPreview.innerText = i18n("discourse_policy.title");
+ policy.prepend(policyPreview);
+ return;
+ }
+
+ helper.renderGlimmer(policy, PolicyWrapper, {
+ post,
+ policy: _buildPolicyAttributes(policy),
+ });
+}
+
+export default {
+ name: "extend-for-policy",
+
+ initialize() {
+ withPluginApi("0.8.7", function (api) {
+ api.decorateCookedElement(attachPolicy, {
+ onlyStream: false,
+ id: "discourse-policy",
+ });
+
+ api.registerCustomPostMessageCallback(
+ "policy_change",
+ (controller, message) => {
+ controller.appEvents.trigger("policy:changed", {
+ controller,
+ message,
+ });
+ }
+ );
+ });
+ },
+};
diff --git a/plugins/discourse-policy/assets/javascripts/lib/discourse-markdown/policy.js b/plugins/discourse-policy/assets/javascripts/lib/discourse-markdown/policy.js
new file mode 100644
index 00000000000..384b2798562
--- /dev/null
+++ b/plugins/discourse-policy/assets/javascripts/lib/discourse-markdown/policy.js
@@ -0,0 +1,32 @@
+const rule = {
+ tag: "policy",
+
+ wrap(token, info) {
+ if (!info.attrs.group && !info.attrs.groups) {
+ return false;
+ }
+
+ token.attrs = [["class", "policy"]];
+
+ // defaults to version 1 of the policy
+ info.attrs.version ||= 1;
+
+ for (let key of Object.keys(info.attrs).sort()) {
+ token.attrs.push([`data-${key}`, info.attrs[key]]);
+ }
+
+ return true;
+ },
+};
+
+export function setup(helper) {
+ helper.allowList(["div.policy"]);
+
+ helper.registerOptions((opts, siteSettings) => {
+ opts.features.policy = !!siteSettings.policy_enabled;
+ });
+
+ helper.registerPlugin((md) => {
+ md.block.bbcode.ruler.push("policy", rule);
+ });
+}
diff --git a/plugins/discourse-policy/assets/javascripts/pre-initializers/policy-user-options.js b/plugins/discourse-policy/assets/javascripts/pre-initializers/policy-user-options.js
new file mode 100644
index 00000000000..269e1d9d511
--- /dev/null
+++ b/plugins/discourse-policy/assets/javascripts/pre-initializers/policy-user-options.js
@@ -0,0 +1,24 @@
+import EmailsController from "discourse/controllers/preferences/emails";
+import { withPluginApi } from "discourse/lib/plugin-api";
+
+const SEND_EMAIL_NOTIFICATIONS_FIELD = "policy_email_frequency";
+
+export default {
+ name: "policy-user-options",
+
+ initialize(container) {
+ withPluginApi("0.8.7", (api) => {
+ const siteSettings = container.lookup("service:site-settings");
+ if (siteSettings.policy_enabled) {
+ api.addSaveableUserOptionField(SEND_EMAIL_NOTIFICATIONS_FIELD);
+ }
+ });
+
+ EmailsController.reopen({
+ init() {
+ this._super(...arguments);
+ this.saveAttrNames.push(SEND_EMAIL_NOTIFICATIONS_FIELD);
+ },
+ });
+ },
+};
diff --git a/plugins/discourse-policy/assets/stylesheets/common/discourse-policy-builder.scss b/plugins/discourse-policy/assets/stylesheets/common/discourse-policy-builder.scss
new file mode 100644
index 00000000000..c687a547759
--- /dev/null
+++ b/plugins/discourse-policy/assets/stylesheets/common/discourse-policy-builder.scss
@@ -0,0 +1,41 @@
+.d-modal.policy-builder {
+ ::-webkit-calendar-picker-indicator {
+ opacity: 1;
+ }
+
+ @media (prefers-color-scheme: dark) {
+ ::-webkit-calendar-picker-indicator {
+ @if is-light-color-scheme() {
+ filter: invert(0);
+ } @else {
+ filter: invert(1);
+ }
+ }
+ }
+
+ input:not([type="checkbox"]),
+ .select-kit {
+ margin: 0;
+ width: 100%;
+ }
+
+ input[type="checkbox"] {
+ margin: 0;
+ }
+
+ .policy-field {
+ margin-bottom: 0.5em;
+
+ &:last-child {
+ margin: 0;
+ }
+
+ .policy-field-label {
+ font-weight: 700;
+ }
+
+ .policy-field-description {
+ font-size: var(--font-down-1);
+ }
+ }
+}
diff --git a/plugins/discourse-policy/assets/stylesheets/common/discourse-policy.scss b/plugins/discourse-policy/assets/stylesheets/common/discourse-policy.scss
new file mode 100644
index 00000000000..f171578d3af
--- /dev/null
+++ b/plugins/discourse-policy/assets/stylesheets/common/discourse-policy.scss
@@ -0,0 +1,158 @@
+@use "lib/viewport";
+
+// Policy in post styles
+.cooked .policy {
+ position: relative;
+ border: 1px solid var(--primary-low);
+
+ .policy-body {
+ padding: 0.75em;
+ margin-bottom: 2em;
+ }
+
+ .policy-footer {
+ border-top: 1px solid var(--primary-low);
+ padding: 0.75em;
+ align-items: center;
+ display: flex;
+ justify-content: space-between;
+ gap: 1rem;
+
+ @include viewport.until(md) {
+ flex-direction: column;
+ }
+ }
+
+ .toggle {
+ display: flex;
+ align-items: center;
+
+ &.toggle-accepted {
+ color: var(--success);
+ }
+
+ &.toggle-not-accepted {
+ color: var(--primary-medium);
+ }
+
+ .user-count {
+ display: flex;
+ align-items: center;
+ margin-right: 0.25em;
+ }
+
+ .d-icon {
+ line-height: var(--line-height-large);
+ }
+ }
+
+ .no-possible-users {
+ color: var(--danger);
+ font-size: var(--font-down-1);
+ }
+
+ .user-lists {
+ display: flex;
+ font-size: var(--font-up-1);
+ gap: 0.5rem;
+ justify-content: end;
+
+ .users {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+
+ .avatar {
+ margin: 1px;
+ }
+ }
+ }
+
+ .separator {
+ border-right: 2px solid var(--primary-low);
+ }
+
+ .see-policy-settings-btn,
+ .edit-policy-settings-btn {
+ position: absolute;
+ top: 0.25em;
+ right: 0.25em;
+ background: none;
+ padding: 0.5em;
+
+ &:hover {
+ color: var(--primary-very-low);
+ background: var(--primary-medium);
+ }
+ }
+
+ .load-more-users {
+ color: var(--primary-medium);
+ margin-left: 0.25em;
+ }
+
+ .policy-actions {
+ display: flex;
+ gap: 0.5rem;
+ flex-wrap: wrap;
+
+ @include viewport.until(lg) {
+ width: 100%;
+ }
+
+ .btn {
+ white-space: nowrap;
+
+ @include viewport.until(lg) {
+ width: 100%;
+ white-space: inherit;
+ }
+ }
+ }
+
+ .policy-settings {
+ display: none; // JS override kicks in when needed.
+ border-top: 1px solid var(--primary-low);
+ padding: 0.75em;
+ flex-direction: column;
+
+ .visible-settings {
+ color: var(--primary-medium);
+ }
+
+ .save-policy-settings-btn {
+ margin-left: auto;
+ }
+ }
+
+ .settings-list {
+ display: flex;
+ flex-direction: column;
+
+ .setting {
+ display: flex;
+ align-items: center;
+ margin-bottom: 0.75em;
+ }
+
+ .policy-setting-name {
+ flex: 1;
+ }
+
+ .policy-setting-value {
+ flex: 4;
+ margin-bottom: 0;
+ }
+ }
+}
+
+// Policy in editor styles
+.d-editor-preview .policy {
+ padding: 0.5em;
+ border: 1px solid var(--primary-low);
+
+ .policy-preview {
+ font-size: var(--font-up-1);
+ font-weight: 700;
+ }
+}
diff --git a/plugins/discourse-policy/config/locales/client.ar.yml b/plugins/discourse-policy/config/locales/client.ar.yml
new file mode 100644
index 00000000000..52be920471f
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.ar.yml
@@ -0,0 +1,62 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ar:
+ js:
+ discourse_policy:
+ title: "السياسة"
+ accepted_tooltip: "المستخدمون الذين قبلوا هذه السياسة"
+ not_accepted_tooltip: "المستخدمون الذين لم يقبلوا هذه السياسة"
+ accept_policy: "قبول السياسة"
+ revoke_policy: "إلغاء السياسة"
+ edit_reason: "تم تعديل إعدادات السياسة"
+ no_possible_users: "لا يوجد مستخدمون محتملون لهذه السياسة"
+ accept_policy_template: "أقبل هذه السياسة"
+ builder:
+ title: السياسة
+ attach: إنشاء سياسة
+ save: حفظ التغييرات
+ insert: إدراج
+ errors:
+ group: المجموعة مطلوبة
+ version: الإصدار مطلوب
+ groups:
+ label: المجموعات
+ description: المجموعات المرتبطة بهذه السياسة
+ version:
+ label: الإصدار
+ description: نسخة السياسة، ستجبر ترقية السياسة الأشخاص على قبولها مرة أخرى
+ renew:
+ label: تجديد
+ description: إعادة تجديد السياسة كل x من الأيام
+ renew-start:
+ label: بدء التجديد
+ description: موعد تجديد السياسة
+ reminder:
+ label: تذكير
+ description: عدد المرات التي يجب فيها إرسال إشعار التذكير بقبول السياسة
+ accept:
+ label: قبول
+ description: النص المستخدم على زر القبول
+ revoke:
+ label: إلغاء
+ description: النص المستخدم على زر الإلغاء
+ private:
+ label: خاصة?
+ description: إبقاء حالة السياسة خاصة للمشرفين
+ send-email:
+ label: هل تريد إرسال رسالة إلكترونية؟
+ description: إرسال إشعار بالسياسة الجديدة إلى المستخدمين عبر البريد الإلكتروني
+ preferences:
+ title: السياسات
+ policy_emails:
+ always_description: سنراسلك عبر البريد الإلكتروني فقط إذا كنت قد اشتركت أيضًا في الرسائل الإلكترونية للنشاط الجديد.
+ away_description: سنراسلك عبر البريد الإلكتروني فقط إذا لم نرك في آخر 10 دقائق عندما تتغيَّر حالة السياسة، وفقط إذا اشتركت في الرسائل الإلكترونية للنشاط الجديد.
+ label: مراسلتي عبر البريد الإلكتروني عندما تحتاج إحدى السياسات إلى مراجعتي
+ email_frequency_options:
+ never: أبدًا
+ when_away: عندما أكون غائبًا فقط
+ always: دائمًا
diff --git a/plugins/discourse-policy/config/locales/client.be.yml b/plugins/discourse-policy/config/locales/client.be.yml
new file mode 100644
index 00000000000..109decd0a65
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.be.yml
@@ -0,0 +1,25 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+be:
+ js:
+ discourse_policy:
+ builder:
+ groups:
+ label: Групы
+ version:
+ label: версія
+ revoke:
+ label: адклікаць
+ private:
+ label: прыватны?
+ send-email:
+ label: Адправіць на e-mail?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: ніколі
+ always: заўсёды
diff --git a/plugins/discourse-policy/config/locales/client.bg.yml b/plugins/discourse-policy/config/locales/client.bg.yml
new file mode 100644
index 00000000000..c37a14e1480
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.bg.yml
@@ -0,0 +1,27 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+bg:
+ js:
+ discourse_policy:
+ builder:
+ groups:
+ label: Групи
+ version:
+ label: Версия
+ accept:
+ label: Приемам
+ revoke:
+ label: Анулирай
+ private:
+ label: Затворени?
+ send-email:
+ label: Изпрати имейл?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Никога
+ always: Винаги
diff --git a/plugins/discourse-policy/config/locales/client.bs_BA.yml b/plugins/discourse-policy/config/locales/client.bs_BA.yml
new file mode 100644
index 00000000000..54ece1f374c
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.bs_BA.yml
@@ -0,0 +1,26 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+bs_BA:
+ js:
+ discourse_policy:
+ builder:
+ insert: Unesi
+ groups:
+ label: Grupe
+ version:
+ label: Verzija
+ accept:
+ label: Prihvati
+ revoke:
+ label: Revoke
+ private:
+ label: Privatno?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Nikad
+ always: Uvijek
diff --git a/plugins/discourse-policy/config/locales/client.ca.yml b/plugins/discourse-policy/config/locales/client.ca.yml
new file mode 100644
index 00000000000..1d2ce09a481
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.ca.yml
@@ -0,0 +1,28 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ca:
+ js:
+ discourse_policy:
+ builder:
+ insert: Insereix
+ groups:
+ label: Grups
+ version:
+ label: Versió
+ accept:
+ label: Accepta
+ revoke:
+ label: Revoca
+ private:
+ label: Privat?
+ send-email:
+ label: Envia un correu?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Mai
+ always: Sempre
diff --git a/plugins/discourse-policy/config/locales/client.cs.yml b/plugins/discourse-policy/config/locales/client.cs.yml
new file mode 100644
index 00000000000..a0f3bf98776
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.cs.yml
@@ -0,0 +1,29 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+cs:
+ js:
+ discourse_policy:
+ builder:
+ insert: Vložit
+ groups:
+ label: Skupiny
+ version:
+ label: Verze
+ accept:
+ label: Přijmout
+ revoke:
+ label: zrušit
+ private:
+ label: Soukromé?
+ send-email:
+ label: Odeslat e-mail?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Nikdy
+ when_away: Jen v nepřítomnosti
+ always: Vždy
diff --git a/plugins/discourse-policy/config/locales/client.da.yml b/plugins/discourse-policy/config/locales/client.da.yml
new file mode 100644
index 00000000000..9ade8f5d9c1
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.da.yml
@@ -0,0 +1,28 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+da:
+ js:
+ discourse_policy:
+ builder:
+ insert: Indsæt
+ groups:
+ label: Grupper
+ version:
+ label: Version
+ accept:
+ label: Acceptér
+ revoke:
+ label: Tilbagekald
+ private:
+ label: Privat?
+ send-email:
+ label: Send E-Mail?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Aldrig
+ always: Altid
diff --git a/plugins/discourse-policy/config/locales/client.de.yml b/plugins/discourse-policy/config/locales/client.de.yml
new file mode 100644
index 00000000000..b73e0278739
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.de.yml
@@ -0,0 +1,66 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+de:
+ js:
+ discourse_policy:
+ title: "Richtlinie"
+ accepted_tooltip: "Benutzer, die diese Richtlinie akzeptiert haben"
+ not_accepted_tooltip: "Benutzer, die diese Richtlinie nicht akzeptiert haben"
+ accept_policy: "Richtlinie akzeptieren"
+ revoke_policy: "Richtlinie widerrufen"
+ edit_reason: "Richtlinieneinstellungen wurden geändert"
+ no_possible_users: "Diese Richtlinie hat keine möglichen Benutzer"
+ accept_policy_template: "Ich akzeptiere diese Richtlinie"
+ builder:
+ title: Richtlinie
+ attach: Richtlinie erstellen
+ save: Änderungen speichern
+ insert: Einfügen
+ errors:
+ group: Gruppe ist erforderlich
+ version: Version ist erforderlich
+ groups:
+ label: Gruppen
+ description: Die mit dieser Richtlinie verknüpften Gruppen
+ version:
+ label: Version
+ description: Die Version der Richtlinie. Das Erhöhen der Version zwingt die Benutzer dazu, sie erneut zu akzeptieren
+ renew:
+ label: Erneuern
+ description: Die Richtlinie alle x Tage erneuern
+ renew-start:
+ label: Start der Erneuerung
+ description: Wann die Richtlinie erneuert werden soll
+ reminder:
+ label: Erinnerung
+ description: Wie oft eine Erinnerungsbenachrichtigung zur Annahme der Richtlinie gesendet werden soll
+ no_reminder: (Keine Erinnerung)
+ accept:
+ label: Akzeptieren
+ description: Text für die Schaltfläche „Akzeptieren“
+ revoke:
+ label: Widerrufen
+ description: Text für die Schaltfläche „Widerrufen“
+ private:
+ label: Privat?
+ description: Status der Richtlinie für Administratoren privat halten
+ send-email:
+ label: E-Mail senden?
+ description: Benutzer per E-Mail über die neue Richtlinie benachrichtigen
+ add-users-to-group:
+ label: Benutzer zu Gruppe hinzufügen
+ description: Füge Benutzer zu der folgenden Gruppe hinzu, wenn sie diese Richtlinie akzeptieren
+ preferences:
+ title: Richtlinien
+ policy_emails:
+ always_description: Wir schicken dir nur dann eine E-Mail, wenn du dich auch für E-Mails zu neuen Aktivitäten angemeldet hast.
+ away_description: Wir schicken dir nur dann eine E-Mail, wenn wir dich in den letzten 10 Minuten nicht gesehen haben, wenn sich der Richtlinienstatus ändert, und wenn du dich auch für E-Mails zu neuen Aktivitäten angemeldet hast.
+ label: E-Mail an mich, wenn eine Richtlinie meine Überprüfung benötigt
+ email_frequency_options:
+ never: niemals
+ when_away: Nur bei Abwesenheit
+ always: Immer
diff --git a/plugins/discourse-policy/config/locales/client.el.yml b/plugins/discourse-policy/config/locales/client.el.yml
new file mode 100644
index 00000000000..aca8ed9d72c
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.el.yml
@@ -0,0 +1,37 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+el:
+ js:
+ discourse_policy:
+ title: "Πολιτική"
+ accept_policy: "Αποδοχή Πολιτικής"
+ revoke_policy: "Ανάκληση Πολιτικής"
+ builder:
+ title: Πολιτική
+ attach: Δημιουργία Πολιτικής
+ save: Αποθήκευση αλλαγών
+ insert: Εισαγωγή
+ groups:
+ label: Ομάδες
+ version:
+ label: Έκδοση
+ renew:
+ label: Ανανέωση
+ accept:
+ label: Αποδέχομαι
+ revoke:
+ label: Ανακάλεσε
+ private:
+ label: Ιδιωτική?
+ send-email:
+ label: Αποστολή Email?
+ preferences:
+ title: Πολιτικές
+ policy_emails:
+ email_frequency_options:
+ never: Ποτέ
+ always: Πάντα
diff --git a/plugins/discourse-policy/config/locales/client.en.yml b/plugins/discourse-policy/config/locales/client.en.yml
new file mode 100644
index 00000000000..5b42cacfc44
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.en.yml
@@ -0,0 +1,60 @@
+en:
+ js:
+ discourse_policy:
+ title: "Policy"
+ accepted_tooltip: "Users who have accepted this policy"
+ not_accepted_tooltip: "Users who have not accepted this policy"
+ accept_policy: "Accept Policy"
+ revoke_policy: "Revoke Policy"
+ edit_reason: "Policy settings have been modified"
+ no_possible_users: "This policy has no possible users"
+ accept_policy_template: "I accept this policy"
+ builder:
+ title: Policy
+ attach: Create Policy
+ save: Save changes
+ insert: Insert
+ errors:
+ group: Group is required
+ version: Version is required
+ groups:
+ label: Groups
+ description: The groups associated to this policy
+ version:
+ label: Version
+ description: The version of the policy, bumping the version will force people to re-accept it
+ renew:
+ label: Renew
+ description: Renew the policy every x days
+ renew-start:
+ label: Renew Start
+ description: When the policy should be renewed
+ reminder:
+ label: Reminder
+ description: How often a reminder notification to accept the policy should be sent
+ no_reminder: (No reminder)
+ accept:
+ label: Accept
+ description: Text used on the accept button
+ revoke:
+ label: Revoke
+ description: Text used on the revoke button
+ private:
+ label: Private?
+ description: Keep policy status private to administrators
+ send-email:
+ label: Send Email?
+ description: Notify users of the new policy by email
+ add-users-to-group:
+ label: Add users to group
+ description: Add users to the following group when they accept this policy
+ preferences:
+ title: Policies
+ policy_emails:
+ always_description: We'll only email you if you've also opted in for new activity emails.
+ away_description: We'll only email you if we haven't seen you in the last 10 minutes when the policy status changes, and only if you've also opted in for new activity emails.
+ label: Email me when a policy needs my review
+ email_frequency_options:
+ never: Never
+ when_away: Only when away
+ always: Always
diff --git a/plugins/discourse-policy/config/locales/client.en_GB.yml b/plugins/discourse-policy/config/locales/client.en_GB.yml
new file mode 100644
index 00000000000..2d4fa180ec7
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.en_GB.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+en_GB:
diff --git a/plugins/discourse-policy/config/locales/client.es.yml b/plugins/discourse-policy/config/locales/client.es.yml
new file mode 100644
index 00000000000..15d2bf75acd
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.es.yml
@@ -0,0 +1,62 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+es:
+ js:
+ discourse_policy:
+ title: "Política"
+ accepted_tooltip: "Usuarios que aceptaron esta política"
+ not_accepted_tooltip: "Usuarios que no aceptaron esta política"
+ accept_policy: "Aceptar política"
+ revoke_policy: "Rechazar política"
+ edit_reason: "Se ha modificado la configuración de la política"
+ no_possible_users: "Esta política no tiene usuarios posibles"
+ accept_policy_template: "Acepto esta política"
+ builder:
+ title: Política
+ attach: Crear política
+ save: Guardar cambios
+ insert: Insertar
+ errors:
+ group: El grupo es obligatorio
+ version: La versión es obligatoria
+ groups:
+ label: Grupos
+ description: Los grupos asociados a esta política
+ version:
+ label: Versión
+ description: La versión de la política, cambiar la versión obligará a las personas a volver a aceptarla
+ renew:
+ label: Renovar
+ description: Renovar la política cada x días
+ renew-start:
+ label: Inicio de la renovación
+ description: Cuándo debe renovarse la política
+ reminder:
+ label: Recordatorio
+ description: Con qué frecuencia se debe enviar una notificación de recordatorio para aceptar la política
+ accept:
+ label: Aceptar
+ description: Texto utilizado en el botón aceptar
+ revoke:
+ label: Revocar
+ description: Texto utilizado en el botón de revocación
+ private:
+ label: '¿Privado?'
+ description: Mantener el estado de la política en privado para los administradores
+ send-email:
+ label: '¿Enviar correo electrónico?'
+ description: Notificar a los usuarios la nueva política por correo electrónico
+ preferences:
+ title: Políticas
+ policy_emails:
+ always_description: Solo te enviaremos un correo electrónico si también has optado por recibir correos electrónicos de nuevas actividades.
+ away_description: Solo te enviaremos un correo electrónico si no te hemos visto en los últimos 10 minutos cuando cambie el estado de la política, y solo si también has optado por recibir correos electrónicos con nuevas actividades.
+ label: Envíame un correo electrónico cuando una política necesite mi revisión
+ email_frequency_options:
+ never: Nunca
+ when_away: Solo cuando estés ausente
+ always: Siempre
diff --git a/plugins/discourse-policy/config/locales/client.et.yml b/plugins/discourse-policy/config/locales/client.et.yml
new file mode 100644
index 00000000000..f56cd06d258
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.et.yml
@@ -0,0 +1,25 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+et:
+ js:
+ discourse_policy:
+ builder:
+ groups:
+ label: Grupid
+ version:
+ label: Versioon
+ revoke:
+ label: Tühista
+ private:
+ label: Privaatne?
+ send-email:
+ label: Saada kiri?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Mitte kunagi
+ always: Alati
diff --git a/plugins/discourse-policy/config/locales/client.fa_IR.yml b/plugins/discourse-policy/config/locales/client.fa_IR.yml
new file mode 100644
index 00000000000..8c179476bed
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.fa_IR.yml
@@ -0,0 +1,39 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+fa_IR:
+ js:
+ discourse_policy:
+ title: "خط مشی"
+ accepted_tooltip: "کاربرانی که این خط مش را پذیرفته‌اند"
+ not_accepted_tooltip: "کاربرانی که این خط مش را نپذیرفته‌اند"
+ accept_policy: "قبول کردن خط مش"
+ revoke_policy: "ابطال خط مش"
+ accept_policy_template: "من این خط مش را می‌پذیرم"
+ builder:
+ title: خط مشی
+ attach: ایجاد خط مش
+ save: ذخیر تغییرات
+ insert: درج کردن
+ errors:
+ group: گروه الزامی است
+ version: نسخه الزامی است
+ groups:
+ label: گروه‌ها
+ version:
+ label: نسخه
+ accept:
+ label: پذیرفتن
+ revoke:
+ label: ابطال
+ private:
+ label: خصوصی؟
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: هرگز
+ when_away: فقط وقتی نیستم
+ always: همیشه
diff --git a/plugins/discourse-policy/config/locales/client.fi.yml b/plugins/discourse-policy/config/locales/client.fi.yml
new file mode 100644
index 00000000000..175e30ff8ff
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.fi.yml
@@ -0,0 +1,62 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+fi:
+ js:
+ discourse_policy:
+ title: "Käytäntö"
+ accepted_tooltip: "Käyttäjät, jotka ovat hyväksyneet tämän käytännön"
+ not_accepted_tooltip: "Käyttäjät, jotka eivät ole hyväksyneet tätä käytäntöä"
+ accept_policy: "Hyväksy käytäntö"
+ revoke_policy: "Peru käytäntö"
+ edit_reason: "Käytäntöasetuksia on muutettu"
+ no_possible_users: "Tällä käytännöllä ei ole mahdollisia käyttäjiä"
+ accept_policy_template: "Hyväksyn tämän käytännön"
+ builder:
+ title: Käytäntö
+ attach: Luo käytäntö
+ save: Tallenna muutokset
+ insert: Lisää
+ errors:
+ group: Ryhmä on pakollinen
+ version: Versio on pakollinen
+ groups:
+ label: Ryhmät
+ description: Tähän käytäntöön liittyvät ryhmät
+ version:
+ label: Versio
+ description: Käytännön versio, version korotus pakottaa ihmiset hyväksymään sen uudelleen
+ renew:
+ label: Uudista
+ description: Uudista käytäntö x päivän välein
+ renew-start:
+ label: Uudistamisen aloitus
+ description: Milloin käytäntö tulisi uudistaa
+ reminder:
+ label: Muistutus
+ description: Kuinka usein muistutus käytännön hyväksymisestä tulisi lähettää
+ accept:
+ label: Hyväksy
+ description: Hyväksymispainikkeessa käytettävä teksti
+ revoke:
+ label: Peru
+ description: Perumispainikkeessa käytettävä teksti
+ private:
+ label: Yksityinen?
+ description: Pidä käytännön tila yksityisenä järjestelmänvalvojille
+ send-email:
+ label: Lähetetäänkö sähköposti?
+ description: Ilmoita käyttäjille uudesta käytännöstä sähköpostitse
+ preferences:
+ title: Käytännöt
+ policy_emails:
+ always_description: Lähetämme sinulle sähköpostin vain, jos olet valinnut vastaanottavasi sähköposteja uusista aktiviteeteista.
+ away_description: Lähetämme sinulle sähköpostin vain, jos emme ole nähneet sinua viimeisten 10 minuutin aikana käytännön tilan muuttuessa, ja jos olet valinnut vastaanottavasi sähköposteja uusista aktiviteeteista.
+ label: Lähetä minulle sähköposti, kun käytäntö tarvitsee tarkistustani
+ email_frequency_options:
+ never: Ei koskaan
+ when_away: Vain poissa ollessa
+ always: Aina
diff --git a/plugins/discourse-policy/config/locales/client.fr.yml b/plugins/discourse-policy/config/locales/client.fr.yml
new file mode 100644
index 00000000000..949f51221d7
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.fr.yml
@@ -0,0 +1,62 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+fr:
+ js:
+ discourse_policy:
+ title: "Politique"
+ accepted_tooltip: "Utilisateurs ayant accepté cette politique"
+ not_accepted_tooltip: "Utilisateurs qui n'ont pas accepté cette politique"
+ accept_policy: "Accepter la politique"
+ revoke_policy: "Refuser la politique"
+ edit_reason: "Les paramètres de la politique ont été modifiés"
+ no_possible_users: "Cette politique n'a aucun utilisateur possible"
+ accept_policy_template: "J'accepte cette politique"
+ builder:
+ title: Politique
+ attach: Créer une politique
+ save: Enregistrer les modifications
+ insert: Insérer
+ errors:
+ group: Le groupe est requis
+ version: La version est requise
+ groups:
+ label: Groupes
+ description: Les groupes associés à cette politique
+ version:
+ label: Version
+ description: La version de la politique, la modification de la version forcera les utilisateurs à devoir l'accepter à nouveau
+ renew:
+ label: Renouveler
+ description: Renouveler la police tous les x jours
+ renew-start:
+ label: Début du renouvellement
+ description: Quand la politique doit être renouvelée
+ reminder:
+ label: Rappel
+ description: La fréquence à laquelle une notification de rappel doit être envoyée pour accepter la police
+ accept:
+ label: Accepter
+ description: Texte utilisé sur le bouton d'acceptation
+ revoke:
+ label: Révoquer
+ description: Texte utilisé sur le bouton de révocation
+ private:
+ label: Rendre privé ?
+ description: Garder le statut de la politique privé pour les administrateurs
+ send-email:
+ label: Envoyer un e-mail ?
+ description: Informer les utilisateurs de la nouvelle politique par e-mail
+ preferences:
+ title: Politiques
+ policy_emails:
+ always_description: Nous ne vous enverrons un e-mail que si vous avez également choisi de recevoir de nouveaux e-mails d'activité.
+ away_description: Nous ne vous enverrons un e-mail que si nous ne vous avons pas vu au cours des 10 dernières minutes avant le changement de statut de la politique, et uniquement si vous avez également accepté de recevoir de nouveaux e-mails d'activité.
+ label: Envoyez-moi un e-mail lorsqu'une politique nécessite mon examen
+ email_frequency_options:
+ never: Jamais
+ when_away: Seulement en cas d'absence
+ always: Toujours
diff --git a/plugins/discourse-policy/config/locales/client.gl.yml b/plugins/discourse-policy/config/locales/client.gl.yml
new file mode 100644
index 00000000000..a2a46aeb38c
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.gl.yml
@@ -0,0 +1,28 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+gl:
+ js:
+ discourse_policy:
+ builder:
+ insert: Inserir
+ groups:
+ label: Grupos
+ version:
+ label: Versión
+ accept:
+ label: Aceptar
+ revoke:
+ label: Revogar
+ private:
+ label: Privado?
+ send-email:
+ label: Enviar correo electrónico?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Nunca
+ always: Sempre
diff --git a/plugins/discourse-policy/config/locales/client.he.yml b/plugins/discourse-policy/config/locales/client.he.yml
new file mode 100644
index 00000000000..bfd837faacd
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.he.yml
@@ -0,0 +1,66 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+he:
+ js:
+ discourse_policy:
+ title: "מדיניות"
+ accepted_tooltip: "משתמשים שקיבלו את המדיניות הזאת"
+ not_accepted_tooltip: "משתמשים שלא קיבלו את המדיניות הזאת"
+ accept_policy: "לקבל מדיניות"
+ revoke_policy: "לשלול מדיניות"
+ edit_reason: "הגדרות המדיניות השתנו"
+ no_possible_users: "למדיניות זאת אין משתמשים אפשריים"
+ accept_policy_template: "המדיניות הזאת מקובלת עליי"
+ builder:
+ title: מדיניות
+ attach: יצירת מדיניות
+ save: שמירת השינויים
+ insert: הוספה
+ errors:
+ group: נדרשת קבוצה
+ version: נדרשת גרסה
+ groups:
+ label: קבוצות
+ description: הקבוצות המשויכות למדיניות זו
+ version:
+ label: גרסה
+ description: גרסת המדיניות, הקפצת הגרסה תאלץ אנשים לקבל אותה מחדש
+ renew:
+ label: חידוש
+ description: חידוש המדיניות כל x ימים
+ renew-start:
+ label: התחלת חידוש
+ description: מתי לחדש את המדיניות
+ reminder:
+ label: תזכורת
+ description: באיזו תדירות לשלוח הודעת תזכורת לקבלת המדיניות
+ no_reminder: (ללא תזכורת)
+ accept:
+ label: קבלה
+ description: טקסט המשמש לכפתור הקבלה
+ revoke:
+ label: שלילה
+ description: טקסט המשמש לכפתור השלילה
+ private:
+ label: פרטי?
+ description: להשאיר את מצב המדיניות למנהלים בלבד
+ send-email:
+ label: שליחת דוא״ל?
+ description: להודיע למשתמשים על מדיניות חדשה דרך דוא״ל
+ add-users-to-group:
+ label: הוספת משתמשים לקבוצה
+ description: הוספת משתמשים לקבוצה הבאה כשהם מאשרים את המדיניות הזאת
+ preferences:
+ title: מסמכי מדיניות
+ policy_emails:
+ always_description: נשלח לך הודעה בדוא״ל רק אם נרשמת להודעות פעילות חדשה בנוסף.
+ away_description: נשלח לך הודעה בדוא״ל רק אם לא ראינו אותך ב־10 הדקות האחרונות כאשר מצב המדיניות משתנה ורק אם נרשמת להודעות פעילות חדשה בנוסף.
+ label: לשלוח לי הודעה בדוא״ל כשיש מדיניות שדורשת את התערבותי
+ email_frequency_options:
+ never: לעולם לא
+ when_away: רק בעת העדרות
+ always: תמיד
diff --git a/plugins/discourse-policy/config/locales/client.hr.yml b/plugins/discourse-policy/config/locales/client.hr.yml
new file mode 100644
index 00000000000..a6042969999
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.hr.yml
@@ -0,0 +1,26 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+hr:
+ js:
+ discourse_policy:
+ builder:
+ insert: Umetni
+ groups:
+ label: Grupe
+ version:
+ label: Inačica
+ accept:
+ label: Prihvati
+ revoke:
+ label: Povuci
+ private:
+ label: Privatno?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Nikad
+ always: Uvijek
diff --git a/plugins/discourse-policy/config/locales/client.hu.yml b/plugins/discourse-policy/config/locales/client.hu.yml
new file mode 100644
index 00000000000..7990eda8259
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.hu.yml
@@ -0,0 +1,29 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+hu:
+ js:
+ discourse_policy:
+ builder:
+ insert: Beszúrás
+ groups:
+ label: Csoportok
+ version:
+ label: Verzió
+ accept:
+ label: Elfogadás
+ revoke:
+ label: Visszavonás
+ private:
+ label: Privát?
+ description: Házirend állapotának privátban tartása a rendszergazdák számára
+ send-email:
+ label: E-mail küldése?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Soha
+ always: Mindig
diff --git a/plugins/discourse-policy/config/locales/client.hy.yml b/plugins/discourse-policy/config/locales/client.hy.yml
new file mode 100644
index 00000000000..f2d019be01c
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.hy.yml
@@ -0,0 +1,28 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+hy:
+ js:
+ discourse_policy:
+ builder:
+ insert: Մուտքագրել
+ groups:
+ label: Խմբեր
+ version:
+ label: Տարբերակ
+ accept:
+ label: Ընդունել
+ revoke:
+ label: Հետ կանչել
+ private:
+ label: Գաղտնի?
+ send-email:
+ label: Ուղարկել Էլ. նամակ?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Երբեք
+ always: Միշտ
diff --git a/plugins/discourse-policy/config/locales/client.id.yml b/plugins/discourse-policy/config/locales/client.id.yml
new file mode 100644
index 00000000000..972c32ef9e2
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.id.yml
@@ -0,0 +1,25 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+id:
+ js:
+ discourse_policy:
+ builder:
+ insert: Masukkan
+ groups:
+ label: Grup
+ accept:
+ label: Menerima
+ revoke:
+ label: Cabut
+ private:
+ label: Pribadi?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Tidak pernah
+ when_away: Hanya saat pergi
+ always: Selalu
diff --git a/plugins/discourse-policy/config/locales/client.it.yml b/plugins/discourse-policy/config/locales/client.it.yml
new file mode 100644
index 00000000000..291b0c6783a
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.it.yml
@@ -0,0 +1,62 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+it:
+ js:
+ discourse_policy:
+ title: "Informativa"
+ accepted_tooltip: "Utenti che hanno accettato questa informativa"
+ not_accepted_tooltip: "Utenti che non hanno accettato questa informativa"
+ accept_policy: "Accetta informativa"
+ revoke_policy: "Revoca informativa"
+ edit_reason: "Le impostazioni dell'informativa sono state modificate"
+ no_possible_users: "Questa informativa non ha utenti possibili"
+ accept_policy_template: "Accetto questa informativa"
+ builder:
+ title: Informativa
+ attach: Crea informativa
+ save: Salva le modifiche
+ insert: Inserisci
+ errors:
+ group: Il gruppo è obbligatorio
+ version: La versione è obbligatoria
+ groups:
+ label: Gruppi
+ description: I gruppi associati a questa informativa
+ version:
+ label: Versione
+ description: La versione dell'informativa, il cambio della versione costringerà gli utenti a riaccettarla
+ renew:
+ label: Rinnova
+ description: Rinnova l'informativa ogni x giorni
+ renew-start:
+ label: Inizio rinnovo
+ description: Quando l'informativa dovrà essere rinnovata
+ reminder:
+ label: Promemoria
+ description: Frequenza di invio di un promemoria di accettazione dell'informativa
+ accept:
+ label: Accetta
+ description: Testo utilizzato sul pulsante di accettazione
+ revoke:
+ label: Revoca
+ description: Testo utilizzato sul pulsante di revoca
+ private:
+ label: Privato?
+ description: Mantieni privato lo stato dell'informativa per gli amministratori
+ send-email:
+ label: Inviare e-mail?
+ description: Avvisa gli utenti della nuova informativa via e-mail
+ preferences:
+ title: Informative
+ policy_emails:
+ always_description: Ti invieremo un'e-mail solo se hai scelto anche di ricevere le e-mail per le nuove attività.
+ away_description: Ti invieremo un'e-mail solo se non ti sei fatto vedere negli ultimi 10 minuti quando lo stato dell'informativa cambia e solo se hai scelto anche di ricevere le e-mail per le nuove attività.
+ label: Inviami un'e-mail quando un'informativa necessita della mia revisione
+ email_frequency_options:
+ never: Mai
+ when_away: Solo quando non sono collegato
+ always: Sempre
diff --git a/plugins/discourse-policy/config/locales/client.ja.yml b/plugins/discourse-policy/config/locales/client.ja.yml
new file mode 100644
index 00000000000..fb0ebecbdb7
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.ja.yml
@@ -0,0 +1,62 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ja:
+ js:
+ discourse_policy:
+ title: "ポリシー"
+ accepted_tooltip: "このポリシーに同意したユーザー"
+ not_accepted_tooltip: "このポリシーに同意していないユーザー"
+ accept_policy: "ポリシーに同意"
+ revoke_policy: "ポリシーへの同意を取り消す"
+ edit_reason: "ポリシーの設定が変更されました"
+ no_possible_users: "このポリシーには可能なユーザーがいません"
+ accept_policy_template: "このポリシーに同意します"
+ builder:
+ title: ポリシー
+ attach: ポリシーを作成
+ save: 変更を保存 
+ insert: 挿入
+ errors:
+ group: グループが必要です
+ version: バージョンが必要です
+ groups:
+ label: グループ
+ description: このポリシーに関連付けられているグループ
+ version:
+ label: バージョン
+ description: ポリシーのバージョン。バージョンを上げると、ユーザーはそれに同意し直する必要があります
+ renew:
+ label: 更新
+ description: x 日ごとにポリシーを更新します
+ renew-start:
+ label: 更新開始
+ description: ポリシーの更新が必要となったとき
+ reminder:
+ label: リマインダー
+ description: ポリシーへの同意に関するリマインダー通知を送信する頻度
+ accept:
+ label: 同意
+ description: 同意ボタンに使用するテキスト
+ revoke:
+ label: 同意を取り消す
+ description: 同意の取り消しボタンに使用するテキスト
+ private:
+ label: 非公開?
+ description: ポリシーステータスを管理者に非公開にします
+ send-email:
+ label: メールを送信?
+ description: ユーザーにメールで新しいポリシーを通知する
+ preferences:
+ title: ポリシー
+ policy_emails:
+ always_description: 新しいアクティビティメールもオプトインしている場合にのみ、メールが送信されます。
+ away_description: ポリシーのステータスが変更された時点で 10 分以上アクセスがない場合で、新しいアクティビティメールにオプトインしている場合にのみ、メールを送信します。
+ label: ポリシーをレビューする必要がある場合にメールで通知を受け取る
+ email_frequency_options:
+ never: なし
+ when_away: 退席中の時のみ
+ always: 常時
diff --git a/plugins/discourse-policy/config/locales/client.ko.yml b/plugins/discourse-policy/config/locales/client.ko.yml
new file mode 100644
index 00000000000..fd7ea39639e
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.ko.yml
@@ -0,0 +1,29 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ko:
+ js:
+ discourse_policy:
+ builder:
+ insert: 삽입
+ groups:
+ label: 그룹
+ version:
+ label: 버전
+ accept:
+ label: 동의
+ revoke:
+ label: 취소
+ private:
+ label: 비공개?
+ send-email:
+ label: 이메일 보내기?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: 알림 받지 않기
+ when_away: 자리를 비울 때만
+ always: 항상
diff --git a/plugins/discourse-policy/config/locales/client.lt.yml b/plugins/discourse-policy/config/locales/client.lt.yml
new file mode 100644
index 00000000000..9a1f53291fe
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.lt.yml
@@ -0,0 +1,28 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+lt:
+ js:
+ discourse_policy:
+ builder:
+ insert: Įterpti
+ groups:
+ label: Grupės
+ version:
+ label: Versija
+ accept:
+ label: Priimti
+ revoke:
+ label: Pašalinti
+ private:
+ label: Privati?
+ send-email:
+ label: Siųsti e-paštą?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Niekada
+ always: Visada
diff --git a/plugins/discourse-policy/config/locales/client.lv.yml b/plugins/discourse-policy/config/locales/client.lv.yml
new file mode 100644
index 00000000000..037d1116b7e
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.lv.yml
@@ -0,0 +1,26 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+lv:
+ js:
+ discourse_policy:
+ builder:
+ insert: Ievietot
+ groups:
+ label: Grupas
+ version:
+ label: Versij
+ accept:
+ label: Apstiprināt
+ revoke:
+ label: Atsaukt
+ private:
+ label: Privāts?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Nekad
+ always: Vienmēr
diff --git a/plugins/discourse-policy/config/locales/client.nb_NO.yml b/plugins/discourse-policy/config/locales/client.nb_NO.yml
new file mode 100644
index 00000000000..3397d7b2d34
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.nb_NO.yml
@@ -0,0 +1,28 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+nb_NO:
+ js:
+ discourse_policy:
+ builder:
+ insert: Sett inn
+ groups:
+ label: Grupper
+ version:
+ label: Versjon
+ accept:
+ label: Godta
+ revoke:
+ label: Trekk tilbake
+ private:
+ label: Privat?
+ send-email:
+ label: Send e-post?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Aldri
+ always: Alltid
diff --git a/plugins/discourse-policy/config/locales/client.nl.yml b/plugins/discourse-policy/config/locales/client.nl.yml
new file mode 100644
index 00000000000..c0f696c5292
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.nl.yml
@@ -0,0 +1,62 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+nl:
+ js:
+ discourse_policy:
+ title: "Beleid"
+ accepted_tooltip: "Gebruikers die dit beleid hebben geaccepteerd"
+ not_accepted_tooltip: "Gebruikers die dit beleid niet hebben geaccepteerd"
+ accept_policy: "Beleid accepteren"
+ revoke_policy: "Beleid intrekken"
+ edit_reason: "Beleidsinstellingen zijn gewijzigd"
+ no_possible_users: "Dit beleid heeft geen mogelijke gebruikers"
+ accept_policy_template: "Ik ga akkoord met dit beleid"
+ builder:
+ title: Beleid
+ attach: Beleid maken
+ save: Wijzigingen opslaan
+ insert: Invoegen
+ errors:
+ group: Groep is vereist
+ version: Versie is vereist
+ groups:
+ label: Groepen
+ description: De groepen die aan dit beleid zijn gekoppeld
+ version:
+ label: Versie
+ description: De versie van het beleid, door de versie op te hogen, worden mensen gedwongen om het opnieuw te accepteren
+ renew:
+ label: Vernieuwen
+ description: Vernieuw het beleid elke x dagen
+ renew-start:
+ label: Begin vernieuwen
+ description: Wanneer het beleid moet worden vernieuwd
+ reminder:
+ label: Herinnering
+ description: Hoe vaak een herinneringsmelding moet worden gestuurd om het beleid te accepteren
+ accept:
+ label: Accepteren
+ description: Tekst op de accepteerknop
+ revoke:
+ label: Intrekken
+ description: Tekst op de intrekknop
+ private:
+ label: Privé?
+ description: Beleidsstatus privé houden voor beheerders
+ send-email:
+ label: E-mail sturen?
+ description: Gebruikers per e-mail op de hoogte brengen van het nieuwe beleid
+ preferences:
+ title: Beleid
+ policy_emails:
+ always_description: We sturen je alleen een e-mail als je je ook hebt aangemeld voor e-mails over nieuwe activiteit.
+ away_description: We sturen je alleen een e-mail als we je de afgelopen 10 minuten niet hebben gezien wanneer de beleidsstatus wijzigt en alleen als je je ook hebt aangemeld voor e-mails over nieuwe activiteit.
+ label: E-mail mij als een beleid mijn beoordeling vereist
+ email_frequency_options:
+ never: Nooit
+ when_away: Alleen wanneer afwezig
+ always: Altijd
diff --git a/plugins/discourse-policy/config/locales/client.pl_PL.yml b/plugins/discourse-policy/config/locales/client.pl_PL.yml
new file mode 100644
index 00000000000..56638a5e6a1
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.pl_PL.yml
@@ -0,0 +1,29 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+pl_PL:
+ js:
+ discourse_policy:
+ builder:
+ insert: Wstaw
+ groups:
+ label: Grupy
+ version:
+ label: Wersja
+ accept:
+ label: Zaakceptuj
+ revoke:
+ label: Odbierz
+ private:
+ label: Prywatna?
+ send-email:
+ label: Wyślij Email?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Nigdy
+ when_away: Tylko gdy jesteś daleko
+ always: Zawsze
diff --git a/plugins/discourse-policy/config/locales/client.pt.yml b/plugins/discourse-policy/config/locales/client.pt.yml
new file mode 100644
index 00000000000..829ad5d8223
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.pt.yml
@@ -0,0 +1,28 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+pt:
+ js:
+ discourse_policy:
+ builder:
+ insert: Inserir
+ groups:
+ label: Grupos
+ version:
+ label: Versão
+ accept:
+ label: Aceitar
+ revoke:
+ label: Revogar
+ private:
+ label: Privado?
+ send-email:
+ label: Enviar Email?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Nunca
+ always: Sempre
diff --git a/plugins/discourse-policy/config/locales/client.pt_BR.yml b/plugins/discourse-policy/config/locales/client.pt_BR.yml
new file mode 100644
index 00000000000..ffd080121c4
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.pt_BR.yml
@@ -0,0 +1,62 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+pt_BR:
+ js:
+ discourse_policy:
+ title: "Política"
+ accepted_tooltip: "Usuários(as) que aceitaram esta política"
+ not_accepted_tooltip: "Usuários(as) que não aceitaram esta política"
+ accept_policy: "Aceitar política"
+ revoke_policy: "Revogar política"
+ edit_reason: "Configurações de política foram modificadas"
+ no_possible_users: "Esta política não tem usuários possíveis"
+ accept_policy_template: "Aceito esta política"
+ builder:
+ title: Política
+ attach: Criar política
+ save: Salvar alterações
+ insert: Inserir
+ errors:
+ group: O grupo é obrigatório
+ version: A versão é obrigatória
+ groups:
+ label: Grupos
+ description: Os grupos associados a esta política
+ version:
+ label: Versão
+ description: A versão da política, promover a versão obrigará as pessoas a aceitá-la novamente
+ renew:
+ label: Renovar
+ description: Renovar a política a cada x dias
+ renew-start:
+ label: Início da renovação
+ description: Quando a política deve ser renovada
+ reminder:
+ label: Lembrete
+ description: Frequência com que a notificação de lembrete para aceitar a política deve ser enviada
+ accept:
+ label: Aceitar
+ description: Texto usado no botão de aceitar
+ revoke:
+ label: Revogar
+ description: Texto usado no botão de revogar
+ private:
+ label: Privado?
+ description: Manter o status da política privado para administradores(as)
+ send-email:
+ label: Enviar e-mail?
+ description: Notifique os usuários da nova política por e-mail
+ preferences:
+ title: Políticas
+ policy_emails:
+ always_description: Só enviaremos um e-mail se você também tiver optado por receber novos e-mails de atividades.
+ away_description: Só enviaremos um e-mail se não o tivermos visto nos últimos 10 minutos quando o status da política for alterado e somente se você também tiver optado por receber novos e-mails de atividades.
+ label: Envie um e-mail para mim quando uma política precisar da minha revisão
+ email_frequency_options:
+ never: Nunca
+ when_away: Só quando estiver ausente
+ always: Sempre
diff --git a/plugins/discourse-policy/config/locales/client.ro.yml b/plugins/discourse-policy/config/locales/client.ro.yml
new file mode 100644
index 00000000000..d7b53de3ea6
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.ro.yml
@@ -0,0 +1,28 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ro:
+ js:
+ discourse_policy:
+ builder:
+ insert: Introdu
+ groups:
+ label: Grupuri
+ version:
+ label: Versiune
+ accept:
+ label: Acceptă
+ revoke:
+ label: Revocă
+ private:
+ label: Privat?
+ send-email:
+ label: Trimite email?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Niciodată
+ always: Întotdeauna
diff --git a/plugins/discourse-policy/config/locales/client.ru.yml b/plugins/discourse-policy/config/locales/client.ru.yml
new file mode 100644
index 00000000000..f23ee2fca0b
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.ru.yml
@@ -0,0 +1,62 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ru:
+ js:
+ discourse_policy:
+ title: "Политика"
+ accepted_tooltip: "Пользователи, принявшие эту политику"
+ not_accepted_tooltip: "Пользователи, которые не приняли эту политику"
+ accept_policy: "Принять политику"
+ revoke_policy: "Отказаться от политики"
+ edit_reason: "Настройки политики были изменены"
+ no_possible_users: "У этой политики нет пользователей"
+ accept_policy_template: "Я принимаю эту политику"
+ builder:
+ title: Политика
+ attach: Создать политику
+ save: Сохранить изменения
+ insert: Вставить
+ errors:
+ group: Требуется группа
+ version: Требуется версия
+ groups:
+ label: Группы
+ description: Группы, связанные с этой политикой
+ version:
+ label: Версии
+ description: Версия политики, при изменении версии политики её необходимо принять заново
+ renew:
+ label: Обновить
+ description: Обновлять политику каждые x дней
+ renew-start:
+ label: Начать обновление
+ description: Когда политика должна быть возобновлена
+ reminder:
+ label: Напоминание
+ description: Как часто следует отправлять напоминания о принятии политики
+ accept:
+ label: Принять
+ description: Текст, используемый на кнопке «Принять»
+ revoke:
+ label: Отмена
+ description: Текст, используемый на кнопке отмены
+ private:
+ label: Приватные?
+ description: Сохранить статус политики приватным для администраторов
+ send-email:
+ label: Отправить письмо?
+ description: Уведомлять пользователей о новой политике по электронной почте
+ preferences:
+ title: Политики
+ policy_emails:
+ always_description: Мы отправим вам письмо, только если вы также согласились получать письма о новых действиях.
+ away_description: Мы отправим вам письмо, только если вас не было в течение последних 10 минут после изменения статуса политики и вы согласились получать письма о новых действиях.
+ label: Отправлять письмо, когда политика нуждается в проверке
+ email_frequency_options:
+ never: Никогда
+ when_away: Если вы находитесь офлайн
+ always: Всегда
diff --git a/plugins/discourse-policy/config/locales/client.sk.yml b/plugins/discourse-policy/config/locales/client.sk.yml
new file mode 100644
index 00000000000..28183842a6c
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.sk.yml
@@ -0,0 +1,29 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sk:
+ js:
+ discourse_policy:
+ builder:
+ insert: Vložiť
+ groups:
+ label: Skupiny
+ version:
+ label: Verzia
+ accept:
+ label: Prijať
+ revoke:
+ label: Zrušiť
+ private:
+ label: Súkromné?
+ send-email:
+ label: Poslať email?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Nikdy
+ when_away: Len keď je preč
+ always: Vždy
diff --git a/plugins/discourse-policy/config/locales/client.sl.yml b/plugins/discourse-policy/config/locales/client.sl.yml
new file mode 100644
index 00000000000..c0033a7cd81
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.sl.yml
@@ -0,0 +1,28 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sl:
+ js:
+ discourse_policy:
+ builder:
+ insert: Dodaj
+ groups:
+ label: Skupine
+ version:
+ label: Verzija
+ accept:
+ label: Odobri
+ revoke:
+ label: Odstrani
+ private:
+ label: Zasebno?
+ send-email:
+ label: Pošlji e-sporočilo?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Nikoli
+ always: Vedno
diff --git a/plugins/discourse-policy/config/locales/client.sq.yml b/plugins/discourse-policy/config/locales/client.sq.yml
new file mode 100644
index 00000000000..9f59b1ec8c1
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.sq.yml
@@ -0,0 +1,23 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sq:
+ js:
+ discourse_policy:
+ builder:
+ groups:
+ label: Grupet
+ version:
+ label: Versioni
+ revoke:
+ label: Revoko
+ send-email:
+ label: Dërgo Email?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Asnjëherë
+ always: Gjithmonë
diff --git a/plugins/discourse-policy/config/locales/client.sr.yml b/plugins/discourse-policy/config/locales/client.sr.yml
new file mode 100644
index 00000000000..66e4ec65140
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.sr.yml
@@ -0,0 +1,21 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sr:
+ js:
+ discourse_policy:
+ builder:
+ groups:
+ label: Grupe
+ version:
+ label: Verzija
+ revoke:
+ label: Povuci
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Nikad
+ always: Uvek
diff --git a/plugins/discourse-policy/config/locales/client.sv.yml b/plugins/discourse-policy/config/locales/client.sv.yml
new file mode 100644
index 00000000000..6ce13ae9a75
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.sv.yml
@@ -0,0 +1,55 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sv:
+ js:
+ discourse_policy:
+ title: "Policy"
+ accepted_tooltip: "Användare som har godkänt denna policy"
+ not_accepted_tooltip: "Användare som inte har godkänt denna policy"
+ accept_policy: "Godkänn policy"
+ revoke_policy: "Återkalla policy"
+ edit_reason: "Policyinställningarna har ändrats"
+ no_possible_users: "Denna policy har inga möjliga användare"
+ builder:
+ title: Policy
+ attach: Skapa policy
+ save: Spara ändringar
+ insert: Infoga
+ errors:
+ group: Grupp krävs
+ version: Version krävs
+ groups:
+ label: Grupper
+ description: Grupperna som är associerade till denna policy
+ version:
+ label: Version
+ description: Policyversionen, om versionen knuffas kommer detta att tvinga människor att godkänna den igen
+ renew:
+ label: Förnya
+ description: Förnya policyn var x:e dag
+ renew-start:
+ label: Förnya, start
+ description: När policyn ska förnyas
+ reminder:
+ label: Påminnelse
+ description: Hur ofta en påminnelse om att godkänna policyn ska skickas
+ accept:
+ label: Godkänn
+ description: Text som används på godkännandeknappen
+ revoke:
+ label: Återkalla
+ description: Text som används på återkallningsknappen
+ private:
+ label: Privat?
+ description: Håll policystatus privat för administratörer
+ send-email:
+ label: Skicka e-post?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Aldrig
+ always: Alltid
diff --git a/plugins/discourse-policy/config/locales/client.sw.yml b/plugins/discourse-policy/config/locales/client.sw.yml
new file mode 100644
index 00000000000..3eab6a30cac
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.sw.yml
@@ -0,0 +1,26 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sw:
+ js:
+ discourse_policy:
+ builder:
+ insert: Weka
+ groups:
+ label: Vikundi
+ version:
+ label: Toleo
+ revoke:
+ label: Futa
+ private:
+ label: Binafsi?
+ send-email:
+ label: Tuma Barua Pepe?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Kamwe
+ always: Mara kwa mara
diff --git a/plugins/discourse-policy/config/locales/client.te.yml b/plugins/discourse-policy/config/locales/client.te.yml
new file mode 100644
index 00000000000..81db65ed5f5
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.te.yml
@@ -0,0 +1,23 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+te:
+ js:
+ discourse_policy:
+ builder:
+ groups:
+ label: గుంపులు
+ version:
+ label: సంచిక
+ accept:
+ label: అంగీకరించండి
+ revoke:
+ label: రివోక్
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: ఎప్పటికీ వద్దు
+ always: ఎల్లప్పుడూ
diff --git a/plugins/discourse-policy/config/locales/client.th.yml b/plugins/discourse-policy/config/locales/client.th.yml
new file mode 100644
index 00000000000..9e7abba8862
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.th.yml
@@ -0,0 +1,26 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+th:
+ js:
+ discourse_policy:
+ builder:
+ insert: แทรก
+ groups:
+ label: กลุ่ม
+ version:
+ label: เวอร์ชัน
+ accept:
+ label: ยอมรับ
+ revoke:
+ label: เอาออก
+ private:
+ label: ส่วนตัว?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: ไม่เคย
+ always: เสมอ
diff --git a/plugins/discourse-policy/config/locales/client.tr_TR.yml b/plugins/discourse-policy/config/locales/client.tr_TR.yml
new file mode 100644
index 00000000000..e878af8c16d
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.tr_TR.yml
@@ -0,0 +1,62 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+tr_TR:
+ js:
+ discourse_policy:
+ title: "Politika"
+ accepted_tooltip: "Bu politikayı kabul eden kullanıcılar"
+ not_accepted_tooltip: "Bu politikayı kabul etmeyen kullanıcılar"
+ accept_policy: "Politikayı Kabul Et"
+ revoke_policy: "İptal Politikası"
+ edit_reason: "Politika ayarları değiştirildi"
+ no_possible_users: "Bu politikanın olası kullanıcısı yok"
+ accept_policy_template: "Bu politikayı kabul ediyorum"
+ builder:
+ title: Politika
+ attach: Politika Oluştur
+ save: Değişiklikleri kaydet
+ insert: Ekle
+ errors:
+ group: Grup gerekli
+ version: Sürüm gerekli
+ groups:
+ label: Gruplar
+ description: Bu politika ile ilişkili gruplar
+ version:
+ label: Sürüm
+ description: Politikanın sürümü, sürümün yükseltilmesi, insanları yeniden kabul etmeye zorlar
+ renew:
+ label: Yenile
+ description: Politikayı her x günde bir yenileyin
+ renew-start:
+ label: Yenileme Başlangıcı
+ description: Politikanın ne zaman yenilenmesi gerektiği
+ reminder:
+ label: Hatırlatma
+ description: Politikayı kabul etmek için hatırlatma bildiriminin ne sıklıkla gönderilmesi gerektiği
+ accept:
+ label: Kabul et
+ description: Kabul et düğmesinde kullanılan metin
+ revoke:
+ label: İptal Et
+ description: İptal düğmesinde kullanılan metin
+ private:
+ label: Özel?
+ description: Politika durumunu yöneticilere gizli tutun
+ send-email:
+ label: E-posta gönderilsin mi?
+ description: Kullanıcıları yeni politikadan e-posta ile haberdar edin
+ preferences:
+ title: Politikalar
+ policy_emails:
+ always_description: Size yalnızca yeni etkinlik e-postalarını da seçtiyseniz e-posta göndereceğiz.
+ away_description: Sadece politika durumu değiştiğinde sizi son 10 dakika içinde görmediysek ve sadece yeni etkinlik e-postalarını da seçtiyseniz size e-posta göndeririz.
+ label: İncelemem gereken bir politika olduğunda bana e-posta gönderin
+ email_frequency_options:
+ never: Asla
+ when_away: Yalnızca uzaktayken
+ always: Her zaman
diff --git a/plugins/discourse-policy/config/locales/client.ug.yml b/plugins/discourse-policy/config/locales/client.ug.yml
new file mode 100644
index 00000000000..7728f71aaf0
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.ug.yml
@@ -0,0 +1,29 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ug:
+ js:
+ discourse_policy:
+ builder:
+ insert: قىستۇر
+ groups:
+ label: گۇرۇپپا
+ version:
+ label: نەشرى
+ accept:
+ label: قوشۇل
+ revoke:
+ label: بىكار قىل
+ private:
+ label: شەخسىي?
+ send-email:
+ label: ئېلخەت يوللا?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: ھەرگىز
+ when_away: ئايرىلغاندىلا
+ always: ھەمىشە
diff --git a/plugins/discourse-policy/config/locales/client.uk.yml b/plugins/discourse-policy/config/locales/client.uk.yml
new file mode 100644
index 00000000000..85127255e9f
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.uk.yml
@@ -0,0 +1,29 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+uk:
+ js:
+ discourse_policy:
+ builder:
+ insert: Вставити
+ groups:
+ label: Групи
+ version:
+ label: Версія
+ accept:
+ label: Схвалити
+ revoke:
+ label: Відкликати
+ private:
+ label: Приватні?
+ send-email:
+ label: Відправити лист?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Ніколи
+ when_away: Тільки коли офлайн
+ always: Завжди
diff --git a/plugins/discourse-policy/config/locales/client.ur.yml b/plugins/discourse-policy/config/locales/client.ur.yml
new file mode 100644
index 00000000000..c98e5949509
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.ur.yml
@@ -0,0 +1,28 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ur:
+ js:
+ discourse_policy:
+ builder:
+ insert: شامل
+ groups:
+ label: گروپس
+ version:
+ label: ورژن
+ accept:
+ label: منظور
+ revoke:
+ label: منسوخ کریں
+ private:
+ label: ذاتی?
+ send-email:
+ label: اِیمیل بھیجیں?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: کبھی نہیں
+ always: ہمیشہ
diff --git a/plugins/discourse-policy/config/locales/client.vi.yml b/plugins/discourse-policy/config/locales/client.vi.yml
new file mode 100644
index 00000000000..3773e9731ec
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.vi.yml
@@ -0,0 +1,28 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+vi:
+ js:
+ discourse_policy:
+ builder:
+ insert: Chèn
+ groups:
+ label: Nhóm
+ version:
+ label: Phiên bản
+ accept:
+ label: Chấp nhận
+ revoke:
+ label: Thu hồi
+ private:
+ label: Riêng tư?
+ send-email:
+ label: Gửi email?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: Không bao giờ
+ always: Luôn luôn
diff --git a/plugins/discourse-policy/config/locales/client.zh_CN.yml b/plugins/discourse-policy/config/locales/client.zh_CN.yml
new file mode 100644
index 00000000000..371ed2f3081
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.zh_CN.yml
@@ -0,0 +1,62 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+zh_CN:
+ js:
+ discourse_policy:
+ title: "策略"
+ accepted_tooltip: "已接受此策略的用户"
+ not_accepted_tooltip: "未接受此策略的用户"
+ accept_policy: "接受策略"
+ revoke_policy: "撤销策略"
+ edit_reason: "策略设置已被修改"
+ no_possible_users: "此策略没有可能的用户"
+ accept_policy_template: "我接受此政策"
+ builder:
+ title: 策略
+ attach: 创建策略
+ save: 保存变更
+ insert: 插入
+ errors:
+ group: 群组为必填项
+ version: 版本为必填项
+ groups:
+ label: 群组
+ description: 与此策略关联的群组
+ version:
+ label: 版本
+ description: 策略的版本,提升版本将强制相关人员重新接受
+ renew:
+ label: 更新
+ description: 每 x 天更新一次策略
+ renew-start:
+ label: 更新开始
+ description: 策略应在何时更新
+ reminder:
+ label: 提醒
+ description: 发送接受策略提醒通知的频率
+ accept:
+ label: 接受
+ description: 接受按钮上使用的文本
+ revoke:
+ label: 撤销
+ description: 撤销按钮上使用的文本
+ private:
+ label: 不公开?
+ description: 将策略状态对管理员保密
+ send-email:
+ label: 发送电子邮件?
+ description: 通过电子邮件通知用户新策略
+ preferences:
+ title: 策略
+ policy_emails:
+ always_description: 仅当您还选择了接收新的活动电子邮件时,我们才会向您发送电子邮件。
+ away_description: 仅当我们在策略状态发生更改的 10 分钟内没有看到您,并且您还选择了接收新的活动电子邮件时,我们才会给您发送电子邮件。
+ label: 当策略需要我审核时给我发送电子邮件
+ email_frequency_options:
+ never: 永不
+ when_away: 仅在离开时
+ always: 始终
diff --git a/plugins/discourse-policy/config/locales/client.zh_TW.yml b/plugins/discourse-policy/config/locales/client.zh_TW.yml
new file mode 100644
index 00000000000..ed4184bb971
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/client.zh_TW.yml
@@ -0,0 +1,28 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+zh_TW:
+ js:
+ discourse_policy:
+ builder:
+ insert: 插入
+ groups:
+ label: 群組
+ version:
+ label: 版本
+ accept:
+ label: 接受
+ revoke:
+ label: 撤回
+ private:
+ label: 私密?
+ send-email:
+ label: 送出電子郵件?
+ preferences:
+ policy_emails:
+ email_frequency_options:
+ never: 永不
+ always: 總是
diff --git a/plugins/discourse-policy/config/locales/server.ar.yml b/plugins/discourse-policy/config/locales/server.ar.yml
new file mode 100644
index 00000000000..cc649fc8aff
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.ar.yml
@@ -0,0 +1,37 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ar:
+ site_settings:
+ policy_enabled: "هل تريد السماح بالسياسات؟"
+ policy_restrict_to_staff_posts: "قد لا تظهر السياسات إلا على منشورات فريق العمل"
+ policy_easy_revoke: "عرض زرَّي القبول والإلغاء في الوقت نفسه"
+ discourse_policy:
+ errors:
+ user_missing: "المستخدم غير موجود في المجموعة"
+ group_not_found: "لم يتم العثور على المجموعة للسياسة"
+ no_policy: "لا توجد سياسة للمنشور"
+ staff_only: "قد تنطبق السياسات على فريق العمل فقط"
+ reports:
+ unaccepted-policies:
+ title: سياسات غير مقبولة
+ labels:
+ topic_id: معرِّف الموضوع
+ user_id: معرِّف المستخدم
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ subject: "تحتاج إحدى السياسات إلى مراجعتك: %{topic_title}"
+ visit_topic: "الانتقال إلى الموضوع"
+ visit_link_to_respond: "%{visit_topic_link} للرد."
+ unsubscribe: "قم بتغيير %{email_preferences_link}أو %{unsubscribe_link} لإلغاء الاشتراك."
+ your_policy_email_settings: "تفضيل مدى تكرار الرسائل الإلكترونية للسياسة"
+ unsubscribe:
+ policy_emails:
+ select_title: "ضبط مدى تكرار الرسائل الإلكترونية لتنبيه السياسة على:"
+ never: أبدًا
+ when_away: عندما أكون غائبًا فقط
+ always: دائمًا
diff --git a/plugins/discourse-policy/config/locales/server.be.yml b/plugins/discourse-policy/config/locales/server.be.yml
new file mode 100644
index 00000000000..9b8103c486d
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.be.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+be:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: Номер тэмы
+ unsubscribe:
+ policy_emails:
+ never: ніколі
+ always: заўсёды
diff --git a/plugins/discourse-policy/config/locales/server.bg.yml b/plugins/discourse-policy/config/locales/server.bg.yml
new file mode 100644
index 00000000000..b59e7151665
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.bg.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+bg:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: Тема ID
+ unsubscribe:
+ policy_emails:
+ never: Никога
+ always: Винаги
diff --git a/plugins/discourse-policy/config/locales/server.bs_BA.yml b/plugins/discourse-policy/config/locales/server.bs_BA.yml
new file mode 100644
index 00000000000..2a7cda41834
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.bs_BA.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+bs_BA:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ID teme
+ unsubscribe:
+ policy_emails:
+ never: Nikad
+ always: Uvijek
diff --git a/plugins/discourse-policy/config/locales/server.ca.yml b/plugins/discourse-policy/config/locales/server.ca.yml
new file mode 100644
index 00000000000..953664e66e4
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.ca.yml
@@ -0,0 +1,18 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ca:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ID de tema
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: Mai
+ always: Sempre
diff --git a/plugins/discourse-policy/config/locales/server.cs.yml b/plugins/discourse-policy/config/locales/server.cs.yml
new file mode 100644
index 00000000000..2daa0475a97
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.cs.yml
@@ -0,0 +1,16 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+cs:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ID tématu
+ unsubscribe:
+ policy_emails:
+ never: Nikdy
+ when_away: Jen v nepřítomnosti
+ always: Vždy
diff --git a/plugins/discourse-policy/config/locales/server.da.yml b/plugins/discourse-policy/config/locales/server.da.yml
new file mode 100644
index 00000000000..43c3c8ac201
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.da.yml
@@ -0,0 +1,18 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+da:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: Emne ID
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: Aldrig
+ always: Altid
diff --git a/plugins/discourse-policy/config/locales/server.de.yml b/plugins/discourse-policy/config/locales/server.de.yml
new file mode 100644
index 00000000000..af6565b66f5
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.de.yml
@@ -0,0 +1,39 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+de:
+ site_settings:
+ policy_enabled: "Richtlinien zulassen?"
+ policy_restrict_to_staff_posts: "Richtlinien dürfen nur in Team-Beiträgen erscheinen"
+ policy_easy_revoke: "Die Schaltflächen „Akzeptieren“ und „Widerrufen“ gleichzeitig anzeigen"
+ discourse_policy:
+ errors:
+ user_missing: "Benutzer existiert nicht in der Gruppe"
+ group_not_found: "Gruppe für Richtlinie nicht gefunden"
+ no_policy: "Keine Richtlinie für Beitrag vorhanden"
+ staff_only: "Richtlinien dürfen nur auf Team-Beiträge angewendet werden"
+ error:
+ no_permission: "Nicht autorisiert"
+ reports:
+ unaccepted-policies:
+ title: Nicht akzeptierte Richtlinien
+ labels:
+ topic_id: Themen-ID
+ user_id: Benutzer-ID
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ subject: "Eine Richtlinie benötigt deine Überprüfung: %{topic_title}"
+ visit_topic: "Thema besuchen"
+ visit_link_to_respond: "%{visit_topic_link}, um zu antworten."
+ unsubscribe: "Ändere deine %{email_preferences_link} oder %{unsubscribe_link}, um dich abzumelden."
+ your_policy_email_settings: "Präferenz für die Häufigkeit von Richtlinien-E-Mails"
+ unsubscribe:
+ policy_emails:
+ select_title: "Setze die Häufigkeit für Richtlinien-E-Mails auf:"
+ never: Nie
+ when_away: Nur bei Abwesenheit
+ always: Immer
diff --git a/plugins/discourse-policy/config/locales/server.el.yml b/plugins/discourse-policy/config/locales/server.el.yml
new file mode 100644
index 00000000000..44306de61da
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.el.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+el:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: Topic ID
+ unsubscribe:
+ policy_emails:
+ never: Ποτέ
+ always: Πάντα
diff --git a/plugins/discourse-policy/config/locales/server.en.yml b/plugins/discourse-policy/config/locales/server.en.yml
new file mode 100644
index 00000000000..00d21011648
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.en.yml
@@ -0,0 +1,34 @@
+en:
+ site_settings:
+ policy_enabled: "Allow policies?"
+ policy_restrict_to_staff_posts: "Policies may only appear on staff posts"
+ policy_easy_revoke: "Show the accept and revoke buttons at the same time"
+ discourse_policy:
+ errors:
+ user_missing: "User does not exist in group"
+ group_not_found: "Group not found for policy"
+ no_policy: "No policy exists for post"
+ staff_only: "Policies may only apply to staff posts"
+ error:
+ no_permission: "Not authorized"
+ reports:
+ unaccepted-policies:
+ title: Unaccepted policies
+ labels:
+ topic_id: Topic ID
+ user_id: User ID
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ subject: "A policy needs your review: %{topic_title}"
+ visit_topic: "Visit Topic"
+ visit_link_to_respond: "%{visit_topic_link} to respond."
+ unsubscribe: "Change your %{email_preferences_link}, or %{unsubscribe_link} to unsubscribe."
+ your_policy_email_settings: "policy emails frequency preference"
+ unsubscribe:
+ policy_emails:
+ select_title: "Set policy alert emails frequency to:"
+ never: Never
+ when_away: Only when away
+ always: Always
+
diff --git a/plugins/discourse-policy/config/locales/server.en_GB.yml b/plugins/discourse-policy/config/locales/server.en_GB.yml
new file mode 100644
index 00000000000..2d4fa180ec7
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.en_GB.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+en_GB:
diff --git a/plugins/discourse-policy/config/locales/server.es.yml b/plugins/discourse-policy/config/locales/server.es.yml
new file mode 100644
index 00000000000..2064a48546d
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.es.yml
@@ -0,0 +1,37 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+es:
+ site_settings:
+ policy_enabled: "¿Permitir políticas?"
+ policy_restrict_to_staff_posts: "Las políticas solo pueden aparecer en las publicaciones del personal"
+ policy_easy_revoke: "Mostrar los botones aceptar y revocar al mismo tiempo"
+ discourse_policy:
+ errors:
+ user_missing: "El usuario no existe en el grupo"
+ group_not_found: "Grupo no encontrado para la política"
+ no_policy: "No existe ninguna política para la publicación"
+ staff_only: "Es posible que las políticas solo se apliquen a las publicaciones del personal"
+ reports:
+ unaccepted-policies:
+ title: Políticas no aceptadas
+ labels:
+ topic_id: ID del tema
+ user_id: ID de usuario
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ subject: "Una política necesita su revisión: %{topic_title}"
+ visit_topic: "Visitar tema"
+ visit_link_to_respond: "%{visit_topic_link} para responder."
+ unsubscribe: "Cambia tus %{email_preferences_link}, o %{unsubscribe_link} para darte de baja."
+ your_policy_email_settings: "preferencia de frecuencia de correos electrónicos de política"
+ unsubscribe:
+ policy_emails:
+ select_title: "Establecer la frecuencia de correo electrónico de alerta de política a:"
+ never: Nunca
+ when_away: Solo cuando no esté en la página
+ always: Siempre
diff --git a/plugins/discourse-policy/config/locales/server.et.yml b/plugins/discourse-policy/config/locales/server.et.yml
new file mode 100644
index 00000000000..0fa6f50cf7b
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.et.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+et:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: Teema ID
+ unsubscribe:
+ policy_emails:
+ never: Mitte kunagi
+ always: Alati
diff --git a/plugins/discourse-policy/config/locales/server.fa_IR.yml b/plugins/discourse-policy/config/locales/server.fa_IR.yml
new file mode 100644
index 00000000000..2c29224844f
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.fa_IR.yml
@@ -0,0 +1,20 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+fa_IR:
+ reports:
+ unaccepted-policies:
+ title: سیاست‌های پذیرفته نشده
+ labels:
+ topic_id: شناسه موضوع
+ user_id: شناسه کاربر
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: هرگز
+ always: همیشه
diff --git a/plugins/discourse-policy/config/locales/server.fi.yml b/plugins/discourse-policy/config/locales/server.fi.yml
new file mode 100644
index 00000000000..80803a6e05a
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.fi.yml
@@ -0,0 +1,37 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+fi:
+ site_settings:
+ policy_enabled: "Sallitaanko käytännöt?"
+ policy_restrict_to_staff_posts: "Käytännöt voivat näkyä vain henkilökunnan viesteissä"
+ policy_easy_revoke: "Näytä hyväksymis- ja perumispainikkeet samanaikaisesti"
+ discourse_policy:
+ errors:
+ user_missing: "Käyttäjää ei ole ryhmässä"
+ group_not_found: "Ryhmää ei löydy käytännölle"
+ no_policy: "Viestille ei ole käytäntöä"
+ staff_only: "Käytännöt voivat koskea vain henkilökunnan viestejä"
+ reports:
+ unaccepted-policies:
+ title: Hyväksymättömät käytännöt
+ labels:
+ topic_id: Ketjun tunnus
+ user_id: Käyttäjätunnus
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ subject: "Käytäntö vaatii tarkistustasi: %{topic_title}"
+ visit_topic: "Vieraile ketjussa"
+ visit_link_to_respond: "%{visit_topic_link} vastataksesi."
+ unsubscribe: "Muuta %{email_preferences_link} tai %{unsubscribe_link} peruuttaaksesi tilauksen."
+ your_policy_email_settings: "käytäntösähköpostien tiheysasetustasi"
+ unsubscribe:
+ policy_emails:
+ select_title: "Aseta käytäntöhälytyssähköpostien tiheydeksi:"
+ never: Ei koskaan
+ when_away: Vain, kun olen poissa
+ always: Aina
diff --git a/plugins/discourse-policy/config/locales/server.fr.yml b/plugins/discourse-policy/config/locales/server.fr.yml
new file mode 100644
index 00000000000..6829674631d
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.fr.yml
@@ -0,0 +1,37 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+fr:
+ site_settings:
+ policy_enabled: "Autoriser les politiques ?"
+ policy_restrict_to_staff_posts: "Les politiques ne peuvent apparaître que sur les messages du personnel"
+ policy_easy_revoke: "Afficher les boutons d'acceptation et de révocation en même temps"
+ discourse_policy:
+ errors:
+ user_missing: "L'utilisateur n'existe pas dans le groupe"
+ group_not_found: "Groupe introuvable pour la politique"
+ no_policy: "Aucune politique n'existe pour le message"
+ staff_only: "Les politiques ne peuvent s'appliquer qu'aux messages du personnel"
+ reports:
+ unaccepted-policies:
+ title: Politiques non acceptées
+ labels:
+ topic_id: ID du sujet
+ user_id: Identifiant d'utilisateur
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ subject: "Une politique a besoin de votre examen : %{topic_title}"
+ visit_topic: "Consulter le sujet"
+ visit_link_to_respond: "%{visit_topic_link} pour répondre."
+ unsubscribe: "Modifiez vos %{email_preferences_link} ou %{unsubscribe_link} pour vous désabonner."
+ your_policy_email_settings: "préférences de fréquence des e-mails liés aux politiques"
+ unsubscribe:
+ policy_emails:
+ select_title: "Définissez la fréquence des e-mails d'alerte liés aux politiques sur :"
+ never: Jamais
+ when_away: Seulement en cas d'absence
+ always: Toujours
diff --git a/plugins/discourse-policy/config/locales/server.gl.yml b/plugins/discourse-policy/config/locales/server.gl.yml
new file mode 100644
index 00000000000..d6b75b27e21
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.gl.yml
@@ -0,0 +1,18 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+gl:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ID do tema
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: Nunca
+ always: Sempre
diff --git a/plugins/discourse-policy/config/locales/server.he.yml b/plugins/discourse-policy/config/locales/server.he.yml
new file mode 100644
index 00000000000..995ec8d60e1
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.he.yml
@@ -0,0 +1,39 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+he:
+ site_settings:
+ policy_enabled: "לאפשר מסמכי מדיניות?"
+ policy_restrict_to_staff_posts: "מסמכי מדיניות יכולים להופיע רק על פוסטים של סגל"
+ policy_easy_revoke: "להציג את כפתורי האישור והשלילה בו־זמנית"
+ discourse_policy:
+ errors:
+ user_missing: "המשתמש לא קיים בקבוצה"
+ group_not_found: "הקבוצה לא נמצאה לצורך מדיניות"
+ no_policy: "לא קיימת מדיניות לפוסט"
+ staff_only: "אפשר להחיל מסמכי מדיניות על פוסטים של הסגל בלבד"
+ error:
+ no_permission: "לא מורשה"
+ reports:
+ unaccepted-policies:
+ title: מדיניויות לא מקובלות
+ labels:
+ topic_id: מזהה נושא
+ user_id: מזהה משתמש
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ subject: "מדיניות דורשת את בדיקתך: %{topic_title}"
+ visit_topic: "ביקור בנושא"
+ visit_link_to_respond: "%{visit_topic_link} לתגובה."
+ unsubscribe: "אפשר לשנות את %{email_preferences_link}, או %{unsubscribe_link} כדי לבטל את המינוי."
+ your_policy_email_settings: "העדפת תדירות הודעות דוא״ל על מדיניות"
+ unsubscribe:
+ policy_emails:
+ select_title: "הגדרת תדירות הודעות התראת מדיניות שנשלחות בדוא״ל לכדי:"
+ never: לעולם לא
+ when_away: רק בעת העדרות
+ always: תמיד
diff --git a/plugins/discourse-policy/config/locales/server.hr.yml b/plugins/discourse-policy/config/locales/server.hr.yml
new file mode 100644
index 00000000000..8cd2583982e
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.hr.yml
@@ -0,0 +1,18 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+hr:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ID teme
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: Nikad
+ always: Uvijek
diff --git a/plugins/discourse-policy/config/locales/server.hu.yml b/plugins/discourse-policy/config/locales/server.hu.yml
new file mode 100644
index 00000000000..3c1198ae156
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.hu.yml
@@ -0,0 +1,18 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+hu:
+ site_settings:
+ policy_easy_revoke: "Az elfogadás és a visszavonás gombok egyidejű megjelenítése"
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: Témaazonosító
+ user_id: Felhasználói azonosító
+ unsubscribe:
+ policy_emails:
+ never: Soha
+ always: Mindig
diff --git a/plugins/discourse-policy/config/locales/server.hy.yml b/plugins/discourse-policy/config/locales/server.hy.yml
new file mode 100644
index 00000000000..7983eafac0a
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.hy.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+hy:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: Թեմայի ID
+ unsubscribe:
+ policy_emails:
+ never: Երբեք
+ always: Միշտ
diff --git a/plugins/discourse-policy/config/locales/server.id.yml b/plugins/discourse-policy/config/locales/server.id.yml
new file mode 100644
index 00000000000..9e41f23a6e9
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.id.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+id:
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: Tidak pernah
+ when_away: Hanya saat pergi
+ always: Selalu
diff --git a/plugins/discourse-policy/config/locales/server.it.yml b/plugins/discourse-policy/config/locales/server.it.yml
new file mode 100644
index 00000000000..6534f2d3ed0
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.it.yml
@@ -0,0 +1,37 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+it:
+ site_settings:
+ policy_enabled: "Consentire informative?"
+ policy_restrict_to_staff_posts: "Le informative possono apparire solo sui messaggi dello staff"
+ policy_easy_revoke: "Mostra contemporaneamente i pulsanti accetta e revoca"
+ discourse_policy:
+ errors:
+ user_missing: "Utente non esistente nel gruppo"
+ group_not_found: "Gruppo non trovato per l'informativa"
+ no_policy: "Non ci sono informative per il messaggio"
+ staff_only: "Le informative si possono applicare solo ai messaggi dello staff"
+ reports:
+ unaccepted-policies:
+ title: Informative non accettate
+ labels:
+ topic_id: ID dell'argomento
+ user_id: ID utente
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ subject: "Un'informativa richiede la tua revisione: %{topic_title}"
+ visit_topic: "Visita l'argomento"
+ visit_link_to_respond: "%{visit_topic_link} per rispondere."
+ unsubscribe: "Cambia %{email_preferences_link} o %{unsubscribe_link} per annullare l'iscrizione."
+ your_policy_email_settings: "preferenza di frequenza delle e-mail sulle informative"
+ unsubscribe:
+ policy_emails:
+ select_title: "Imposta la frequenza delle e-mail sulle informative a:"
+ never: Mai
+ when_away: Solo quando non sono collegato
+ always: Sempre
diff --git a/plugins/discourse-policy/config/locales/server.ja.yml b/plugins/discourse-policy/config/locales/server.ja.yml
new file mode 100644
index 00000000000..403cb84e25d
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.ja.yml
@@ -0,0 +1,37 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ja:
+ site_settings:
+ policy_enabled: "ポリシーを許可?"
+ policy_restrict_to_staff_posts: "ポリシーはスタッフの投稿のみに表示される場合があります"
+ policy_easy_revoke: "同意ボタンと同意の取り消しボタンを同時に表示する"
+ discourse_policy:
+ errors:
+ user_missing: "ユーザーはグループに存在しません"
+ group_not_found: "ポリシーのグループが見つかりません"
+ no_policy: "投稿にポリシーが存在しません"
+ staff_only: "ポリシーはスタッフの投稿のみに適用される場合があります"
+ reports:
+ unaccepted-policies:
+ title: 未承認のポリシー
+ labels:
+ topic_id: トピック ID
+ user_id: ユーザー ID
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ subject: "ポリシーをレビューする必要があります: %{topic_title}"
+ visit_topic: "トピックにアクセス"
+ visit_link_to_respond: "%{visit_topic_link} で回答します。"
+ unsubscribe: "%{email_preferences_link} を変更するか、%{unsubscribe_link} で購読を解除します。"
+ your_policy_email_settings: "ポリシーメールの頻度設定"
+ unsubscribe:
+ policy_emails:
+ select_title: "ポリシーアラートメールの頻度を次に設定する:"
+ never: なし
+ when_away: 退席中の時のみ
+ always: 常時
diff --git a/plugins/discourse-policy/config/locales/server.ko.yml b/plugins/discourse-policy/config/locales/server.ko.yml
new file mode 100644
index 00000000000..6c0320dc7e4
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.ko.yml
@@ -0,0 +1,19 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ko:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: 토픽 ID
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: 알림 받지 않기
+ when_away: 자리를 비울 때만
+ always: 항상
diff --git a/plugins/discourse-policy/config/locales/server.lt.yml b/plugins/discourse-policy/config/locales/server.lt.yml
new file mode 100644
index 00000000000..20cffe52ec6
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.lt.yml
@@ -0,0 +1,18 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+lt:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: Temos ID
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: Niekada
+ always: Visada
diff --git a/plugins/discourse-policy/config/locales/server.lv.yml b/plugins/discourse-policy/config/locales/server.lv.yml
new file mode 100644
index 00000000000..920bd17383a
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.lv.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+lv:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: Tēmas ID
+ unsubscribe:
+ policy_emails:
+ never: Nekad
+ always: Vienmēr
diff --git a/plugins/discourse-policy/config/locales/server.nb_NO.yml b/plugins/discourse-policy/config/locales/server.nb_NO.yml
new file mode 100644
index 00000000000..83d776b23d9
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.nb_NO.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+nb_NO:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: Emne-ID
+ unsubscribe:
+ policy_emails:
+ never: Aldri
+ always: Alltid
diff --git a/plugins/discourse-policy/config/locales/server.nl.yml b/plugins/discourse-policy/config/locales/server.nl.yml
new file mode 100644
index 00000000000..e8a5aa02f39
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.nl.yml
@@ -0,0 +1,37 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+nl:
+ site_settings:
+ policy_enabled: "Beleid toestaan?"
+ policy_restrict_to_staff_posts: "Beleid mag alleen worden weergegeven in berichten van medewerkers"
+ policy_easy_revoke: "Knoppen Accepteren en Intrekken tegelijk weergeven"
+ discourse_policy:
+ errors:
+ user_missing: "Gebruiker bestaat niet in groep"
+ group_not_found: "Groep niet gevonden voor beleid"
+ no_policy: "Er is geen beleid voor bericht"
+ staff_only: "Beleid mag alleen van toepassing zijn op berichten van medewerkers"
+ reports:
+ unaccepted-policies:
+ title: Niet-geaccepteerd beleid
+ labels:
+ topic_id: Topic-ID
+ user_id: Gebruikers-ID
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ subject: "Een beleid heeft je beoordeling nodig: %{topic_title}"
+ visit_topic: "Naar topic"
+ visit_link_to_respond: "%{visit_topic_link} om te reageren."
+ unsubscribe: "Wijzig je %{email_preferences_link}, of %{unsubscribe_link} om je af te melden."
+ your_policy_email_settings: "Voorkeursfrequentie voor beleids-e-mails"
+ unsubscribe:
+ policy_emails:
+ select_title: "Stel de frequentie van e-mails met beleidswaarschuwingen in op:"
+ never: Nooit
+ when_away: Alleen wanneer afwezig
+ always: Altijd
diff --git a/plugins/discourse-policy/config/locales/server.pl_PL.yml b/plugins/discourse-policy/config/locales/server.pl_PL.yml
new file mode 100644
index 00000000000..32b4bb54cfd
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.pl_PL.yml
@@ -0,0 +1,20 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+pl_PL:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ID tematu
+ user_id: ID użytkownika
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: Nigdy
+ when_away: Tylko gdy jesteś daleko
+ always: Zawsze
diff --git a/plugins/discourse-policy/config/locales/server.pt.yml b/plugins/discourse-policy/config/locales/server.pt.yml
new file mode 100644
index 00000000000..aac4ea04f2d
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.pt.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+pt:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ID do Tópico
+ unsubscribe:
+ policy_emails:
+ never: Nunca
+ always: Sempre
diff --git a/plugins/discourse-policy/config/locales/server.pt_BR.yml b/plugins/discourse-policy/config/locales/server.pt_BR.yml
new file mode 100644
index 00000000000..ec200670e89
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.pt_BR.yml
@@ -0,0 +1,37 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+pt_BR:
+ site_settings:
+ policy_enabled: "Permitir políticas?"
+ policy_restrict_to_staff_posts: "Políticas devem aparecer apenas nas postagens da equipe"
+ policy_easy_revoke: "Exibir os botões de aceitar e revogar ao mesmo tempo"
+ discourse_policy:
+ errors:
+ user_missing: "O(a) usuário(a) não existe no grupo"
+ group_not_found: "Grupo não encontrado para política"
+ no_policy: "Não existem políticas para a postagem"
+ staff_only: "Políticas podem ser aplicadas apenas às postagens da equipe"
+ reports:
+ unaccepted-policies:
+ title: Políticas não aceitas
+ labels:
+ topic_id: ID do tópico
+ user_id: ID do usuário
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ subject: "Uma política precisa da sua revisão: %{topic_title}"
+ visit_topic: "Visitar o tópico"
+ visit_link_to_respond: "%{visit_topic_link} para responder."
+ unsubscribe: "Altere seu %{email_preferences_link} ou %{unsubscribe_link} para cancelar a inscrição."
+ your_policy_email_settings: "preferência de frequência de e-mails de política"
+ unsubscribe:
+ policy_emails:
+ select_title: "Defina a frequência de e-mails de alerta de política para:"
+ never: Nunca
+ when_away: Somente quando estiver longe
+ always: Sempre
diff --git a/plugins/discourse-policy/config/locales/server.ro.yml b/plugins/discourse-policy/config/locales/server.ro.yml
new file mode 100644
index 00000000000..2165d651d3a
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.ro.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ro:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ID discuție
+ unsubscribe:
+ policy_emails:
+ never: Niciodată
+ always: Întotdeauna
diff --git a/plugins/discourse-policy/config/locales/server.ru.yml b/plugins/discourse-policy/config/locales/server.ru.yml
new file mode 100644
index 00000000000..d4631925d9f
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.ru.yml
@@ -0,0 +1,37 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ru:
+ site_settings:
+ policy_enabled: "Разрешить политику?"
+ policy_restrict_to_staff_posts: "Политика может применяться только к записям персонала"
+ policy_easy_revoke: "Показывать одновременно кнопки «Принять» и «Отмена»"
+ discourse_policy:
+ errors:
+ user_missing: "Пользователь не существует в группе"
+ group_not_found: "Группа не найдена"
+ no_policy: "Политики для записи не существует"
+ staff_only: "Политика может применяться только к записям персонала"
+ reports:
+ unaccepted-policies:
+ title: Непринятые политики
+ labels:
+ topic_id: ID темы
+ user_id: Идентификатор пользователя
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ subject: "Политика требует проверки: %{topic_title}"
+ visit_topic: "Открыть тему"
+ visit_link_to_respond: "Чтобы ответить, %{visit_topic_link}."
+ unsubscribe: "Для отмены подписки измените %{email_preferences_link} или %{unsubscribe_link}."
+ your_policy_email_settings: "настройки частоты писем о политиках"
+ unsubscribe:
+ policy_emails:
+ select_title: "Частота писем с оповещениями о политиках:"
+ never: Никогда
+ when_away: Если вы находитесь офлайн
+ always: Всегда
diff --git a/plugins/discourse-policy/config/locales/server.sk.yml b/plugins/discourse-policy/config/locales/server.sk.yml
new file mode 100644
index 00000000000..336b6b65a80
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.sk.yml
@@ -0,0 +1,20 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sk:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ID témy
+ user_id: ID používateľa
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: Nikdy
+ when_away: Len keď je preč
+ always: Vždy
diff --git a/plugins/discourse-policy/config/locales/server.sl.yml b/plugins/discourse-policy/config/locales/server.sl.yml
new file mode 100644
index 00000000000..9edf16f77b1
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.sl.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sl:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ID teme
+ unsubscribe:
+ policy_emails:
+ never: Nikoli
+ always: Vedno
diff --git a/plugins/discourse-policy/config/locales/server.sq.yml b/plugins/discourse-policy/config/locales/server.sq.yml
new file mode 100644
index 00000000000..63c02848496
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.sq.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sq:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ID e temës
+ unsubscribe:
+ policy_emails:
+ never: Asnjëherë
+ always: Gjithmonë
diff --git a/plugins/discourse-policy/config/locales/server.sr.yml b/plugins/discourse-policy/config/locales/server.sr.yml
new file mode 100644
index 00000000000..2e8d63b8794
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.sr.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sr:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ID Teme
+ unsubscribe:
+ policy_emails:
+ never: Nikad
+ always: Uvek
diff --git a/plugins/discourse-policy/config/locales/server.sv.yml b/plugins/discourse-policy/config/locales/server.sv.yml
new file mode 100644
index 00000000000..7a59dd47a96
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.sv.yml
@@ -0,0 +1,29 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sv:
+ site_settings:
+ policy_enabled: "Tillåter du policyer?"
+ policy_restrict_to_staff_posts: "Policyer får endast visas på personalens inlägg"
+ policy_easy_revoke: "Visa knapparna acceptera och återkalla samtidigt"
+ discourse_policy:
+ errors:
+ user_missing: "Användaren finns inte i gruppen"
+ group_not_found: "Gruppen hittades inte för policyn"
+ no_policy: "Det finns ingen policy för inlägg"
+ staff_only: "Policyer får endast gälla för personalens inlägg"
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: Ämnes-ID
+ user_id: Användar-ID
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: Aldrig
+ always: Alltid
diff --git a/plugins/discourse-policy/config/locales/server.sw.yml b/plugins/discourse-policy/config/locales/server.sw.yml
new file mode 100644
index 00000000000..8ab6d8888b8
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.sw.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sw:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: Utambulisho wa Mada
+ unsubscribe:
+ policy_emails:
+ never: Kamwe
+ always: Mara kwa mara
diff --git a/plugins/discourse-policy/config/locales/server.te.yml b/plugins/discourse-policy/config/locales/server.te.yml
new file mode 100644
index 00000000000..b5e1352a493
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.te.yml
@@ -0,0 +1,19 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+te:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: విషయపు ఐడీ
+ user_id: సభ్యుని ID
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: ఎప్పటికీ వద్దు
+ always: ఎల్లప్పుడూ
diff --git a/plugins/discourse-policy/config/locales/server.th.yml b/plugins/discourse-policy/config/locales/server.th.yml
new file mode 100644
index 00000000000..37495feba97
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.th.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+th:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: หมายเลขกระทู้
+ unsubscribe:
+ policy_emails:
+ never: ไม่เคย
+ always: เสมอ
diff --git a/plugins/discourse-policy/config/locales/server.tr_TR.yml b/plugins/discourse-policy/config/locales/server.tr_TR.yml
new file mode 100644
index 00000000000..9fd02b20513
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.tr_TR.yml
@@ -0,0 +1,37 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+tr_TR:
+ site_settings:
+ policy_enabled: "Politikalara izin verilsin mi?"
+ policy_restrict_to_staff_posts: "Politikalar yalnızca personel gönderilerinde görünebilir"
+ policy_easy_revoke: "Kabul et ve iptal et düğmelerini aynı anda göster"
+ discourse_policy:
+ errors:
+ user_missing: "Kullanıcı grupta mevcut değil"
+ group_not_found: "Politika için grup bulunamadı"
+ no_policy: "Gönderi için politika yok"
+ staff_only: "Politikalar yalnızca personel gönderileri için geçerli olabilir"
+ reports:
+ unaccepted-policies:
+ title: Kabul edilmeyen politikalar
+ labels:
+ topic_id: Konu kimliği
+ user_id: Kullanıcı kimliği
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ subject: "Bir politikayı incelemeniz gerekiyor: %{topic_title}"
+ visit_topic: "Konuyu ziyaret et"
+ visit_link_to_respond: "Yanıtlamak için %{visit_topic_link}."
+ unsubscribe: "Aboneliğinizi iptal etmek için %{email_preferences_link} veya %{unsubscribe_link} bağlantınızı değiştirin."
+ your_policy_email_settings: "politika e-postaları sıklığı tercihi"
+ unsubscribe:
+ policy_emails:
+ select_title: "Politika uyarısı e-postalarının sıklığını şu şekilde ayarlayın:"
+ never: Asla
+ when_away: Yalnızca uzaktayken
+ always: Her zaman
diff --git a/plugins/discourse-policy/config/locales/server.ug.yml b/plugins/discourse-policy/config/locales/server.ug.yml
new file mode 100644
index 00000000000..adcaa71018e
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.ug.yml
@@ -0,0 +1,20 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ug:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: تېما كىملىكى
+ user_id: ئىشلەتكۈچى كىملىكى
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: ھەرگىز
+ when_away: ئايرىلغاندىلا
+ always: ھەمىشە
diff --git a/plugins/discourse-policy/config/locales/server.uk.yml b/plugins/discourse-policy/config/locales/server.uk.yml
new file mode 100644
index 00000000000..4b87e33396f
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.uk.yml
@@ -0,0 +1,20 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+uk:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ID теми
+ user_id: ID користувача
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: Ніколи
+ when_away: Тільки коли офлайн
+ always: Завжди
diff --git a/plugins/discourse-policy/config/locales/server.ur.yml b/plugins/discourse-policy/config/locales/server.ur.yml
new file mode 100644
index 00000000000..52017250709
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.ur.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ur:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ٹاپک ID
+ unsubscribe:
+ policy_emails:
+ never: کبھی نہیں
+ always: ہمیشہ
diff --git a/plugins/discourse-policy/config/locales/server.vi.yml b/plugins/discourse-policy/config/locales/server.vi.yml
new file mode 100644
index 00000000000..9a369fa9cb7
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.vi.yml
@@ -0,0 +1,15 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+vi:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: ID Chủ đề
+ unsubscribe:
+ policy_emails:
+ never: Không bao giờ
+ always: Luôn luôn
diff --git a/plugins/discourse-policy/config/locales/server.zh_CN.yml b/plugins/discourse-policy/config/locales/server.zh_CN.yml
new file mode 100644
index 00000000000..311bd3f3f98
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.zh_CN.yml
@@ -0,0 +1,37 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+zh_CN:
+ site_settings:
+ policy_enabled: "允许策略?"
+ policy_restrict_to_staff_posts: "策略可能只适用于管理人员帖子"
+ policy_easy_revoke: "同时显示接受和撤销按钮"
+ discourse_policy:
+ errors:
+ user_missing: "用户在群组中不存在"
+ group_not_found: "找不到策略的群组"
+ no_policy: "帖子没有策略"
+ staff_only: "策略可能只适用于管理人员帖子"
+ reports:
+ unaccepted-policies:
+ title: 未接受的策略
+ labels:
+ topic_id: 话题 ID
+ user_id: 用户 ID
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ subject: "一项策略需要您的审核:%{topic_title}"
+ visit_topic: "访问话题"
+ visit_link_to_respond: "%{visit_topic_link}以回复。"
+ unsubscribe: "更改您的%{email_preferences_link},或者%{unsubscribe_link}以取消订阅。"
+ your_policy_email_settings: "策略电子邮件频率偏好设置"
+ unsubscribe:
+ policy_emails:
+ select_title: "将接收策略提醒电子邮件的频率设为:"
+ never: 从不
+ when_away: 只在离开时
+ always: 始终
diff --git a/plugins/discourse-policy/config/locales/server.zh_TW.yml b/plugins/discourse-policy/config/locales/server.zh_TW.yml
new file mode 100644
index 00000000000..ec271f74a36
--- /dev/null
+++ b/plugins/discourse-policy/config/locales/server.zh_TW.yml
@@ -0,0 +1,18 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+zh_TW:
+ reports:
+ unaccepted-policies:
+ labels:
+ topic_id: 話題 ID
+ user_notifications:
+ policy_email:
+ from: "%{site_name}"
+ unsubscribe:
+ policy_emails:
+ never: 永不
+ always: 總是
diff --git a/plugins/discourse-policy/config/settings.yml b/plugins/discourse-policy/config/settings.yml
new file mode 100644
index 00000000000..58db380747d
--- /dev/null
+++ b/plugins/discourse-policy/config/settings.yml
@@ -0,0 +1,9 @@
+plugins:
+ policy_enabled:
+ default: false
+ client: true
+ policy_restrict_to_staff_posts:
+ client: true
+ default: true
+ policy_easy_revoke:
+ default: false
diff --git a/plugins/discourse-policy/db/migrate/20190817010101_migrate_post_policy_table.rb b/plugins/discourse-policy/db/migrate/20190817010101_migrate_post_policy_table.rb
new file mode 100644
index 00000000000..2b613a1995e
--- /dev/null
+++ b/plugins/discourse-policy/db/migrate/20190817010101_migrate_post_policy_table.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class MigratePostPolicyTable < ActiveRecord::Migration[5.2]
+ def up
+ create_table(:post_policies) do |t|
+ t.bigint :post_id, null: false, unique: true
+ t.timestamp :renew_start
+ t.integer :renew_days
+ t.datetime :next_renew_at
+ t.string :reminder
+ t.datetime :last_reminded_at
+ t.string :version
+ t.integer :group_id, null: false
+ t.timestamps
+ end
+ end
+
+ def down
+ drop_table :post_policies
+ end
+end
diff --git a/plugins/discourse-policy/db/migrate/20190817010201_migrate_post_policy_data.rb b/plugins/discourse-policy/db/migrate/20190817010201_migrate_post_policy_data.rb
new file mode 100644
index 00000000000..994c96bd60e
--- /dev/null
+++ b/plugins/discourse-policy/db/migrate/20190817010201_migrate_post_policy_data.rb
@@ -0,0 +1,65 @@
+# frozen_string_literal: true
+
+class MigratePostPolicyData < ActiveRecord::Migration[5.2]
+ def up
+ execute(<<~SQL)
+ INSERT INTO post_policies(
+ post_id,
+ group_id,
+ version,
+ reminder,
+ last_reminded_at,
+ renew_days,
+ updated_at,
+ created_at
+ )
+ SELECT
+ f1.post_id,
+ (select id from groups where name ilike f1.value) group_id,
+ f2.value as version,
+ f3.value as reminder,
+ case when f4.value ~ '^[0-9]+$' then
+ TIMESTAMP 'epoch' + f4.value::integer * interval '1 second'
+ else null end
+ as last_reminded_at,
+ case when f5.value ~ '^[0-9]+$' then
+ f5.value::integer else null end
+ as renew_days,
+ greatest(f1.updated_at, f2.updated_at) as updated_at,
+ least(f1.updated_at, f2.updated_at) as created_at
+ FROM post_custom_fields f1
+ LEFT JOIN post_custom_fields f2 ON
+ f1.post_id = f2.post_id AND f2.name = 'PolicyVersion'
+ LEFT JOIN post_custom_fields f3 ON
+ f1.post_id = f3.post_id AND f3.name = 'PolicyReminder'
+ LEFT JOIN post_custom_fields f4 ON
+ f1.post_id = f4.post_id AND f4.name = 'LastRemindedAt'
+ LEFT JOIN post_custom_fields f5 ON
+ f1.post_id = f5.post_id AND f5.name = 'PolicyRenewDays'
+ WHERE f1.name = 'PolicyGroup'
+ AND (select id from groups where name ilike f1.value) is not null
+ ON CONFLICT DO NOTHING
+ SQL
+
+ execute(<<~SQL)
+ INSERT INTO post_custom_fields (post_id, name, value, created_at, updated_at)
+ SELECT post_id, 'HasPolicy', 'true', created_at, updated_at
+ FROM post_policies
+ SQL
+
+ execute(<<~SQL)
+ DELETE FROM post_custom_fields
+ WHERE name in (
+ 'PolicyGroup',
+ 'PolicyVersion',
+ 'PolicyReminder',
+ 'PolicyRemindedAt',
+ 'PolicyRenewDays'
+ )
+ SQL
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/plugins/discourse-policy/db/migrate/20191013212445_migrate_policy_users_table.rb b/plugins/discourse-policy/db/migrate/20191013212445_migrate_policy_users_table.rb
new file mode 100644
index 00000000000..8cddde9158a
--- /dev/null
+++ b/plugins/discourse-policy/db/migrate/20191013212445_migrate_policy_users_table.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class MigratePolicyUsersTable < ActiveRecord::Migration[5.2]
+ def change
+ create_table :policy_users do |t|
+ t.integer :post_policy_id, null: false
+ t.integer :user_id, null: false
+ t.datetime :accepted_at
+ t.datetime :revoked_at
+ t.datetime :expired_at
+ t.string :version
+ t.timestamps null: false
+ end
+
+ add_index :policy_users, %i[post_policy_id user_id]
+ end
+end
diff --git a/plugins/discourse-policy/db/migrate/20191014224419_migrate_custom_field_to_policy_users.rb b/plugins/discourse-policy/db/migrate/20191014224419_migrate_custom_field_to_policy_users.rb
new file mode 100644
index 00000000000..d1799aff7da
--- /dev/null
+++ b/plugins/discourse-policy/db/migrate/20191014224419_migrate_custom_field_to_policy_users.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class MigrateCustomFieldToPolicyUsers < ActiveRecord::Migration[5.2]
+ def up
+ execute(<<~SQL)
+ INSERT INTO policy_users(post_policy_id, user_id, version, accepted_at, created_at, updated_at)
+ SELECT post_policies.id, post_custom_fields.value::INTEGER, post_policies.version, post_custom_fields.created_at, post_custom_fields.created_at, post_custom_fields.updated_at
+ FROM post_custom_fields
+ INNER JOIN post_policies ON post_policies.post_id = post_custom_fields.post_id
+ WHERE post_custom_fields.name = 'PolicyAcceptedBy'
+ SQL
+
+ execute(<<~SQL)
+ DELETE FROM post_custom_fields WHERE name = 'PolicyAcceptedBy'
+ SQL
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/plugins/discourse-policy/db/migrate/20200312233001_add_renew_interval_to_post_policies.rb b/plugins/discourse-policy/db/migrate/20200312233001_add_renew_interval_to_post_policies.rb
new file mode 100644
index 00000000000..6fce4f847c1
--- /dev/null
+++ b/plugins/discourse-policy/db/migrate/20200312233001_add_renew_interval_to_post_policies.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddRenewIntervalToPostPolicies < ActiveRecord::Migration[6.0]
+ def up
+ add_column :post_policies, :renew_interval, :integer
+ end
+
+ def down
+ remove_column :post_policies, :renew_interval
+ end
+end
diff --git a/plugins/discourse-policy/db/migrate/20210429154321_remove_nil_custom_fields_from_policy.rb b/plugins/discourse-policy/db/migrate/20210429154321_remove_nil_custom_fields_from_policy.rb
new file mode 100644
index 00000000000..1d995f09a79
--- /dev/null
+++ b/plugins/discourse-policy/db/migrate/20210429154321_remove_nil_custom_fields_from_policy.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class RemoveNilCustomFieldsFromPolicy < ActiveRecord::Migration[6.0]
+ def up
+ execute <<~SQL
+ DELETE FROM post_custom_fields
+ WHERE name = 'HasPolicy' AND value IS NULL
+ SQL
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/plugins/discourse-policy/db/migrate/20211206205455_add_private_to_post_policies.rb b/plugins/discourse-policy/db/migrate/20211206205455_add_private_to_post_policies.rb
new file mode 100644
index 00000000000..c0922c6ca01
--- /dev/null
+++ b/plugins/discourse-policy/db/migrate/20211206205455_add_private_to_post_policies.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddPrivateToPostPolicies < ActiveRecord::Migration[6.1]
+ def up
+ add_column :post_policies, :private, :boolean, default: false, null: false
+ end
+
+ def down
+ remove_column :post_policies, :private
+ end
+end
diff --git a/plugins/discourse-policy/db/migrate/20220609014748_add_post_policy_group.rb b/plugins/discourse-policy/db/migrate/20220609014748_add_post_policy_group.rb
new file mode 100644
index 00000000000..41b4d3d5d9d
--- /dev/null
+++ b/plugins/discourse-policy/db/migrate/20220609014748_add_post_policy_group.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+class AddPostPolicyGroup < ActiveRecord::Migration[6.1]
+ def up
+ create_table(:post_policy_groups) do |t|
+ t.integer :group_id, null: false
+ t.bigint :post_policy_id, null: false
+ t.timestamps
+ end
+
+ add_index :post_policy_groups, %i[post_policy_id group_id], unique: true
+
+ execute <<~SQL
+ INSERT INTO post_policy_groups(group_id, post_policy_id, created_at, updated_at)
+ SELECT group_id, id, created_at, updated_at
+ FROM post_policies
+ SQL
+
+ Migration::ColumnDropper.mark_readonly(:post_policies, :group_id)
+ end
+
+ def down
+ drop_table :post_policy_groups
+ Migration::ColumnDropper.drop_readonly(:post_policies, :group_id)
+ end
+end
diff --git a/plugins/discourse-policy/db/migrate/20220609017748_remove_group_id_from_post_policy.rb b/plugins/discourse-policy/db/migrate/20220609017748_remove_group_id_from_post_policy.rb
new file mode 100644
index 00000000000..491b41162b8
--- /dev/null
+++ b/plugins/discourse-policy/db/migrate/20220609017748_remove_group_id_from_post_policy.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+class RemoveGroupIdFromPostPolicy < ActiveRecord::Migration[6.1]
+ def up
+ Migration::ColumnDropper.execute_drop(:post_policies, [:group_id])
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/plugins/discourse-policy/db/migrate/20221014145803_add_policy_emails_frequency_to_user_options.rb b/plugins/discourse-policy/db/migrate/20221014145803_add_policy_emails_frequency_to_user_options.rb
new file mode 100644
index 00000000000..63d02a874a0
--- /dev/null
+++ b/plugins/discourse-policy/db/migrate/20221014145803_add_policy_emails_frequency_to_user_options.rb
@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+class AddPolicyEmailsFrequencyToUserOptions < ActiveRecord::Migration[7.0]
+ def change
+ add_column :user_options, :policy_email_frequency, :integer, default: 0, null: false
+ end
+end
diff --git a/plugins/discourse-policy/db/migrate/20231204161807_add_last_bumped_at_to_post_policies.rb b/plugins/discourse-policy/db/migrate/20231204161807_add_last_bumped_at_to_post_policies.rb
new file mode 100644
index 00000000000..2f5e12a0a04
--- /dev/null
+++ b/plugins/discourse-policy/db/migrate/20231204161807_add_last_bumped_at_to_post_policies.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddLastBumpedAtToPostPolicies < ActiveRecord::Migration[7.0]
+ def change
+ add_column :post_policies, :last_bumped_at, :datetime
+ end
+end
diff --git a/plugins/discourse-policy/db/migrate/20241009155340_alter_post_policy_id_to_bigint.rb b/plugins/discourse-policy/db/migrate/20241009155340_alter_post_policy_id_to_bigint.rb
new file mode 100644
index 00000000000..ca292f8ac5f
--- /dev/null
+++ b/plugins/discourse-policy/db/migrate/20241009155340_alter_post_policy_id_to_bigint.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AlterPostPolicyIdToBigint < ActiveRecord::Migration[7.1]
+ def up
+ change_column :policy_users, :post_policy_id, :bigint
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/plugins/discourse-policy/db/migrate/20250514162335_add_add_users_to_group_to_post_policy.rb b/plugins/discourse-policy/db/migrate/20250514162335_add_add_users_to_group_to_post_policy.rb
new file mode 100644
index 00000000000..14d564f84b0
--- /dev/null
+++ b/plugins/discourse-policy/db/migrate/20250514162335_add_add_users_to_group_to_post_policy.rb
@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+class AddAddUsersToGroupToPostPolicy < ActiveRecord::Migration[7.2]
+ def change
+ add_column :post_policies, :add_users_to_group, :integer, null: true
+ end
+end
diff --git a/plugins/discourse-policy/db/migrate/20250721192554_enable_policy_if_already_installed.rb b/plugins/discourse-policy/db/migrate/20250721192554_enable_policy_if_already_installed.rb
new file mode 100644
index 00000000000..cd1cd2cf388
--- /dev/null
+++ b/plugins/discourse-policy/db/migrate/20250721192554_enable_policy_if_already_installed.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class EnablePolicyIfAlreadyInstalled < ActiveRecord::Migration[7.2]
+ def up
+ installed_at = DB.query_single(<<~SQL)&.first
+ SELECT created_at FROM schema_migration_details WHERE version='20190817010101'
+ SQL
+
+ if installed_at && installed_at < 1.hour.ago
+ # The plugin was installed before we changed it to be disabled-by-default
+ # Therefore, if there is no existing database value, enable the plugin
+ execute <<~SQL
+ INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
+ VALUES('policy_enabled', 5, 't', NOW(), NOW())
+ ON CONFLICT (name) DO NOTHING
+ SQL
+ end
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/plugins/discourse-policy/jobs/scheduled/check_policy.rb b/plugins/discourse-policy/jobs/scheduled/check_policy.rb
new file mode 100644
index 00000000000..7374487191a
--- /dev/null
+++ b/plugins/discourse-policy/jobs/scheduled/check_policy.rb
@@ -0,0 +1,127 @@
+# frozen_string_literal: true
+
+module Jobs
+ class ::DiscoursePolicy::CheckPolicy < ::Jobs::Scheduled
+ every 6.hours
+
+ def execute(args = nil)
+ sql = <<~SQL
+ SELECT p.id
+ FROM post_policies pp
+ JOIN posts p ON p.id = pp.post_id
+ JOIN topics t ON t.id = p.topic_id
+ WHERE t.deleted_at IS NULL
+ AND p.deleted_at IS NULL
+ AND t.archetype = 'regular'
+ AND (
+ (reminder = 'weekly' AND last_reminded_at < :weekly)
+ OR
+ (reminder = 'daily' AND last_reminded_at < :daily)
+ )
+ SQL
+
+ post_ids = DB.query_single(sql, weekly: 1.week.ago, daily: 1.day.ago)
+
+ if post_ids.size > 0
+ Post
+ .where(id: post_ids)
+ .find_each do |post|
+ post.post_policy.update(last_reminded_at: Time.zone.now)
+
+ missing_users(post).find_each do |user|
+ clear_existing_notification(user, post)
+ user.notifications.create!(
+ notification_type: Notification.types[:topic_reminder],
+ topic_id: post.topic_id,
+ post_number: post.post_number,
+ data: { topic_title: post.topic.title, display_username: user.username }.to_json,
+ high_priority: true,
+ )
+ end
+
+ users_to_email(post).find_each do |user|
+ DiscoursePolicy::PolicyMailer.send_email(user, post)
+ end
+ end
+ end
+
+ PostPolicy
+ .where("next_renew_at < ?", Time.zone.now)
+ .find_each do |policy|
+ policy
+ .policy_users
+ .accepted
+ .where("accepted_at < ?", policy.next_renew_at)
+ .update_all(expired_at: Time.zone.now)
+ next_renew = policy.renew_start
+
+ if policy.renew_days.to_i < 1 &&
+ !PostPolicy.renew_intervals.keys.include?(policy.renew_interval)
+ Rails.logger.warn("Invalid policy on post #{policy.post_id}")
+ elsif next_renew.present?
+ while next_renew < Time.zone.now
+ next_renew = calculate_next_renew_date(next_renew, policy)
+ end
+ end
+
+ policy.update(next_renew_at: next_renew)
+ end
+
+ DB.exec <<~SQL,
+ UPDATE policy_users pu
+ SET expired_at = :now
+ FROM post_policies pp
+ WHERE pp.id = pu.post_policy_id
+ AND pp.renew_start IS NULL
+ AND (pp.renew_days IS NOT NULL OR pp.renew_interval IS NOT NULL)
+ AND pu.accepted_at IS NOT NULL
+ AND pu.expired_at IS NULL
+ AND pu.revoked_at IS NULL
+ AND
+ (
+ (pp.renew_days IS NOT NULL AND pu.accepted_at < :now::timestamp - (INTERVAL '1 day' * pp.renew_days::integer)) OR
+ (pp.renew_interval = :monthly AND pu.accepted_at < :now::timestamp - (INTERVAL '1 month')) OR
+ (pp.renew_interval = :quarterly AND pu.accepted_at < :now::timestamp - (INTERVAL '1 month' * 3)) OR
+ (pp.renew_interval = :yearly AND pu.accepted_at < :now::timestamp - (INTERVAL '1 year'))
+ )
+ SQL
+ now: Time.zone.now,
+ monthly: PostPolicy.renew_intervals["monthly"],
+ quarterly: PostPolicy.renew_intervals["quarterly"],
+ yearly: PostPolicy.renew_intervals["yearly"]
+ end
+
+ def calculate_next_renew_date(date, policy)
+ case policy.renew_interval
+ when "monthly"
+ date + 1.month
+ when "quarterly"
+ date + 3.months
+ when "yearly"
+ date + 1.year
+ else
+ date + policy.renew_days.to_i.days
+ end
+ end
+
+ def missing_users(post)
+ post.post_policy.not_accepted_by
+ end
+
+ def users_to_email(post)
+ post.post_policy.emailed_by
+ end
+
+ def clear_existing_notification(user, post)
+ existing_notification =
+ Notification.find_by(
+ notification_type: Notification.types[:topic_reminder],
+ topic_id: post.topic_id,
+ post_number: post.post_number,
+ user: user,
+ )
+ return if existing_notification.blank?
+ existing_notification.delete
+ end
+ end
+end
diff --git a/plugins/discourse-policy/lib/email_controller_helper/policy_email_unsubscriber.rb b/plugins/discourse-policy/lib/email_controller_helper/policy_email_unsubscriber.rb
new file mode 100644
index 00000000000..e693560ff5f
--- /dev/null
+++ b/plugins/discourse-policy/lib/email_controller_helper/policy_email_unsubscriber.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+module EmailControllerHelper
+ class PolicyEmailUnsubscriber < BaseEmailUnsubscriber
+ def prepare_unsubscribe_options(controller)
+ super(controller)
+
+ policy_email_frequencies =
+ UserOption.policy_email_frequencies.map do |(freq, _)|
+ [I18n.t("unsubscribe.policy_emails.#{freq}"), freq]
+ end
+
+ controller.instance_variable_set(:@policy_email_frequencies, policy_email_frequencies)
+ controller.instance_variable_set(
+ :@current_policy_email_frequency,
+ key_owner.user_option.policy_email_frequency,
+ )
+ end
+
+ def unsubscribe(params)
+ updated = super(params)
+
+ if params[:policy_email_frequency]
+ key_owner.user_option.update!(policy_email_frequency: params[:policy_email_frequency])
+ updated = true
+ end
+
+ updated
+ end
+ end
+end
diff --git a/plugins/discourse-policy/lib/extensions/post_extension.rb b/plugins/discourse-policy/lib/extensions/post_extension.rb
new file mode 100644
index 00000000000..ed8a7ce093a
--- /dev/null
+++ b/plugins/discourse-policy/lib/extensions/post_extension.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module DiscoursePolicy
+ module PostExtension
+ extend ActiveSupport::Concern
+
+ prepended { has_one :post_policy, dependent: :destroy }
+ end
+end
diff --git a/plugins/discourse-policy/lib/extensions/post_serializer_extension.rb b/plugins/discourse-policy/lib/extensions/post_serializer_extension.rb
new file mode 100644
index 00000000000..d1f237c6837
--- /dev/null
+++ b/plugins/discourse-policy/lib/extensions/post_serializer_extension.rb
@@ -0,0 +1,84 @@
+# frozen_string_literal: true
+
+module DiscoursePolicy
+ module PostSerializerExtension
+ extend ActiveSupport::Concern
+
+ prepended do
+ attributes :policy_can_accept,
+ :policy_can_revoke,
+ :policy_accepted,
+ :policy_revoked,
+ :policy_not_accepted_by,
+ :policy_not_accepted_by_count,
+ :policy_accepted_by,
+ :policy_accepted_by_count,
+ :policy_stats
+
+ delegate :post_policy, to: :object
+
+ alias include_policy_can_accept? include_policy?
+ alias include_policy_can_revoke? include_policy?
+ alias include_policy_accepted? include_policy?
+ alias include_policy_revoked? include_policy?
+ alias include_policy_not_accepted_by? include_policy_stats?
+ alias include_policy_not_accepted_by_count? include_policy_stats?
+ alias include_policy_accepted_by? include_policy_stats?
+ alias include_policy_accepted_by_count? include_policy_stats?
+
+ has_many :policy_not_accepted_by, embed: :object, serializer: BasicUserSerializer
+ has_many :policy_accepted_by, embed: :object, serializer: BasicUserSerializer
+ end
+
+ def include_policy?
+ SiteSetting.policy_enabled? && post_custom_fields[DiscoursePolicy::HAS_POLICY]
+ end
+
+ def policy_stats
+ true
+ end
+
+ def include_policy_stats?
+ return false unless include_policy?
+ return true if scope.is_admin?
+ return false if post_policy.private?
+ groups = post_policy.groups
+ return false if groups.blank?
+ Guardian.new(scope.user).can_see_groups_members?(groups)
+ end
+
+ def policy_can_accept
+ scope.authenticated? &&
+ (SiteSetting.policy_easy_revoke || post_policy.not_accepted_by.exists?(id: scope.user.id))
+ end
+
+ def policy_can_revoke
+ scope.authenticated? &&
+ (SiteSetting.policy_easy_revoke || post_policy.accepted_by.exists?(id: scope.user.id))
+ end
+
+ def policy_accepted
+ scope.authenticated? && post_policy.accepted_by.exists?(id: scope.user.id)
+ end
+
+ def policy_revoked
+ scope.authenticated? && post_policy.revoked_by.exists?(id: scope.user.id)
+ end
+
+ def policy_not_accepted_by
+ post_policy.not_accepted_by.limit(DiscoursePolicy::POLICY_USER_DEFAULT_LIMIT)
+ end
+
+ def policy_not_accepted_by_count
+ post_policy.not_accepted_by.size
+ end
+
+ def policy_accepted_by
+ post_policy.accepted_by.limit(DiscoursePolicy::POLICY_USER_DEFAULT_LIMIT)
+ end
+
+ def policy_accepted_by_count
+ post_policy.accepted_by.size
+ end
+ end
+end
diff --git a/plugins/discourse-policy/lib/extensions/user_notifications_extension.rb b/plugins/discourse-policy/lib/extensions/user_notifications_extension.rb
new file mode 100644
index 00000000000..92703fed548
--- /dev/null
+++ b/plugins/discourse-policy/lib/extensions/user_notifications_extension.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module DiscoursePolicy::UserNotificationsExtension
+ def policy_email(user, opts)
+ @user = user
+ build_summary_for(user)
+ @preferences_path = "#{Discourse.base_url}/my/preferences/emails"
+
+ # TODO(mark.reeves, a la chat plugin): Remove after the 2.9 release
+ add_unsubscribe_link = UnsubscribeKey.respond_to?(:get_unsubscribe_strategy_for)
+
+ if add_unsubscribe_link
+ unsubscribe_key = UnsubscribeKey.create_key_for(@user, "policy_email")
+ @unsubscribe_link = "#{Discourse.base_url}/email/unsubscribe/#{unsubscribe_key}"
+ opts[:add_unsubscribe_link] = add_unsubscribe_link
+ end
+
+ @post = opts[:post]
+ @topic_title = @post.topic.title
+ @classes = Rtl.new(user).css_class
+ @base_url = Discourse.base_url
+ @first_footer_classes = "highlight"
+ opts[:subject] = I18n.t("user_notifications.policy_email.subject", topic_title: @topic_title)
+
+ build_email(user.email, opts)
+ end
+end
diff --git a/plugins/discourse-policy/lib/extensions/user_option_extension.rb b/plugins/discourse-policy/lib/extensions/user_option_extension.rb
new file mode 100644
index 00000000000..b41b5c5f493
--- /dev/null
+++ b/plugins/discourse-policy/lib/extensions/user_option_extension.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+module DiscoursePolicy::UserOptionExtension
+ def self.prepended(base)
+ def base.policy_email_frequencies
+ @policy_email_frequencies ||= { never: 0, when_away: 1, always: 2 }
+ end
+
+ base.enum :policy_email_frequency, base.policy_email_frequencies, prefix: "send_policy_email"
+ end
+end
diff --git a/plugins/discourse-policy/lib/policy_mailer.rb b/plugins/discourse-policy/lib/policy_mailer.rb
new file mode 100644
index 00000000000..be34227af02
--- /dev/null
+++ b/plugins/discourse-policy/lib/policy_mailer.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class DiscoursePolicy::PolicyMailer
+ def self.send_email(user, post)
+ Jobs.enqueue(:user_email, type: "policy_email", user_id: user.id, post_id: post.id)
+ end
+end
diff --git a/plugins/discourse-policy/plugin.rb b/plugins/discourse-policy/plugin.rb
new file mode 100644
index 00000000000..6b0ce9acad7
--- /dev/null
+++ b/plugins/discourse-policy/plugin.rb
@@ -0,0 +1,205 @@
+# frozen_string_literal: true
+
+# name: discourse-policy
+# about: Gives the ability to confirm your users have seen or done something, with optional reminders.
+# meta_topic_id: 88557
+# version: 0.1.1
+# authors: Sam Saffron
+# url: https://github.com/discourse/discourse/tree/main/plugins/discourse-policy
+
+register_asset "stylesheets/common/discourse-policy.scss"
+register_asset "stylesheets/common/discourse-policy-builder.scss"
+
+register_svg_icon "user-check"
+register_svg_icon "file-signature"
+
+enabled_site_setting :policy_enabled
+
+after_initialize do
+ module ::DiscoursePolicy
+ PLUGIN_NAME = "discourse-policy"
+ HAS_POLICY = "HasPolicy"
+ POLICY_USER_DEFAULT_LIMIT = 25
+
+ class Engine < ::Rails::Engine
+ engine_name PLUGIN_NAME
+ isolate_namespace DiscoursePolicy
+ end
+ end
+
+ require_relative "app/controllers/policy_controller"
+ require_relative "app/models/policy_user"
+ require_relative "app/models/post_policy_group"
+ require_relative "app/models/post_policy"
+ require_relative "jobs/scheduled/check_policy"
+ require_relative "lib/email_controller_helper/policy_email_unsubscriber"
+ require_relative "lib/extensions/post_extension"
+ require_relative "lib/extensions/post_serializer_extension"
+ require_relative "lib/extensions/user_notifications_extension"
+ require_relative "lib/extensions/user_option_extension"
+ require_relative "lib/policy_mailer"
+
+ Discourse::Application.routes.append { mount ::DiscoursePolicy::Engine, at: "/policy" }
+
+ DiscoursePolicy::Engine.routes.draw do
+ put "/accept" => "policy#accept"
+ put "/unaccept" => "policy#unaccept"
+ get "/accepted" => "policy#accepted"
+ get "/not-accepted" => "policy#not_accepted"
+ end
+
+ Post.prepend DiscoursePolicy::PostExtension
+ PostSerializer.prepend DiscoursePolicy::PostSerializerExtension
+ UserNotifications.prepend DiscoursePolicy::UserNotificationsExtension
+ UserOption.prepend DiscoursePolicy::UserOptionExtension
+
+ UserUpdater::OPTION_ATTR.push(:policy_email_frequency)
+
+ UserNotifications.append_view_path(File.expand_path("../app/views", __FILE__))
+
+ add_to_serializer(:user_option, :policy_email_frequency) { object.policy_email_frequency }
+
+ register_email_unsubscriber("policy_email", EmailControllerHelper::PolicyEmailUnsubscriber)
+
+ TopicView.default_post_custom_fields << DiscoursePolicy::HAS_POLICY
+
+ on(:post_process_cooked) do |doc, post|
+ has_group = false
+
+ if !SiteSetting.policy_restrict_to_staff_posts || post&.user&.staff?
+ if policy = doc.search(".policy")&.first
+ post_policy = post.post_policy || post.build_post_policy
+
+ group_names = []
+
+ if group = policy["data-group"]
+ group_names << group
+ end
+
+ if groups = policy["data-groups"]
+ group_names.concat(groups.split(","))
+ end
+
+ new_group_ids = Group.where("name in (?)", group_names).pluck(:id)
+
+ has_group = true if new_group_ids.length > 0
+
+ existing_ids = post_policy.post_policy_groups.pluck(:group_id)
+
+ missing = (new_group_ids - existing_ids)
+
+ new_relations = []
+
+ post_policy.post_policy_groups.each do |relation|
+ new_relations << relation if new_group_ids.include?(relation.group_id)
+ end
+
+ missing.each do |id|
+ new_relations << PostPolicyGroup.new(post_policy_id: post_policy.id, group_id: id)
+ end
+
+ post_policy.post_policy_groups = new_relations
+
+ renew_days = policy["data-renew"]
+ if (renew_days.to_i) > 0 || PostPolicy.renew_intervals.keys.include?(renew_days)
+ post_policy.renew_days =
+ PostPolicy.renew_intervals.keys.include?(renew_days) ? nil : renew_days
+ post_policy.renew_interval = post_policy.renew_days.present? ? nil : renew_days
+
+ post_policy.renew_start = nil
+
+ if (renew_start = policy["data-renew-start"])
+ begin
+ renew_start = Date.parse(renew_start)
+ post_policy.renew_start = renew_start
+ if !post_policy.next_renew_at || post_policy.next_renew_at < renew_start
+ post_policy.next_renew_at = renew_start
+ end
+ rescue ArgumentError
+ # already nil
+ end
+ else
+ post_policy.next_renew_at = nil
+ end
+ else
+ post_policy.renew_days = nil
+ post_policy.renew_start = nil
+ post_policy.next_renew_at = nil
+ end
+
+ if version = policy["data-version"]
+ old_version = post_policy.version || "1"
+ if version != old_version
+ post_policy.version = version
+
+ if post_policy.add_users_to_group.present?
+ previously_accepted_users = post_policy.accepted_policy_users
+
+ Group.find_by(id: post_policy.add_users_to_group)&.remove(previously_accepted_users)
+ end
+ end
+ end
+
+ if reminder = policy["data-reminder"]
+ post_policy.reminder = reminder
+ post_policy.last_reminded_at ||= Time.zone.now
+ end
+
+ post_policy.private = policy["data-private"] == "true"
+
+ if policy["data-add-users-to-group"].present?
+ post_policy.add_users_to_group = Group.find_by_name(policy["data-add-users-to-group"])&.id
+ end
+
+ if has_group
+ if !post.custom_fields[DiscoursePolicy::HAS_POLICY]
+ post.custom_fields[DiscoursePolicy::HAS_POLICY] = true
+ post.save_custom_fields
+ end
+ post_policy.save!
+ end
+ end
+ end
+
+ if !has_group && (post.custom_fields[DiscoursePolicy::HAS_POLICY] || !post_policy&.new_record?)
+ post.custom_fields.delete(DiscoursePolicy::HAS_POLICY)
+ post.save_custom_fields
+ PostPolicy.where(post_id: post.id).destroy_all
+ end
+ end
+
+ add_report("unaccepted-policies") do |report|
+ report.modes = [:table]
+
+ report.labels = [
+ { property: :topic_id, title: I18n.t("reports.unaccepted-policies.labels.topic_id") },
+ { property: :user_id, title: I18n.t("reports.unaccepted-policies.labels.user_id") },
+ ]
+
+ results = DB.query(<<~SQL)
+ SELECT distinct t.id AS topic_id, gu.user_id AS user_id
+ FROM post_policies pp
+ JOIN post_policy_groups pg on pg.post_policy_id = pp.id
+ JOIN posts p ON p.id = pp.post_id AND p.deleted_at is null
+ JOIN topics t ON t.id = p.topic_id AND t.deleted_at is null
+ JOIN group_users gu ON gu.group_id = pg.group_id
+ LEFT JOIN policy_users pu ON
+ pu.user_id = gu.user_id AND
+ pu.post_policy_id = pp.id AND
+ pu.accepted_at IS NOT NULL AND
+ pu.revoked_at IS NULL AND
+ (pu.expired_at IS NULL OR pu.expired_at < pu.accepted_at) AND
+ ((pu.version IS NULL AND pp.version IS NULL) OR
+ (pp.version IS NOT NULL AND pu.version IS NOT NULL AND pu.version = pp.version))
+ WHERE pu.id IS NULL
+ SQL
+
+ report.data = []
+ results.each do |row|
+ data = {}
+ data[:user_id] = row.user_id
+ data[:topic_id] = row.topic_id
+ report.data << data
+ end
+ end
+end
diff --git a/plugins/discourse-policy/spec/fabricators/post_policy_fabricator.rb b/plugins/discourse-policy/spec/fabricators/post_policy_fabricator.rb
new file mode 100644
index 00000000000..fa5f75596ba
--- /dev/null
+++ b/plugins/discourse-policy/spec/fabricators/post_policy_fabricator.rb
@@ -0,0 +1,3 @@
+# frozen_string_literal: true
+
+Fabricator(:post_policy) { post }
diff --git a/plugins/discourse-policy/spec/lib/check_policy_spec.rb b/plugins/discourse-policy/spec/lib/check_policy_spec.rb
new file mode 100644
index 00000000000..e43ad59f9b2
--- /dev/null
+++ b/plugins/discourse-policy/spec/lib/check_policy_spec.rb
@@ -0,0 +1,324 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+describe DiscoursePolicy::CheckPolicy do
+ before do
+ enable_current_plugin
+ Jobs.run_immediately!
+ end
+
+ fab!(:user1) { Fabricate(:user) }
+ fab!(:user2) { Fabricate(:user) }
+
+ fab!(:group) do
+ group = Fabricate(:group)
+ group.add(user1)
+ group.add(user2)
+ group
+ end
+
+ def accept_policy(post)
+ [user1, user2].each { |u| PolicyUser.add!(u, post.post_policy) }
+ end
+
+ it "correctly renews policies with no renew-start" do
+ freeze_time Time.utc(2019)
+
+ raw = <<~MD
+ [policy group=#{group.name} renew=400]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+
+ freeze_time Time.utc(2021)
+ accept_policy(post)
+
+ freeze_time Time.utc(2022)
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ post.reload
+ expect(post.post_policy.accepted_by).to contain_exactly(user1, user2)
+
+ freeze_time Time.utc(2023)
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ post.reload
+ expect(post.post_policy.accepted_by).to be_empty
+ end
+
+ it "expires only for user with expired policy" do
+ freeze_time Time.utc(2019)
+
+ raw = <<~MD
+ [policy group=#{group.name} renew=364]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+
+ freeze_time Time.utc(2021)
+ accept_policy(post)
+
+ freeze_time Time.utc(2022)
+ PolicyUser.where(user_id: user2.id).update(accepted_at: Time.now)
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ post.reload
+ expect(post.post_policy.accepted_by).to contain_exactly(user2)
+ end
+
+ it "expires just for expired policy" do
+ freeze_time Time.utc(2019)
+
+ raw = <<~MD
+ [policy group=#{group.name} renew=364]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ raw2 = <<~MD
+ [policy group=#{group.name} renew=1000]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+ post2 = create_post(raw: raw2, user: Fabricate(:admin))
+
+ freeze_time Time.utc(2021)
+ accept_policy(post)
+ accept_policy(post2)
+
+ freeze_time Time.utc(2022)
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ post.reload
+ expect(post.post_policy.accepted_by).to be_empty
+ expect(post2.post_policy.accepted_by).to contain_exactly(user1, user2)
+ end
+
+ it "correctly renews policies" do
+ freeze_time Time.utc(2019)
+
+ raw = <<~MD
+ [policy group=#{group.name} renew=100 renew-start="2020-10-17"]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+
+ accept_policy(post)
+
+ freeze_time Time.utc(2020)
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ post.reload
+ # did not hit renew start
+ expect(post.post_policy.accepted_by).to contain_exactly(user1, user2)
+
+ freeze_time Time.utc(2020, 10, 18)
+
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ post.reload
+ expect(post.post_policy.accepted_by).to be_empty
+
+ accept_policy(post)
+
+ freeze_time(Time.utc(2020, 10, 17) + 101.days)
+
+ PolicyUser.add!(user2, post.post_policy)
+
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ post.reload
+ expect(post.post_policy.accepted_by).to contain_exactly(user2)
+ end
+
+ %w[monthly quarterly yearly].each do |how_often|
+ it "sets correctly next_renew_at for #{how_often} when renew-start is set" do
+ period =
+ case how_often
+ when "monthly"
+ 1.month
+ when "quarterly"
+ 3.months
+ when "yearly"
+ 12.months
+ end
+ freeze_time Time.utc(2020, 10, 16)
+
+ raw = <<~MD
+ [policy group=#{group.name} renew=#{how_often} renew-start="2020-10-17"]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+
+ accept_policy(post)
+
+ freeze_time Time.utc(2020, 10, 17)
+
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ post.reload
+ expect(post.post_policy.accepted_by).to contain_exactly(user1, user2)
+
+ freeze_time Time.utc(2020, 10, 18)
+
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ post.reload
+ expect(post.post_policy.accepted_by).to be_empty
+ expect(post.post_policy.next_renew_at.to_s).to eq((Time.utc(2020, 10, 17) + period).to_s)
+ end
+ end
+
+ %w[monthly quarterly yearly].each do |how_often|
+ it "expires policies when #{how_often}" do
+ period =
+ case how_often
+ when "monthly"
+ 1.month
+ when "quarterly"
+ 3.months
+ when "yearly"
+ 12.months
+ end
+ freeze_time Time.utc(2020, 10, 16)
+
+ raw = <<~MD
+ [policy group=#{group.name} renew=#{how_often}]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+
+ accept_policy(post)
+
+ freeze_time Time.utc(2020, 10, 30)
+
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ post.reload
+ expect(post.post_policy.accepted_by).to contain_exactly(user1, user2)
+
+ freeze_time Time.utc(2020, 10, 16) + period + 1.day
+
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ post.reload
+ expect(post.post_policy.accepted_by).to be_empty
+ expect(post.post_policy.renew_start).to eq(nil)
+ end
+ end
+
+ it "will correctly notify users with high priority notifications" do
+ Jobs.run_immediately!
+ freeze_time
+
+ raw = <<~MD
+ [policy group=#{group.name} reminder=weekly]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ expect(
+ user1.notifications.where(notification_type: Notification.types[:topic_reminder]).count,
+ ).to eq(0)
+ expect(
+ user2.notifications.where(notification_type: Notification.types[:topic_reminder]).count,
+ ).to eq(0)
+
+ freeze_time 2.weeks.from_now
+
+ DiscoursePolicy::CheckPolicy.new.execute
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ user1_notifications =
+ user1.notifications.where(
+ notification_type: Notification.types[:topic_reminder],
+ topic_id: post.topic_id,
+ post_number: 1,
+ )
+ expect(user1_notifications.count).to eq(1)
+ expect(user1_notifications.first.high_priority).to eq(true)
+ user2_notifications =
+ user2.notifications.where(
+ notification_type: Notification.types[:topic_reminder],
+ topic_id: post.topic_id,
+ post_number: 1,
+ )
+ expect(user2_notifications.count).to eq(1)
+ expect(user2_notifications.first.high_priority).to eq(true)
+ end
+
+ it "will delete the existing policy reminder notification before creating a new one" do
+ Jobs.run_immediately!
+ freeze_time
+
+ raw = <<~MD
+ [policy group=#{group.name} reminder=weekly]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ expect(
+ user1.notifications.where(notification_type: Notification.types[:topic_reminder]).count,
+ ).to eq(0)
+
+ freeze_time 2.weeks.from_now
+
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ user1_notification =
+ user1
+ .notifications
+ .where(
+ notification_type: Notification.types[:topic_reminder],
+ topic_id: post.topic_id,
+ post_number: 1,
+ )
+ .last
+ expect(user1_notification).not_to eq(nil)
+
+ freeze_time 2.weeks.from_now
+
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ expect(
+ user1
+ .notifications
+ .where(
+ notification_type: Notification.types[:topic_reminder],
+ topic_id: post.topic_id,
+ post_number: 1,
+ )
+ .count,
+ ).to eq(1)
+ expect(Notification.find_by(id: user1_notification.id)).to eq(nil)
+ end
+
+ it "clears the next_renew_at when renew_start is nil" do
+ policy = Fabricate(:post_policy, next_renew_at: 3.hours.ago, renew_start: nil, renew_days: 10)
+
+ DiscoursePolicy::CheckPolicy.new.execute
+
+ expect(policy.reload.next_renew_at).to be_nil
+ end
+end
diff --git a/plugins/discourse-policy/spec/lib/pretty_text_spec.rb b/plugins/discourse-policy/spec/lib/pretty_text_spec.rb
new file mode 100644
index 00000000000..cc6134e1041
--- /dev/null
+++ b/plugins/discourse-policy/spec/lib/pretty_text_spec.rb
@@ -0,0 +1,128 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+describe PrettyText do
+ before do
+ enable_current_plugin
+ Jobs.run_immediately!
+ end
+
+ it "can properly decorate policies (legacy)" do
+ raw = <<~MD
+ [policy group=team renew-start="2010-01-01" reminder=weekly accept=banana revoke=apple]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ cooked = (<<~HTML).strip
+ <div class="policy" data-accept="banana" data-group="team" data-reminder="weekly" data-renew-start="2010-01-01" data-revoke="apple" data-version="1">
+ <p>I always open <strong>doors</strong>!</p>
+ </div>
+ HTML
+
+ expect(PrettyText.cook(raw)).to match_html(cooked)
+ end
+
+ it "can properly decorate policies" do
+ raw = <<~MD
+ [policy groups=team,staff renew-start="2010-01-01" reminder=weekly accept=banana revoke=apple]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ cooked = (<<~HTML).strip
+ <div class="policy" data-accept="banana" data-groups="team,staff" data-reminder="weekly" data-renew-start="2010-01-01" data-revoke="apple" data-version="1">
+ <p>I always open <strong>doors</strong>!</p>
+ </div>
+ HTML
+
+ expect(PrettyText.cook(raw)).to match_html(cooked)
+ end
+
+ it "sets the custom attribute on posts with policies" do
+ SiteSetting.policy_restrict_to_staff_posts = false
+
+ raw = <<~MD
+ [policy group=staff reminder=weekly]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw)
+ post = Post.find(post.id)
+
+ expect(post.post_policy.groups.pluck(:name)).to eq(["staff"])
+
+ post.revise(post.user, raw: "i am new raw")
+
+ post = Post.find(post.id)
+
+ expect(post.post_policy).to eq(nil)
+ end
+
+ it "allows policy to expire for end users on demand" do
+ SiteSetting.policy_restrict_to_staff_posts = false
+
+ freeze_time
+
+ user = Fabricate(:admin)
+
+ raw = <<~MD
+ [policy group=staff renew=200]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw)
+ PolicyUser.add!(user, post.post_policy)
+
+ freeze_time(199.days.from_now)
+ ::DiscoursePolicy::CheckPolicy.new.execute(nil)
+ expect(post.post_policy.accepted_by).to eq([user])
+
+ freeze_time(2.days.from_now)
+ ::DiscoursePolicy::CheckPolicy.new.execute(nil)
+ expect(post.post_policy.accepted_by).to be_empty
+ end
+
+ it "resets list of accepted users if version is bumped" do
+ SiteSetting.policy_restrict_to_staff_posts = false
+
+ freeze_time
+
+ user = Fabricate(:admin)
+
+ raw = <<~MD
+ [policy group=staff reminder=weekly]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw)
+
+ PolicyUser.add!(user, post.post_policy)
+
+ post = Post.find(post.id)
+
+ expect(post.post_policy.accepted_by).to contain_exactly(user)
+ expect(post.post_policy.reminder).to eq("weekly")
+ expect(post.post_policy.last_reminded_at).to eq_time(Time.zone.now)
+ expect(post.post_policy.groups.pluck(:name)).to contain_exactly("staff")
+
+ raw = <<~MD
+ [policy groups=trust_level_1,trust_level_0 version=2 reminder=weekly]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post.revise(post.user, raw: raw)
+
+ post = Post.find(post.id)
+ expect(post.post_policy.accepted_by).to be_empty
+ expect(post.post_policy.groups.pluck(:name)).to contain_exactly(
+ "trust_level_0",
+ "trust_level_1",
+ )
+ end
+end
diff --git a/plugins/discourse-policy/spec/mailers/policy_email_spec.rb b/plugins/discourse-policy/spec/mailers/policy_email_spec.rb
new file mode 100644
index 00000000000..ddd5221dd41
--- /dev/null
+++ b/plugins/discourse-policy/spec/mailers/policy_email_spec.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+describe Jobs::UserEmail do
+ fab!(:user1) { Fabricate(:user) }
+
+ fab!(:group1) do
+ group = Fabricate(:group)
+ group.add(user1)
+ group
+ end
+
+ before { enable_current_plugin }
+
+ it "sends a policy alert email to users who have opted in" do
+ raw = <<~MD
+ [policy group=#{group1.name} reminder=weekly]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+
+ Jobs::UserEmail.new.execute(type: "policy_email", user_id: user1.id, post_id: post.id)
+
+ email = ActionMailer::Base.deliveries.first
+
+ expect(email.to).to contain_exactly(user1.email)
+ expect(email.subject).to eq I18n.t(
+ "user_notifications.policy_email.subject",
+ topic_title: post.topic.title,
+ )
+ expect(email.subject).to include(post.topic.title)
+ expect(email.parts[0].body.to_s).to include(post.url)
+ end
+end
diff --git a/plugins/discourse-policy/spec/models/policy_user_spec.rb b/plugins/discourse-policy/spec/models/policy_user_spec.rb
new file mode 100644
index 00000000000..f0ce89c3322
--- /dev/null
+++ b/plugins/discourse-policy/spec/models/policy_user_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+describe PolicyUser do
+ before do
+ enable_current_plugin
+ Jobs.run_immediately!
+ end
+
+ fab!(:user)
+
+ fab!(:group) do
+ group = Fabricate(:group)
+ group.add(user)
+ group
+ end
+
+ it "allows to accept and revoke policy" do
+ raw = <<~MD
+ [policy group=#{group.name} renew=400]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+
+ described_class.add!(user, post.post_policy)
+ expect(post.post_policy.accepted_by).to eq([user])
+
+ described_class.remove!(user, post.post_policy)
+ expect(post.post_policy.accepted_by).to eq([])
+ end
+end
diff --git a/plugins/discourse-policy/spec/models/post_policy_spec.rb b/plugins/discourse-policy/spec/models/post_policy_spec.rb
new file mode 100644
index 00000000000..097cdc5c24a
--- /dev/null
+++ b/plugins/discourse-policy/spec/models/post_policy_spec.rb
@@ -0,0 +1,228 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+RSpec.describe PostPolicy do
+ include ActiveSupport::Testing::TimeHelpers
+
+ fab!(:user1) { Fabricate(:user) }
+ fab!(:user2) { Fabricate(:user) }
+ fab!(:inactive_user) { Fabricate(:user, active: false) }
+ fab!(:suspended_user) { Fabricate(:user, suspended_till: 1.year.from_now) }
+
+ fab!(:group1) do
+ group = Fabricate(:group)
+ group.add(user1)
+ group.add(user2)
+ group.add(inactive_user)
+ group.add(suspended_user)
+ group
+ end
+
+ fab!(:group2) do
+ group = Fabricate(:group)
+ group.add(user1)
+ group
+ end
+
+ fab!(:policy) do
+ policy = Fabricate(:post_policy)
+ PostPolicyGroup.create!(post_policy_id: policy.id, group_id: group1.id)
+ PostPolicyGroup.create!(post_policy_id: policy.id, group_id: group2.id)
+ policy
+ end
+
+ before do
+ enable_current_plugin
+ Jobs.run_immediately!
+ end
+
+ describe "Callbacks" do
+ context "when bumping version" do
+ before { freeze_time }
+
+ after { travel_back }
+
+ it "updates the `last_bumped_at` field" do
+ expect { policy.update!(version: "2") }.to change { policy.reload.last_bumped_at }.to eq(
+ Time.current,
+ )
+ end
+ end
+
+ context "when not bumping version" do
+ it "doesn't change the `last_bumped_at` field" do
+ expect { policy.update!(private: true) }.not_to change { policy.reload.last_bumped_at }
+ end
+ end
+ end
+
+ describe "#accepted_by" do
+ it "returns empty if no policy group" do
+ PolicyUser.add!(user1, policy)
+ Group.delete_all
+
+ expect(policy.accepted_by).to eq []
+ end
+
+ it "shows users who accepted ordered by id" do
+ PolicyUser.add!(user2, policy)
+ PolicyUser.add!(user1, policy)
+
+ expect(policy.accepted_by).to eq [user1, user2]
+ end
+
+ it "excludes inactive or suspended users" do
+ PolicyUser.add!(inactive_user, policy)
+ PolicyUser.add!(suspended_user, policy)
+
+ expect(policy.accepted_by).to eq []
+ end
+
+ it "has no duplicates for users in multiple groups" do
+ PolicyUser.add!(user1, policy)
+
+ expect(policy.accepted_by).to eq [user1]
+ end
+ end
+
+ describe "#revoked_by" do
+ it "returns empty if no policy group" do
+ PolicyUser.add!(user1, policy)
+ Group.delete_all
+
+ expect(policy.revoked_by).to eq []
+ end
+
+ it "shows users who revoked ordered by id" do
+ PolicyUser.remove!(user2, policy)
+ PolicyUser.remove!(user1, policy)
+
+ expect(policy.revoked_by).to eq [user1, user2]
+ end
+
+ it "excludes inactive or suspended users" do
+ PolicyUser.remove!(inactive_user, policy)
+ PolicyUser.remove!(suspended_user, policy)
+
+ expect(policy.revoked_by).to eq []
+ end
+
+ it "has no duplicates for users in multiple groups" do
+ PolicyUser.remove!(user1, policy)
+
+ expect(policy.revoked_by).to eq [user1]
+ end
+ end
+
+ describe "#not_accepted_by" do
+ it "returns empty if no policy group" do
+ PolicyUser.add!(user1, policy)
+ Group.delete_all
+
+ expect(policy.not_accepted_by).to eq []
+ end
+
+ it "shows users who have not accepted ordered by id" do
+ expect(policy.not_accepted_by).to eq [user1, user2]
+ end
+
+ it "excludes inactive or suspended users" do
+ expect(policy.not_accepted_by).to_not include(inactive_user, suspended_user)
+ end
+ end
+
+ describe "#emailed_by" do
+ it "returns empty if no users have requested emails" do
+ user1.user_option.update(policy_email_frequency: UserOption.policy_email_frequencies[:never])
+ user2.user_option.update(policy_email_frequency: UserOption.policy_email_frequencies[:never])
+
+ expect(policy.emailed_by).to eq []
+ end
+
+ it "shows users who have requested emails and have not accepted yet" do
+ user1.user_option.update(policy_email_frequency: UserOption.policy_email_frequencies[:always])
+ user2.user_option.update(
+ policy_email_frequency: UserOption.policy_email_frequencies[:when_away],
+ )
+
+ user2.update(last_seen_at: 30.minutes.ago)
+
+ expect(policy.emailed_by).to eq [user1, user2]
+ end
+ end
+
+ describe "#emailed_by_always" do
+ it "shows users who have opted for emails always" do
+ user1.user_option.update(policy_email_frequency: UserOption.policy_email_frequencies[:always])
+ user2.user_option.update(policy_email_frequency: UserOption.policy_email_frequencies[:never])
+
+ expect(policy.emailed_by_always).to eq [user1]
+ end
+
+ it "returns empty if users who requested emails always have accepted" do
+ user1.user_option.update(policy_email_frequency: UserOption.policy_email_frequencies[:always])
+ user2.user_option.update(policy_email_frequency: UserOption.policy_email_frequencies[:never])
+
+ PolicyUser.add!(user1, policy)
+
+ expect(policy.emailed_by_always).to eq []
+ end
+ end
+
+ describe "#emailed_by_when_away" do
+ it "shows users who have opted for emails when away" do
+ user1.user_option.update(
+ policy_email_frequency: UserOption.policy_email_frequencies[:when_away],
+ )
+ user2.user_option.update(policy_email_frequency: UserOption.policy_email_frequencies[:never])
+
+ user1.update(last_seen_at: 30.minutes.ago)
+
+ expect(policy.emailed_by_when_away).to eq [user1]
+ end
+
+ it "returns empty if users who requested emails when away have accepted" do
+ user1.user_option.update(
+ policy_email_frequency: UserOption.policy_email_frequencies[:when_away],
+ )
+ user2.user_option.update(policy_email_frequency: UserOption.policy_email_frequencies[:never])
+
+ PolicyUser.add!(user1, policy)
+
+ user1.update(last_seen_at: 30.minutes.ago)
+
+ expect(policy.emailed_by_when_away).to eq []
+ end
+ end
+
+ describe "#add_users_group" do
+ fab!(:policy_no_user_add) do
+ policy = Fabricate(:post_policy, add_users_to_group: nil)
+ PostPolicyGroup.create!(post_policy_id: policy.id, group_id: group1.id)
+
+ policy
+ end
+
+ fab!(:policy_user_add) do
+ policy = Fabricate(:post_policy, add_users_to_group: group1.id)
+ PostPolicyGroup.create!(post_policy_id: policy.id, group_id: group1.id)
+
+ policy
+ end
+
+ it "returns the group if add_users_to_group is set" do
+ expect(policy_user_add.add_users_group).to eq group1
+ end
+
+ it "returns nil if add_users_to_group is not set" do
+ expect(policy_no_user_add.add_users_group).to be_nil
+ end
+
+ it "returns nil if group does not exist" do
+ policy.update(add_users_to_group: 42_069)
+
+ expect(policy.add_users_group).to be_nil
+ end
+ end
+end
diff --git a/plugins/discourse-policy/spec/plugin_spec.rb b/plugins/discourse-policy/spec/plugin_spec.rb
new file mode 100644
index 00000000000..0756b9cd758
--- /dev/null
+++ b/plugins/discourse-policy/spec/plugin_spec.rb
@@ -0,0 +1,92 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+describe DiscoursePolicy do
+ fab!(:user1) { Fabricate(:user) }
+
+ before { enable_current_plugin }
+
+ describe "after_initialize" do
+ before { Jobs.run_immediately! }
+
+ it "serializes user options correctly" do
+ user1.user_option.update(
+ policy_email_frequency: UserOption.policy_email_frequencies[:when_away],
+ )
+
+ @plugin = Plugin::Instance.new
+ @plugin.add_to_serializer(:user_option, :policy_email_frequency) do
+ object.policy_email_frequency
+ end
+
+ json = UserSerializer.new(user1, scope: Guardian.new(user1), root: false).as_json
+
+ expect(json[:user_option][:policy_email_frequency]).to eq("when_away")
+ end
+ end
+
+ describe "post_process_cooked event" do
+ before { Jobs.run_immediately! }
+
+ fab!(:group)
+ fab!(:moderator)
+
+ it "sets next_renew_at when removing renew-start but not renew" do
+ renew_days = 10
+ renew_start = 1.day.from_now.to_date
+ raw = <<~MD
+ [policy group=#{group.name} renew="#{renew_days}" renew-start="#{renew_start.strftime("%F")}"]
+ Here's the new policy
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+ policy = PostPolicy.find_by(post: post)
+
+ expect(policy.renew_days).to eq(renew_days)
+ expect(policy.renew_start).to eq(renew_start)
+ expect(policy.next_renew_at.to_date).to eq(renew_start)
+
+ updated_policy = <<~MD
+ [policy group=#{group.name} renew="#{renew_days}"]
+ Here's the new policy
+ [/policy]
+ MD
+
+ post.update!(raw: updated_policy)
+ post.rebake!
+ policy = policy.reload
+
+ expect(policy.renew_days).to eq(renew_days)
+ expect(policy.renew_start).to be_nil
+ expect(policy.next_renew_at).to be_nil
+ end
+
+ context "with add_users_to_group present" do
+ fab!(:group2) { Fabricate(:group) }
+ fab!(:post) { Fabricate(:post, user: moderator) }
+ fab!(:policy666) do
+ policy = Fabricate(:post_policy, post: post, add_users_to_group: group2.id)
+ PostPolicyGroup.create!(post_policy_id: policy.id, group_id: group.id)
+ policy
+ end
+
+ before { group.add(user1) }
+
+ it "removes all users from the group upon version change" do
+ updated_policy = <<~MD
+ [policy group=#{group.name} version=2 add_users_to_group=#{group2.id}]
+ Here's the new policy
+ [/policy]
+ MD
+
+ post.update!(raw: updated_policy)
+ post.rebake!
+ post.post_policy.reload
+
+ expect(group2.users).to contain_exactly
+ end
+ end
+ end
+end
diff --git a/plugins/discourse-policy/spec/reports/unaccepted_policies_spec.rb b/plugins/discourse-policy/spec/reports/unaccepted_policies_spec.rb
new file mode 100644
index 00000000000..c6580607551
--- /dev/null
+++ b/plugins/discourse-policy/spec/reports/unaccepted_policies_spec.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+RSpec.describe Report do
+ fab!(:user1) { Fabricate(:user) }
+ fab!(:user2) { Fabricate(:user) }
+
+ fab!(:group1) do
+ group = Fabricate(:group)
+ group.add(user1)
+ group.add(user2)
+ group
+ end
+
+ fab!(:policy) do
+ policy = Fabricate(:post_policy)
+ PostPolicyGroup.create!(post_policy_id: policy.id, group_id: group1.id)
+ policy
+ end
+
+ before do
+ enable_current_plugin
+ PolicyUser.add!(user1, policy)
+ end
+
+ it "reports users who have not accepted" do
+ report = Report.find("unaccepted-policies")
+ topic = policy.post.topic
+ expect(report.data).to eq([{ topic_id: topic.id, user_id: user2.id }])
+ end
+end
diff --git a/plugins/discourse-policy/spec/requests/policy_controller_spec.rb b/plugins/discourse-policy/spec/requests/policy_controller_spec.rb
new file mode 100644
index 00000000000..b07aee3c466
--- /dev/null
+++ b/plugins/discourse-policy/spec/requests/policy_controller_spec.rb
@@ -0,0 +1,158 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+describe DiscoursePolicy::PolicyController do
+ fab!(:group)
+ fab!(:moderator)
+ fab!(:user1) { Fabricate(:user) }
+ fab!(:user2) { Fabricate(:user) }
+
+ before do
+ enable_current_plugin
+ Jobs.run_immediately!
+ group.add(user1)
+ group.add(user2)
+ end
+
+ def raw
+ <<~MD
+ [policy group=#{group.name}]
+ I always open **doors**!
+ [/policy]
+ MD
+ end
+
+ it "allows users to accept/reject policy" do
+ post = create_post(raw: raw, user: moderator)
+
+ sign_in(user1)
+ put "/policy/accept.json", params: { post_id: post.id }
+ expect(response.status).to eq(200)
+ expect(post.reload.post_policy.accepted_by.map(&:id)).to eq([user1.id])
+
+ sign_in(user2)
+ put "/policy/accept.json", params: { post_id: post.id }
+ expect(response.status).to eq(200)
+ expect(post.reload.post_policy.accepted_by.map(&:id).sort).to eq([user1.id, user2.id])
+
+ put "/policy/unaccept.json", params: { post_id: post.id }
+ expect(response.status).to eq(200)
+ expect(post.reload.post_policy.accepted_by.map(&:id)).to eq([user1.id])
+ end
+
+ context "when add_users_to_group is present" do
+ fab!(:group2) { Fabricate(:group) }
+ fab!(:post) { Fabricate(:post, user: moderator) }
+ fab!(:policy666) do
+ policy = Fabricate(:post_policy, post: post, add_users_to_group: group2.id)
+ PostPolicyGroup.create!(post_policy_id: policy.id, group_id: group.id)
+ policy
+ end
+
+ it "adds/removes users to the group when they accept the policy" do
+ sign_in(user1)
+ put "/policy/accept.json", params: { post_id: post.id }
+
+ expect(response.status).to eq(200)
+ expect(post.reload.post_policy.accepted_by.map(&:id)).to eq([user1.id])
+ expect(group2.users.pluck(:id)).to contain_exactly(user1.id)
+
+ put "/policy/unaccept.json", params: { post_id: post.id }
+
+ expect(response.status).to eq(200)
+ expect(post.reload.post_policy.accepted_by.map(&:id)).to eq([])
+ expect(group2.users.pluck(:id)).to contain_exactly
+ end
+ end
+
+ describe "#accepted" do
+ before { sign_in(user1) }
+
+ it "returns pages of users who accepted" do
+ post = create_post(raw: raw, user: moderator)
+ PolicyUser.add!(user1, post.post_policy)
+ PolicyUser.add!(user2, post.post_policy)
+
+ get "/policy/accepted.json", params: { post_id: post.id, offset: 0 }
+ expect(response.status).to eq(200)
+ expect(response.parsed_body["users"].map { |x| x["id"] }).to contain_exactly(
+ user1.id,
+ user2.id,
+ )
+
+ get "/policy/accepted.json", params: { post_id: post.id, offset: 1 }
+ expect(response.status).to eq(200)
+ expect(response.parsed_body["users"].map { |x| x["id"] }).to contain_exactly(user2.id)
+
+ get "/policy/accepted.json", params: { post_id: post.id, offset: 2 }
+ expect(response.status).to eq(200)
+ expect(response.parsed_body["users"].map { |x| x["id"] }).to contain_exactly
+ end
+ end
+
+ describe "#not_accepted" do
+ before { sign_in(user1) }
+
+ it "returns pages of users who accepted" do
+ post = create_post(raw: raw, user: moderator)
+
+ get "/policy/not-accepted.json", params: { post_id: post.id, offset: 0 }
+ expect(response.status).to eq(200)
+ expect(response.parsed_body["users"].map { |x| x["id"] }).to contain_exactly(
+ user1.id,
+ user2.id,
+ )
+
+ get "/policy/not-accepted.json", params: { post_id: post.id, offset: 1 }
+ expect(response.status).to eq(200)
+ expect(response.parsed_body["users"].map { |x| x["id"] }).to contain_exactly(user2.id)
+
+ get "/policy/not-accepted.json", params: { post_id: post.id, offset: 2 }
+ expect(response.status).to eq(200)
+ expect(response.parsed_body["users"].map { |x| x["id"] }).to contain_exactly
+ end
+ end
+
+ describe "group member visibility restrictions" do
+ fab!(:owner) { Fabricate(:user) }
+ let!(:post) do
+ raw = <<~MD
+ [policy group=#{group.name}]
+ I always open **doors**!
+ [/policy]
+ MD
+ create_post(raw: raw, user: moderator)
+ end
+
+ before do
+ group.update!(members_visibility_level: Group.visibility_levels[:owners])
+ group.add_owner(owner)
+ end
+
+ it "returns 422 and error if user cannot see group members (accepted endpoint)" do
+ sign_in(user2)
+ get "/policy/accepted.json", params: { post_id: post.id, offset: 0 }
+ expect(response.status).to eq(422)
+ expect(response.parsed_body["errors"]).to include(
+ I18n.t("discourse_policy.error.no_permission"),
+ )
+ end
+
+ it "returns 422 and error if user cannot see group members (not_accepted endpoint)" do
+ sign_in(user2)
+ get "/policy/not-accepted.json", params: { post_id: post.id, offset: 0 }
+ expect(response.status).to eq(422)
+ expect(response.parsed_body["errors"]).to include(
+ I18n.t("discourse_policy.error.no_permission"),
+ )
+ end
+
+ it "allows owner to see group members" do
+ sign_in(owner)
+ get "/policy/accepted.json", params: { post_id: post.id, offset: 0 }
+ expect(response.status).to eq(200)
+ expect(response.parsed_body["users"]).to be_an(Array)
+ end
+ end
+end
diff --git a/plugins/discourse-policy/spec/serializers/post_serializer_spec.rb b/plugins/discourse-policy/spec/serializers/post_serializer_spec.rb
new file mode 100644
index 00000000000..4ad03f4761a
--- /dev/null
+++ b/plugins/discourse-policy/spec/serializers/post_serializer_spec.rb
@@ -0,0 +1,182 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+describe PostSerializer do
+ fab!(:group)
+ fab!(:admin)
+ fab!(:user1) { Fabricate(:user) }
+ fab!(:user2) { Fabricate(:user) }
+
+ before do
+ enable_current_plugin
+ Jobs.run_immediately!
+
+ group.add(admin)
+ group.add(user1)
+ group.add(user2)
+ end
+
+ it "includes users in the serializer" do
+ raw = <<~MD
+ [policy group=#{group.name}]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+ post.reload
+
+ json = PostSerializer.new(post, scope: Guardian.new).as_json
+ accepted = json[:post][:policy_accepted_by]
+
+ expect(accepted.length).to eq(0)
+
+ not_accepted = json[:post][:policy_not_accepted_by]
+
+ expect(not_accepted.map { |u| u[:id] }).to contain_exactly(admin.id, user1.id, user2.id)
+
+ PolicyUser.add!(user1, post.post_policy)
+
+ json = PostSerializer.new(post, scope: Guardian.new).as_json
+
+ not_accepted = json[:post][:policy_not_accepted_by]
+ accepted = json[:post][:policy_accepted_by]
+
+ expect(not_accepted.map { |u| u[:id] }).to contain_exactly(admin.id, user2.id)
+ expect(accepted.map { |u| u[:id] }).to contain_exactly(user1.id)
+ end
+
+ it "works if group not found" do
+ raw = <<~MD
+ [policy group=#{group.name}]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+ post.reload
+
+ group.destroy!
+
+ json = PostSerializer.new(post, scope: Guardian.new).as_json
+ puts json.inspect
+
+ not_accepted = json[:post][:policy_not_accepted_by]
+
+ expect(not_accepted).to eq(nil)
+ end
+
+ it "excludes inactive users" do
+ user1.active = false
+ user1.save!
+
+ raw = <<~MD
+ [policy group=#{group.name} private=true]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+ post.reload
+
+ PolicyUser.add!(user1, post.post_policy)
+
+ json = PostSerializer.new(post, scope: admin.guardian).as_json
+ expect(json[:post][:policy_accepted_by]).to be_empty
+ end
+
+ it "excludes suspended users" do
+ user1.suspended_till = 1.year.from_now
+ user1.save!
+
+ raw = <<~MD
+ [policy group=#{group.name} private=true]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+ post.reload
+
+ PolicyUser.add!(user1, post.post_policy)
+
+ json = PostSerializer.new(post, scope: admin.guardian).as_json
+ expect(json[:post][:policy_accepted_by]).to be_empty
+ end
+
+ it "does not include users if private" do
+ raw = <<~MD
+ [policy group=#{group.name} private=true]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+ post.reload
+
+ PolicyUser.add!(user1, post.post_policy)
+
+ json = PostSerializer.new(post, scope: Guardian.new).as_json
+ expect(json[:post][:policy_not_accepted_by]).to eq(nil)
+ expect(json[:post][:policy_accepted_by]).to eq(nil)
+ expect(json[:post][:policy_stats]).to eq(nil)
+
+ json = PostSerializer.new(post, scope: admin.guardian).as_json
+ expect(json[:post][:policy_not_accepted_by].map { |u| u[:id] }).to contain_exactly(
+ admin.id,
+ user2.id,
+ )
+ expect(json[:post][:policy_accepted_by].map { |u| u[:id] }).to contain_exactly(user1.id)
+ end
+
+ it "does not include users if group members are not visible to the user" do
+ group.update!(members_visibility_level: Group.visibility_levels[:owners])
+ owner = Fabricate(:user)
+ group.add_owner(owner)
+
+ raw = <<~MD
+ [policy group=#{group.name}]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+ post.reload
+
+ PolicyUser.add!(user1, post.post_policy)
+
+ # A non-owner, non-admin user should not see the user lists
+ json = PostSerializer.new(post, scope: Guardian.new(user2)).as_json
+ expect(json[:post][:policy_not_accepted_by]).to eq(nil)
+ expect(json[:post][:policy_accepted_by]).to eq(nil)
+
+ # The owner should see the user lists
+ json = PostSerializer.new(post, scope: Guardian.new(owner)).as_json
+ expect(json[:post][:policy_not_accepted_by].map { |u| u[:id] }).to include(admin.id, user2.id)
+ expect(json[:post][:policy_accepted_by].map { |u| u[:id] }).to include(user1.id)
+ end
+
+ describe "policy_easy_revoke" do
+ it "lets user accept and revoke post at the same time if enabled" do
+ raw = <<~MD
+ [policy group=#{group.name}]
+ I always open **doors**!
+ [/policy]
+ MD
+
+ post = create_post(raw: raw, user: Fabricate(:admin))
+ post.reload
+
+ json = PostSerializer.new(post, scope: admin.guardian).as_json
+ expect(json[:post][:policy_can_accept]).to eq(true)
+ expect(json[:post][:policy_can_revoke]).to eq(false)
+
+ SiteSetting.policy_easy_revoke = true
+
+ json = PostSerializer.new(post, scope: admin.guardian).as_json
+ expect(json[:post][:policy_can_accept]).to eq(true)
+ expect(json[:post][:policy_can_revoke]).to eq(true)
+ end
+ end
+end
diff --git a/plugins/discourse-policy/spec/system/core_features_spec.rb b/plugins/discourse-policy/spec/system/core_features_spec.rb
new file mode 100644
index 00000000000..db86db283bd
--- /dev/null
+++ b/plugins/discourse-policy/spec/system/core_features_spec.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+RSpec.describe "Core features", type: :system do
+ before { enable_current_plugin }
+
+ it_behaves_like "having working core features"
+end
diff --git a/plugins/discourse-policy/test/javascripts/acceptance/policy-test.js b/plugins/discourse-policy/test/javascripts/acceptance/policy-test.js
new file mode 100644
index 00000000000..900acce4fc6
--- /dev/null
+++ b/plugins/discourse-policy/test/javascripts/acceptance/policy-test.js
@@ -0,0 +1,116 @@
+/* eslint-disable qunit/no-loose-assertions */
+/* eslint-disable qunit/no-assert-equal */
+import { click, fillIn, visit } from "@ember/test-helpers";
+import { test } from "qunit";
+import { cloneJSON } from "discourse/lib/object";
+import postFixtures from "discourse/tests/fixtures/post";
+import topicFixtures from "discourse/tests/fixtures/topic";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import { i18n } from "discourse-i18n";
+
+acceptance("Discourse Policy - post", function (needs) {
+ needs.user();
+
+ needs.settings({
+ policy_enabled: true,
+ });
+
+ needs.pretender((server, helper) => {
+ const topic = cloneJSON(topicFixtures["/t/130.json"]);
+ const post = cloneJSON(postFixtures["/posts/18"]);
+
+ post.topic_id = topic.id;
+ post.policy_can_accept = true;
+ post.cooked = `<div class=\"policy\" data-group=\"everyone\" data-version=\"1\">\n<p>test</p>\n</div>`;
+
+ topic.post_stream = {
+ posts: [post],
+ stream: [post.id],
+ };
+
+ server.get("/t/130.json", () => helper.response(topic));
+ server.put("/policy/accept", () => helper.response(200, {}));
+ server.put("/policy/unaccept", () => helper.response(200, {}));
+ });
+
+ test("insert a policy", async function (assert) {
+ updateCurrentUser({ admin: true });
+ await visit("/t/-/130");
+ await click(".actions .edit");
+
+ await fillIn("textarea.d-editor-input", "");
+
+ await click(".toolbar-menu__options-trigger");
+ await click(`button[title="${i18n("discourse_policy.builder.attach")}"]`);
+ await selectKit(".group-chooser").expand();
+ await selectKit(".group-chooser").fillInFilter("staff");
+ await selectKit(".group-chooser").selectRowByValue("staff");
+ await selectKit(".group-chooser").collapse();
+
+ await selectKit(".combo-box").expand();
+ await selectKit(".combo-box").selectRowByIndex(0);
+
+ await click(".d-modal__footer .btn-primary");
+
+ let raw = document.querySelector("textarea.d-editor-input").value;
+
+ assert.equal(
+ raw.trim(),
+ '[policy reminder="daily" version="1" groups="staff"]\nI accept this policy\n[/policy]'
+ );
+ });
+
+ test("edit email preferences", async function (assert) {
+ await visit(`/u/eviltrout/preferences/emails`);
+ assert.dom("#user_policy_email_frequency").exists();
+ });
+
+ test("edit policy - staff", async function (assert) {
+ await visit("/t/-/130");
+ await click(".edit-policy-settings-btn");
+
+ assert.dom(".policy-builder").exists();
+ await selectKit(".group-chooser").expand();
+ await selectKit(".group-chooser").selectRowByName("admins");
+ await selectKit(".group-chooser").selectRowByName("moderators");
+ await selectKit(".group-chooser").collapse();
+
+ await assert.strictEqual(
+ selectKit(".group-chooser").header().value(),
+ "admins,moderators"
+ );
+ });
+
+ test("edit policy - not staff", async function (assert) {
+ updateCurrentUser({ moderator: false, admin: false });
+ await visit("/t/-/130");
+
+ assert.dom(".edit-policy-settings-btn").doesNotExist();
+ });
+
+ test("edit policy - not staff, post owner", async function (assert) {
+ updateCurrentUser({ moderator: false, admin: false, id: 1 });
+ await visit("/t/-/130");
+
+ assert.dom(".edit-policy-settings-btn").exists();
+ });
+
+ test("accept a policy", async function (assert) {
+ await visit("/t/-/130");
+ await click(".btn-accept-policy");
+
+ assert.dom(".btn-revoke-policy").exists();
+ });
+
+ test("revoke a policy", async function (assert) {
+ await visit("/t/-/130");
+ await click(".btn-accept-policy");
+ await click(".btn-revoke-policy");
+
+ assert.dom(".btn-accept-policy").exists();
+ });
+});
diff --git a/plugins/discourse-policy/test/javascripts/integration/components/policy-builder-form-test.gjs b/plugins/discourse-policy/test/javascripts/integration/components/policy-builder-form-test.gjs
new file mode 100644
index 00000000000..a8597965e57
--- /dev/null
+++ b/plugins/discourse-policy/test/javascripts/integration/components/policy-builder-form-test.gjs
@@ -0,0 +1,74 @@
+import EmberObject from "@ember/object";
+import { click, fillIn, render } from "@ember/test-helpers";
+import { module, test } from "qunit";
+import { setupRenderingTest } from "discourse/tests/helpers/component-test";
+import { query } from "discourse/tests/helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import { i18n } from "discourse-i18n";
+import PolicyBuilderForm from "discourse/plugins/discourse-policy/discourse/components/policy-builder-form";
+
+module(
+ "Discourse Policy | Integration | Component | policy-builder-form",
+ function (hooks) {
+ setupRenderingTest(hooks);
+
+ test("onChange", async function (assert) {
+ const self = this;
+
+ this.set("policy", new EmberObject());
+ this.set("onChange", (key, value) => {
+ query(".output").innerText = `${key}=${value}`;
+ });
+
+ await render(
+ <template>
+ <span class="output"></span>
+ <PolicyBuilderForm
+ @onChange={{self.onChange}}
+ @policy={{self.policy}}
+ />
+ </template>
+ );
+
+ const groupsChooser = selectKit(".groups .group-chooser");
+ await groupsChooser.expand();
+ await groupsChooser.selectRowByValue("admins");
+ assert.dom(".output").hasText("groups=admins");
+
+ await fillIn("input[name='version']", "1");
+ assert.dom(".output").hasText("version=1");
+
+ await fillIn("input[name='renew']", "1");
+ assert.dom(".output").hasText("renew=1");
+
+ await fillIn("input[name='renew-start']", "2022-06-07");
+ assert.dom(".output").hasText("renew-start=2022-06-07");
+
+ const reminderChooser = selectKit(".combo-box");
+ assert
+ .dom(reminderChooser.header().el())
+ .hasText(
+ i18n("discourse_policy.builder.reminder.no_reminder"),
+ "should be set by default"
+ );
+
+ await reminderChooser.expand();
+ await reminderChooser.selectRowByValue("weekly");
+ assert.dom(".output").hasText("reminder=weekly");
+
+ await fillIn("input[name='accept']", "foo");
+ assert.dom(".output").hasText("accept=foo");
+
+ await fillIn("input[name='revoke']", "bar");
+ assert.dom(".output").hasText("revoke=bar");
+
+ const addGroupsChooser = selectKit(".add-users-to-group .group-chooser");
+ await addGroupsChooser.expand();
+ await addGroupsChooser.selectRowByValue("moderators");
+ assert.dom(".output").hasText("add-users-to-group=moderators");
+
+ await click("input[name='private']");
+ assert.dom(".output").hasText("private=true");
+ });
+ }
+);
diff --git a/plugins/discourse-policy/test/javascripts/integration/components/post-policy-test.gjs b/plugins/discourse-policy/test/javascripts/integration/components/post-policy-test.gjs
new file mode 100644
index 00000000000..1343556b029
--- /dev/null
+++ b/plugins/discourse-policy/test/javascripts/integration/components/post-policy-test.gjs
@@ -0,0 +1,259 @@
+import EmberObject from "@ember/object";
+import { click, render } from "@ember/test-helpers";
+import { module, test } from "qunit";
+import { setupRenderingTest } from "discourse/tests/helpers/component-test";
+import pretender, { response } from "discourse/tests/helpers/create-pretender";
+import { i18n } from "discourse-i18n";
+import PostPolicy from "discourse/plugins/discourse-policy/discourse/components/post-policy";
+
+function fabricatePost(options = {}) {
+ return EmberObject.create({ id: 1, ...options });
+}
+
+function fabricatePolicy(options = {}) {
+ return EmberObject.create({ accept: "ok", revoke: "not ok", ...options });
+}
+
+module(
+ "Discourse Policy | Integration | Component | post-policy",
+ function (hooks) {
+ setupRenderingTest(hooks);
+
+ test("empty post", async function (assert) {
+ const self = this;
+
+ await render(
+ <template>
+ <PostPolicy @post={{self.post}} @policy={{self.policy}} />
+ </template>
+ );
+
+ assert.dom(".policy-footer").doesNotExist();
+ });
+
+ test("post#policy_can_accept", async function (assert) {
+ const self = this;
+
+ this.set("post", fabricatePost({ policy_can_accept: true }));
+ this.set("policy", fabricatePolicy());
+
+ await render(
+ <template>
+ <PostPolicy @post={{self.post}} @policy={{self.policy}} />
+ </template>
+ );
+
+ assert.dom(".btn-accept-policy").exists();
+ assert.dom(".btn-accept-policy").hasText(this.policy.accept);
+ });
+
+ test("post#policy_can_revoke", async function (assert) {
+ const self = this;
+
+ this.set("post", fabricatePost({ policy_can_revoke: true }));
+ this.set("policy", fabricatePolicy());
+
+ await render(
+ <template>
+ <PostPolicy @post={{self.post}} @policy={{self.policy}} />
+ </template>
+ );
+
+ assert.dom(".btn-revoke-policy").exists();
+ assert.dom(".btn-revoke-policy").hasText(this.policy.revoke);
+ });
+
+ test("post#policy_accepted_by_count", async function (assert) {
+ const self = this;
+
+ this.set("post", fabricatePost({ policy_accepted_by_count: 10 }));
+ this.set("policy", fabricatePolicy());
+
+ await render(
+ <template>
+ <PostPolicy @post={{self.post}} @policy={{self.policy}} />
+ </template>
+ );
+
+ assert.dom(".toggle-accepted .user-count").hasText("10");
+ });
+
+ test("post#policy_not_accepted_by_count", async function (assert) {
+ const self = this;
+
+ this.set("post", fabricatePost({ policy_not_accepted_by_count: 10 }));
+ this.set("policy", fabricatePolicy());
+
+ await render(
+ <template>
+ <PostPolicy @post={{self.post}} @policy={{self.policy}} />
+ </template>
+ );
+
+ assert.dom(".toggle-not-accepted .user-count").hasText("10");
+ });
+
+ test("no possible users", async function (assert) {
+ const self = this;
+
+ this.set(
+ "post",
+ fabricatePost({
+ policy_accepted_by_count: 0,
+ policy_not_accepted_by_count: 0,
+ policy_stats: true,
+ })
+ );
+ this.set("policy", fabricatePolicy());
+
+ await render(
+ <template>
+ <PostPolicy @post={{self.post}} @policy={{self.policy}} />
+ </template>
+ );
+
+ assert
+ .dom(".no-possible-users")
+ .hasText(i18n("discourse_policy.no_possible_users"));
+ });
+
+ test("does not show 'no possible users' when no access to stats", async function (assert) {
+ const self = this;
+
+ this.set(
+ "post",
+ fabricatePost({
+ policy_accepted_by_count: 0,
+ policy_not_accepted_by_count: 0,
+ })
+ );
+ this.set("policy", fabricatePolicy());
+
+ await render(
+ <template>
+ <PostPolicy @post={{self.post}} @policy={{self.policy}} />
+ </template>
+ );
+
+ assert.dom(".no-possible-users").doesNotExist();
+ });
+
+ test("toggle state", async function (assert) {
+ const self = this;
+
+ const acceptedByUsers = [
+ { id: 1, username: "jeanne", avatar_template: "/images/avatar.png" },
+ ];
+
+ const notAcceptedByUsers = [
+ { id: 2, username: "bob", avatar_template: "/images/avatar.png" },
+ { id: 3, username: "alex", avatar_template: "/images/avatar.png" },
+ ];
+
+ this.set(
+ "post",
+ fabricatePost({
+ policy_accepted_by: acceptedByUsers,
+ policy_accepted_by_count: 1,
+ policy_not_accepted_by: notAcceptedByUsers,
+ policy_not_accepted_by_count: 3,
+ })
+ );
+ this.set("policy", fabricatePolicy());
+
+ await render(
+ <template>
+ <PostPolicy @post={{self.post}} @policy={{self.policy}} />
+ </template>
+ );
+
+ assert.dom(".users.accepted .avatar").exists({ count: 1 });
+ assert.dom(".user-lists .toggle-accepted .user-count").hasText("1");
+ assert.dom(".users.not-accepted").doesNotExist();
+
+ await click(".toggle-not-accepted");
+
+ assert.dom(".users.accepted").doesNotExist();
+ assert.dom(".users.not-accepted .avatar").exists({ count: 2 });
+ assert.dom(".user-lists .toggle-not-accepted .user-count").hasText("3");
+ assert.dom(".load-more-users").hasText("+ 1");
+
+ await click(".toggle-accepted");
+
+ assert.dom(".users.accepted").exists();
+ assert.dom(".users.not-accepted").doesNotExist();
+ });
+
+ test("accept policy", async function (assert) {
+ const self = this;
+
+ this.set("currentUser", {
+ id: 1,
+ username: "bob",
+ avatar_template: "/images/avatar.png",
+ });
+ this.set(
+ "post",
+ fabricatePost({
+ policy_can_accept: true,
+ policy_not_accepted_by: [this.currentUser],
+ policy_not_accepted_by_count: 1,
+ })
+ );
+ this.set("policy", fabricatePolicy());
+
+ await render(
+ <template>
+ <PostPolicy @post={{self.post}} @policy={{self.policy}} />
+ </template>
+ );
+
+ pretender.put("/policy/accept", () => {
+ this.post.set("policy_accepted_by", this.currentUser);
+ this.post.set("policy_accepted_by_count", 1);
+ return response({});
+ });
+
+ await click(".btn-accept-policy");
+
+ assert.dom(".btn-revoke-policy").exists();
+ assert.dom(".user-lists .toggle-accepted .user-count").hasText("1");
+ });
+
+ test("revoke policy", async function (assert) {
+ const self = this;
+
+ this.set("currentUser", {
+ id: 1,
+ username: "bob",
+ avatar_template: "/images/avatar.png",
+ });
+ this.set(
+ "post",
+ fabricatePost({
+ policy_can_revoke: true,
+ policy_accepted_by: [this.currentUser],
+ policy_accepted_by_count: 1,
+ })
+ );
+ this.set("policy", fabricatePolicy());
+
+ await render(
+ <template>
+ <PostPolicy @post={{self.post}} @policy={{self.policy}} />
+ </template>
+ );
+
+ pretender.put("/policy/unaccept", () => {
+ this.post.set("policy_not_accepted_by", this.currentUser);
+ this.post.set("policy_not_accepted_by_count", 1);
+ return response({});
+ });
+
+ await click(".btn-revoke-policy");
+
+ assert.dom(".btn-accept-policy").exists();
+ assert.dom(".user-lists .toggle-not-accepted .user-count").hasText("1");
+ });
+ }
+);
diff --git a/translator.yml b/translator.yml
index e3ba82c0435..b6eadf03b46 100644
--- a/translator.yml
+++ b/translator.yml
@@ -246,3 +246,10 @@ files:
- source_path: plugins/discourse-calendar/config/locales/server.en.yml
destination_path: plugins/calendar/server.yml
label: calendar
+
+ - source_path: plugins/discourse-policy/config/locales/client.en.yml
+ destination_path: plugins/policy/client.yml
+ label: policy
+ - source_path: plugins/discourse-policy/config/locales/server.en.yml
+ destination_path: plugins/policy/server.yml
+ label: policy