# 允许PM给员工

**URL:** <https://meta.discourse.org/t/allow-pm-to-staff/260946>\
**Category:** Plugin\
**Created:** [2023年四月7日 14:52 UTC](https://meta.discourse.org/t/allow-pm-to-staff/260946 "2023-04-07T14:52:28Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)\
**Post date:** [2026年七月4日 16:37 UTC](https://meta.discourse.org/t/allow-pm-to-staff/260946/21 "2026-07-04T16:37:09Z")

</div>

自 2026.7.0-latest +1 版本以及[今日版本](https://github.com/discourse/discourse/commits/28b003a38d82c354ffc49bac23b655de9664e478 "View commit 28b003a38d on GitHub")起，我便无法再发送私信（pn）了。我检查了日志，发现是 `discourse-allow-pm-to-staff` 插件导致的问题。禁用该插件后，私信功能恢复正常。以下是我在日志中发现的内容：

```plaintext
plugins/discourse-allow-pm-to-staff/plugin.rb:46:in 'block (2 levels) in activate!'

lib/plugin/instance.rb:460:in 'Kernel#public_send'

lib/plugin/instance.rb:460:in 'block (2 levels) in Guardian#add_to_class'

lib/topic_creator.rb:356:in 'TopicCreator#check_can_send_permission!'

lib/topic_creator.rb:305:in 'block in TopicCreator#add_users_from_scope'

activerecord (8.0.5) lib/active_record/relation/batches.rb:88:in 'Array#each'

activerecord (8.0.5) lib/active_record/relation/batches.rb:88:in 'block in ActiveRecord::Batches#find_each'

activerecord (8.0.5) lib/active_record/relation/batches.rb:172:in 'block in ActiveRecord::Batches#find_in_batches'

activerecord (8.0.5) lib/active_record/relation/batches.rb:461:in 'block in ActiveRecord::Batches#batch_on_unloaded_relation'

<internal:kernel>:168:in 'Kernel#loop'

activerecord (8.0.5) lib/active_record/relation/batches.rb:434:in 'ActiveRecord::Batches#batch_on_unloaded_relation'

activerecord (8.0.5) lib/active_record/relation/batches.rb:289:in 'ActiveRecord::Batches#in_batches'

activerecord (8.0.5) lib/active_record/relation/batches.rb:171:in 'ActiveRecord::Batches#find_in_batches'

activerecord (8.0.5) lib/active_record/relation/batches.rb:87:in 'ActiveRecord::Batches#find_each'

lib/topic_creator.rb:304:in 'TopicCreator#add_users_from_scope'

lib/topic_creator.rb:289:in 'TopicCreator#add_users'

lib/topic_creator.rb:271:in 'TopicCreator#process_private_message'

lib/topic_creator.rb:69:in 'TopicCreator#create'

lib/post_creator.rb:511:in 'PostCreator#create_topic'

lib/post_creator.rb:201:in 'block in PostCreator#create'

lib/post_creator.rb:411:in 'block in PostCreator#transaction'

activerecord (8.0.5) lib/active_record/connection_adapters/abstract/transaction.rb:626:in 'block in ActiveRecord::ConnectionAdapters::TransactionManager#within_new_transaction'

activesupport (8.0.5) lib/active_support/concurrency/null_lock.rb:9:in 'ActiveSupport::Concurrency::NullLock#synchronize'

activerecord (8.0.5) lib/active_record/connection_adapters/abstract/transaction.rb:623:in 'ActiveRecord::ConnectionAdapters::TransactionManager#within_new_transaction'

activerecord (8.0.5) lib/active_record/connection_adapters/abstract/database_statements.rb:367:in 'ActiveRecord::ConnectionAdapters::DatabaseStatements#within_new_transaction'

activerecord (8.0.5) lib/active_record/connection_adapters/abstract/database_statements.rb:359:in 'ActiveRecord::ConnectionAdapters::DatabaseStatements#transaction'

activerecord (8.0.5) lib/active_record/transactions.rb:233:in 'block in ActiveRecord::Transactions::ClassMethods#transaction'

activerecord (8.0.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in 'ActiveRecord::ConnectionAdapters::ConnectionPool#with_connection'

activerecord (8.0.5) lib/active_record/connection_handling.rb:312:in 'ActiveRecord::ConnectionHandling#with_connection'

activerecord (8.0.5) lib/active_record/transactions.rb:232:in 'ActiveRecord::Transactions::ClassMethods#transaction'

lib/post_creator.rb:411:in 'PostCreator#transaction'

lib/post_creator.rb:199:in 'PostCreator#create'

lib/new_post_manager.rb:316:in 'NewPostManager#perform_create_post'

lib/new_post_manager.rb:247:in 'NewPostManager#perform'

app/controllers/posts_controller.rb:218:in 'PostsController#create'

actionpack (8.0.5) lib/action_controller/metal/basic_implicit_render.rb:8:in 'ActionController::BasicImplicitRender#send_action'

actionpack (8.0.5) lib/abstract_controller/base.rb:215:in 'AbstractController::Base#process_action'

actionpack (8.0.5) lib/action_controller/metal/rendering.rb:193:in 'ActionController::Rendering#process_action'

actionpack (8.0.5) lib/abstract_controller/callbacks.rb:261:in 'block in AbstractController::Callbacks#process_action'

activesupport (8.0.5) lib/active_support/callbacks.rb:120:in 'block in ActiveSupport::Callbacks#run_callbacks'

plugins/discourse-staff-alias/lib/discourse_staff_alias/posts_controller_extension.rb:26:in 'block (2 levels) in <module:PostsControllerExtension>'

activesupport (8.0.5) lib/active_support/callbacks.rb:129:in 'BasicObject#instance_exec'

activesupport (8.0.5) lib/active_support/callbacks.rb:129:in 'block in ActiveSupport::Callbacks#run_callbacks'

app/controllers/application_controller.rb:442:in 'block in ApplicationController#with_resolved_locale'

i18n (1.14.8) lib/i18n.rb:354:in 'I18n::Base#with_locale'

app/controllers/application_controller.rb:442:in 'ApplicationController#with_resolved_locale'

activesupport (8.0.5) lib/active_support/callbacks.rb:129:in 'block in ActiveSupport::Callbacks#run_callbacks'

app/controllers/application_controller.rb:1098:in 'ApplicationController#ensure_dont_cache_page'

activesupport (8.0.5) lib/active_support/callbacks.rb:129:in 'block in ActiveSupport::Callbacks#run_callbacks'

activesupport (8.0.5) lib/active_support/callbacks.rb:140:in 'ActiveSupport::Callbacks#run_callbacks'

actionpack (8.0.5) lib/abstract_controller/callbacks.rb:260:in 'AbstractController::Callbacks#process_action'

actionpack (8.0.5) lib/action_controller/metal/rescue.rb:27:in 'ActionController::Rescue#process_action'

actionpack (8.0.5) lib/action_controller/metal/instrumentation.rb:76:in 'block in ActionController::Instrumentation#process_action'

activesupport (8.0.5) lib/active_support/notifications.rb:210:in 'block in ActiveSupport::Notifications.instrument'

activesupport (8.0.5) lib/active_support/notifications/instrumenter.rb:58:in 'ActiveSupport::Notifications::Instrumenter#instrument'

activesupport (8.0.5) lib/active_support/notifications.rb:210:in 'ActiveSupport::Notifications.instrument'

actionpack (8.0.5) lib/action_controller/metal/instrumentation.rb:75:in 'ActionController::Instrumentation#process_action'

actionpack (8.0.5) lib/action_controller/metal/params_wrapper.rb:259:in 'ActionController::ParamsWrapper#process_action'

activerecord (8.0.5) lib/active_record/railties/controller_runtime.rb:39:in 'ActiveRecord::Railties::ControllerRuntime#process_action'

actionpack (8.0.5) lib/abstract_controller/base.rb:152:in 'AbstractController::Base#process'

actionview (8.0.5) lib/action_view/rendering.rb:40:in 'ActionView::Rendering#process'

rack-mini-profiler (4.0.1) lib/mini_profiler/profiling_methods.rb:116:in 'block in ActionController::Base#profile_method'[](https://github.com/rack/rack/blob/master/mini_profiler/profiling_methods.rb#L116)

actionpack (8.0.5) lib/action_controller/metal.rb:252:in 'ActionController::Metal#dispatch'

actionpack (8.0.5) lib/action_controller/metal.rb:335:in 'ActionController::Metal.dispatch'

actionpack (8.0.5) lib/action_dispatch/routing/route_set.rb:67:in 'ActionDispatch::Routing::RouteSet::Dispatcher#dispatch'

actionpack (8.0.5) lib/action_dispatch/routing/route_set.rb:50:in 'ActionDispatch::Routing::RouteSet::Dispatcher#serve'

actionpack (8.0.5) lib/action_dispatch/journey/router.rb:53:in 'block in ActionDispatch::Journey::Router#serve'

actionpack (8.0.5) lib/action_dispatch/journey/router.rb:133:in 'block in ActionDispatch::Journey::Router#find_routes'

actionpack (8.0.5) lib/action_dispatch/journey/router.rb:126:in 'Array#each'

actionpack (8.0.5) lib/action_dispatch/journey/router.rb:126:in 'ActionDispatch::Journey::Router#find_routes'

actionpack (8.0.5) lib/action_dispatch/journey/router.rb:34:in 'ActionDispatch::Journey::Router#serve'

actionpack (8.0.5) lib/action_dispatch/routing/route_set.rb:908:in 'ActionDispatch::Routing::RouteSet#call'

lib/middleware/omniauth_bypass_middleware.rb:35:in 'Middleware::OmniauthBypassMiddleware#call'

lib/middleware/crawler_hooks.rb:13:in 'Middleware::CrawlerHooks#call'

rack (2.2.23) lib/rack/tempfile_reaper.rb:15:in 'Rack::TempfileReaper#call'

rack (2.2.23) lib/rack/conditional_get.rb:40:in 'Rack::ConditionalGet#call'

rack (2.2.23) lib/rack/head.rb:12:in 'Rack::Head#call'

```

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2026年七月4日 17:39 UTC](https://meta.discourse.org/t/allow-pm-to-staff/260946/22 "2026-07-04T17:39:41Z")

</div>

嗯。我想最新的更新可能弄坏了一些东西。我不确定我创建它的那个人是否还在使用它，或者是否有预算来修复它。如果我能联系到他，我会把它修好。

欢迎提交 PR。

---

<div class="post-metadata">

**Author:** ![pmcpa](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@pmcpa](https://meta.discourse.org/u/pmcpa)\
**Post date:** [2026年七月10日 11:11 UTC](https://meta.discourse.org/t/allow-pm-to-staff/260946/23 "2026-07-10T11:11:07Z")

</div>

我也看到了这个：

```plaintext

7
ArgumentError (unknown keyword: :private_message_context) lib/plugin/instance.rb:460:in 'Kernel#public_send' lib/plugin/instance.rb:460:in 'block (2 levels) in Guardian#add_to_class' lib/topic_creator
6:52 am
7
Failed to handle exception in exception app middleware : ArgumentError : unknown keyword: :private_message_context
6:52 am

```

禁用插件并重建已恢复的私信

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2026年七月10日 15:10 UTC](https://meta.discourse.org/t/allow-pm-to-staff/260946/24 "2026-07-10T15:10:14Z")

</div>

我还没有收到任何提交 PR 的人或支付开发费用的客户的消息，所以我还没有抽出时间进行调查。我可能会在下周查看一下。

---

<div class="post-metadata">

**Author:** ![pmcpa](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@pmcpa](https://meta.discourse.org/u/pmcpa)\
**Post date:** [2026年七月14日 15:12 UTC](https://meta.discourse.org/t/allow-pm-to-staff/260946/25 "2026-07-14T15:12:03Z")

</div>

我给你发了一封关于此事的邮件

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2026年七月14日 19:28 UTC](https://meta.discourse.org/t/allow-pm-to-staff/260946/26 "2026-07-14T19:28:37Z")

</div>

感谢 @pmcpa 支持必要的更新。我解决了由核心更改引起的问题，并将骨架和代码规范检查更新到了当前版本。我还更新了测试，补充了一些缺失的测试用例。

我自己并没有使用这个项目，所以如果你发现它能正常工作，请告诉我！（也许只需发个 :100 表情或那些新潮的“提升”功能）

---

<div class="post-metadata">

**Author:** ![pmcpa](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@pmcpa](https://meta.discourse.org/u/pmcpa)\
**Post date:** [2026年七月15日 10:35 UTC](https://meta.discourse.org/t/allow-pm-to-staff/260946/27 "2026-07-15T10:35:30Z")

</div>

更新似乎成功了，谢谢！

---

<div class="post-metadata">

**Author:** ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)\
**Post date:** [2026年七月18日 10:42 UTC](https://meta.discourse.org/t/allow-pm-to-staff/260946/28 "2026-07-18T10:42:03Z")

</div>

> [@pfaffman](#):
>
> 我自己没有在使用这个功能，所以如果你发现它确实有效，请告诉我！

我刚刚重新启用了该插件，发现私信功能仍然可以正常使用（或者说又恢复正常了）。🙂 非常感谢！😃

[上一頁](https://meta.discourse.org/t/allow-pm-to-staff/260946.md?page=1)
