حسنًا، لا أستطيع البرمجة بنفسي، ولأن هذا سيكون إثبات مفهوم قبل أن أتمكن من إقناع مديري بدعمه، لا أملك وسيلة لتقديم دعم مالي في الوقت الحالي.
هل يعتقد أحد أنه شيء مثل هذا سيكون جيدًا للمجتمع؟
اعتبار آخر، هل هناك أي تواصل بين Discourse وملحق الاشتراكات يمكن أن يتابع عدد الاشتراكات التي يمتلكها المستخدم؟ سيكون من المفيد السماح لشخص ما بشراء عدة منشورات دفعة واحدة بدلاً من شراء واحدة ثم نشرها، ثم شراء أخرى ثم النشر مرة أخرى.
بالتأكيد، ولكن سيكون من الرائع الحصول عليه.
على أي حال، يبدو أن هذا سيفي بالغرض طالما أنك تقوم بتثبيت معرف الفئة واسم المجموعة بشكل ثابت.
هل يمكن لأي مبرمجين حقيقيين التوسع في هذا بحيث يمكنك تعيين هذه المتغيرات من صفحة إعدادات المكون الإضافي؟
# name: discourse-auto-remove-group
# version: 0.1
# authors: tknospdr
# url: https://github.com/tknospdr/discourse-auto-remove-group
enabled_site_setting :auto_remove_group_enabled
# Site setting to enable/disable the plugin
register_site_setting :auto_remove_group_enabled, type: :boolean, default: false
register_site_setting :auto_remove_group_category_id, type: :integer, default: 0
register_site_setting :auto_remove_group_name, type: :string, default: ""
after_initialize do
# Listen for post creation events
DiscourseEvent.on(:post_created) do |post|
next unless SiteSetting.auto_remove_group_enabled
next unless post&.user # Ensure post has a user
next unless post&.topic&.category_id # Ensure post is in a category
target_category_id = SiteSetting.auto_remove_group_category_id
group_name = SiteSetting.auto_remove_group_name
# Check if the post is in the configured category
if post.topic.category_id == target_category_id
begin
group = Group.find_by(name: group_name)
unless group
Rails.logger.error("AutoRemoveGroup: Group '#{group_name}' not found")
next
end
user = post.user
if group.users.include?(user)
group.remove(user)
Rails.logger.info("AutoRemoveGroup: Removed user #{user.username} from group #{group_name} after posting in category #{target_category_id}")
else
Rails.logger.info("AutoRemoveGroup: User #{user.username} is not in group #{group_name}, no action taken")
end
rescue StandardError => e
Rails.logger.error("AutoRemoveGroup: Error removing user from group: #{e.message}")
end
end
end
end
كلا من grok و ask.discourse.com يطلبان تثبيت الإضافة في /var/discouse/plugins/.
المشكلة هي أنه ليس لدي هذا المسار، سواء داخل الحاوية أو خارجها. أقرب شيء يمكنني العثور عليه هو داخل الحاوية لدي /var/www/discourse/plugins/.
عندما أحاول تثبيتها هناك وإعادة البناء، تختفي.
حسنًا، لذا يقول الروبوت أن هذا طبيعي للتثبيت المستضاف ذاتيًا. لا أعرف كيفية إعداد مستودع git مناسب لتثبيت الإضافة بالطريقة العادية. هل يمكن لأحد مساعدتي في ذلك؟
أعتقد أنني قمت بإعداد git، وقمت بتثبيت المكون الإضافي وحصلت على بعض الأخطاء. هذا هو المكان الذي أضيع فيه بصراحة.
/var/www/discourse/plugins/discourse-auto-remove-group/plugin.rb:9:in `activate!': undefined method `register_site_setting' for an instance of Plugin::Instance (NoMethodError)
You are unable to start Discourse due to errors in the plugin at
/var/www/discourse/plugins/discourse-auto-remove-group
Please try removing this plugin and rebuilding again!
I, [2025-05-20T16:17:10.306025 #1] INFO -- :
I, [2025-05-20T16:17:10.347496 #1] INFO -- : Terminating async processes
I, [2025-05-20T16:17:10.350251 #1] INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/15/bin/postmaster -D /etc/postgresql/15/main pid: 42
I, [2025-05-20T16:17:10.351238 #1] INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 109
2025-05-20 16:17:10.351 UTC [42] LOG: received fast shutdown request
109:signal-handler (1747757830) Received SIGTERM scheduling shutdown...
109:M 20 May 2025 16:17:10.368 # User requested shutdown...
109:M 20 May 2025 16:17:10.369 * Saving the final RDB snapshot before exiting.
2025-05-20 16:17:10.412 UTC [42] LOG: aborting any active transactions
2025-05-20 16:17:10.438 UTC [42] LOG: background worker "logical replication launcher" (PID 56) exited with exit code 1
2025-05-20 16:17:10.438 UTC [51] LOG: shutting down
2025-05-20 16:17:10.447 UTC [51] LOG: checkpoint starting: shutdown immediate
2025-05-20 16:17:10.526 UTC [51] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.088 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=4 kB
2025-05-20 16:17:10.540 UTC [42] LOG: database system is shut down
109:M 20 May 2025 16:17:10.947 * DB saved on disk
109:M 20 May 2025 16:17:10.947 # Redis is now ready to exit, bye bye...
FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 987 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "tag"=>"migrate", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
9fed9596b10ffb4628947e678585b813813ae27a4de746feba16e89f2b9cdc51