Sure what do you think @gerhard?
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.
@gerhard we should make sure the task is logged in the staff logs if possible, per above ↑ ↑
I’m currently writing my todo list for this week and it’s already on it.
Is there an easy way to change which email address is primary?
Here’s my use case:
imported user with email email@example.com emails from firstname.lastname@example.org 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.
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.
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.destroy ue.active=true ue.save
is there some easier way that I’m missing?
I updated the rake task so that it logs a “merge user” action instead of “delete user” in the staff logs.
I’m little bit confused. I don’t have
users:merge task in my docker container. Does it already in
v2.1.0.beta2 +16 version?
Yes, it’s part of Discourse since 2.0.0.beta4
Hm. Here what I have when I run
And I rebuild discourse container in a last week.
Oh, I see. The task doesn’t show up in that list because it doesn’t have a description. I’m going to add one.
But you should be able to execute the task as shown in the first post:
Here is what I have:
root@host:/var/www/discourse# rake users:merge['source','target'] rake aborted! PG::UndefinedFunction: ОШИБКА: функция jsonb_build_object(unknown, text, unknown, text, unknown, text, unknown, text) не существует LINE 4: jsonb_build_object( ^ HINT: Функция с данными именем и типами аргументов не найдена. Возможно, вам следует добавить явные приведения типов. /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-mini-profiler-1.0.0/lib/patches/db/pg.rb:92:in `async_exec' /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-mini-profiler-1.0.0/lib/patches/db/pg.rb:92:in `async_exec' /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/mini_sql-0.1.9/lib/mini_sql/connection.rb:104:in `run' /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/mini_sql-0.1.9/lib/mini_sql/connection.rb:76:in `exec' /var/www/discourse/app/jobs/regular/update_username.rb:63:in `update_notifications' /var/www/discourse/app/jobs/regular/update_username.rb:22:in `execute' /var/www/discourse/app/services/username_changer.rb:46:in `update_username' /var/www/discourse/app/services/user_merger.rb:30:in `update_username' /var/www/discourse/app/services/user_merger.rb:10:in `merge!' /var/www/discourse/lib/tasks/users.rake:47:in `block in <top (required)>' /usr/local/bin/bundle:23:in `load' /usr/local/bin/bundle:23:in `<main>' Tasks: TOP => users:merge (See full trace by running task with --trace)
ERROR: function jsonb_build_object(unknown, text, unknown, text, unknown, text, unknown, text) doesn't exist
You need to upgrade PostgreSQL to version 9.5 or greater. The current docker container uses Postgres 10 by default.
Ou, I see now. Thank you very much!
The software powering this discussion forum encountered an unexpected problem. We apologize for the inconvenience.
Disabling the plugin solves the problem, but I like the plugin, so ideas on how I could fix it are very welcome!
The line in question is at https://github.com/discourse/discourse-voting/blob/master/plugin.rb#L112 and I think I’ve fixed it at https://github.com/discourse/discourse-voting/pull/33.
Maybe. Plugins can subscribe to the
:merging_users event. It’s possible that the Voting plugin needs to do that.
Just found out about this and immediately tried it out. Works like a charm. Thank you for this nice feature!
Is there any way to empty the second emails field? I merged two users and then later realized I should not have done so. Now I can’t create the user again because the email address is in the second emails field.
Obviously some sort of UI fix would be lovely long term for emptying/changing these addresses, but I know that’s likely a ways off. In the meantime I’d be grateful for command line steps. Thanks in advance!
Sure, this can be done in the rails console within the container.
rails c # restrict to secondary emails, just in case you try to delete the wrong email UserEmail.where(email: "email@example.com", primary: false).destroy_all # probably not needed, but better safe than sorry EmailToken.where(email: "firstname.lastname@example.org").destroy_all