مهمة Rake لدمج المستخدمين

اعتبارًا من Discourse 2.5.0.beta3، يمكن لمسؤولي الموقع دمج المستخدمين غير منسوبي الطاقم دون الحاجة إلى الوصول إلى وحدة التحكم. ولأغراض أمنية، سيظل دمج المستخدمين المنسوبي الطاقم يتطلب الوصول إلى وحدة التحكم.

انتقل إلى صفحة إدارة المستخدمين، واختر “دمج” في أسفل الصفحة.
image

أدخل اسم المستخدم الذي تريد دمج الحساب فيه، ثم انقر على “نقل وحذف @username” لبدء عملية الدمج.


تتوفر الآن مهمة rake لدمج المستخدمين على tests-passed. :sunny:

يمكن دمج المستخدمين بتنفيذ الأمر التالي:

rake users:merge['source_username','target_username']

(ملاحظة: تأكد من عدم وجود مسافة قبل أو بعد الفاصلة)

تقوم هذه العملية بدمج بيانات المستخدم المصدر في المستخدم الهدف قبل حذف المستخدم المصدر. يتم دمج محتوى 45 جدولًا، لذا قد تستغرق هذه العملية بعض الوقت اعتمادًا على كمية البيانات المرتبطة بـ المستخدم المصدر.

يمكن لـ مطوري الإضافات الارتباط بعملية الدمج من خلال معالجة حدث :merging_users. لقد قمت بالفعل بتطبيق ذلك في إضافة الاستطلاعات، والتي تدمج أصوات المستخدمين المدمجين.

المشاكل المعروفة:

  1. الروابط الواردة التي لا تزال تشير إلى المستخدم المصدر (مثل https://talk.example.com/t/some-topic/17/3?u=source_username) لن ترتبط بـ المستخدم الهدف.

  2. يمكن للمستخدم أن يكون له مستخدم ظل واحد فقط (من ميزة السماح بالنشر المجهول). لذا، إذا كان كلا المستخدمين المدمجين لهما مستخدم ظل، فسيُفقد المستخدم الظل المملوك لـ المستخدم المصدر… حسنًا، لا يزال موجودًا، لكنه لم يعد مرتبطًا بأي مستخدم حالي.

55 إعجابًا

Ooh… That’s the most exciting part of this to me.

3 إعجابات

We should try this out on some of the accounts at rubytalk.org … a great little test site, Matz has like 5 emails.

7 إعجابات

Thank you for this feature, it is huge for my use case! I am currently porting our forums from phpBB to Discourse and wanted to use SSO via a custom provider. Since we could not easily link SSO accounts to our legacy accounts and works flawlessly!

If anyone else is going to use this make a note of this:

rake users:merge['mattbr_sso', 'mattbr_legacy'] will not work as expected, the SSO will not go through. However:

rake users:merge['mattbr_legacy', 'mattbr_sso'] works perfectly and allows you to migrate all the posts into the SSO account.

Thanks for the feature :slight_smile:

8 إعجابات

I’m super excited about this, but can’t see any mention of webhooks in this topic. Is this planned @gerhard?

How are webhooks relevant to this?

When using the ‘User Event’-webhook created or login (or approved?) the duplicates will be existent on a connected site as well and one might want an automatism to clean them up as well, if the connected site supports that.

I haven’t used webhooks yet but plan to. On my connected site (using Discourse as SSO provider) the users are only created at first login for now.
+ I had duplicate users in my old forum before migrating to Discourse which I was looking forward to consolidate once this feature becomes available.

I had another user question about this today, He also asked about the “Created” field in his profile.

  1. Is this function going to be implemented in the GUI, or will it stay a rake task?
  2. Will (or has) the rake task be(en) changed to handle mentions and quotes?
  3. Would it be possible to set “Created” to the date of the oldest owned post?

It will stay a rake task for now.

Yes, it will. I should be able to make this happen for the 2.0 release.

You will have to update the user’s created_at manually if you want to set it to the oldest post. The merge process uses the created_at from either the source or target user – whatever date is earlier.

4 إعجابات

This being the case, if as a hosted customer I have accounts to be merged, should I ping the details through to the Discourse team for actioning?

5 إعجابات

Sure that sounds fine. We also need to exercise the feature internally to make sure it is working right.

4 إعجابات

Quick update: Merging users now updates mentions, quotes and avatars in posts and revisions. :tada:

31 إعجابًا

Any chance the staff action log could better show what happens to users when they are merged? Here’s how it looks now - just shows that system has deleted the user but no context. The details only show some info about the user that got deleted as a result of the merge.

8 إعجابات

Sure what do you think @gerhard?

4 إعجابات

How about adding a staff note along the lines of “Username with email was merged to this account, date

This is what I did when I was merging accounts manually. Probably more work than a staff action log entry, but might be useful information at some point later.

4 إعجابات

@gerhard we should make sure the task is logged in the staff logs if possible, per above ↑ ↑

إعجابَين (2)

I’m currently writing my todo list for this week and it’s already on it. :slight_smile:

5 إعجابات

Is there an easy way to change which email address is primary?

Here’s my use case:

imported user with email user@defunctdomain.com emails from user@fancynewemail.com which creates a staged user. After a few PMs with the staged user, I merge the accounts, but the primary address is still the old one. And from the web interface I can’t change the email in his profile because it’s already taken. By him.

Perhaps this is a bug in the multiple email address model and not a complaint for here.

The simple solution, which took me much to long to come up with, is to delete the old address.

إعجابَين (2)

Merging users always preserves the existing data of the target_user, so the email address of the source_user is only added as secondary email address.

Yeah, that’s the solution.

إعجابَين (2)

Is there something easier that I should do?
I need to keep the old username with the new email. The staged user is the real problem. Perhaps I should just delete the staged user, but then I don’t have an easy way to reply to them to tell them what happened.

It’s pretty cumbersome to merge[‘newname_newemail’,'oldname_bogusemail"] and then have to do something like

u=User.find_by_username['oldname_bogusemail']
ue=UserEmail.where(user_id: u.id)
ue[0].destroy
ue[1].active=true
ue[1].save

is there some easier way that I’m missing?

إعجاب واحد (1)