Expérience utilisateur pour les utilisateurs importés ?

Je souhaite importer environ 600 adresses e-mail d’une liste de diffusion dans Discourse, dans le but de configurer automatiquement tout le monde pour qu’il suive la catégorie « Annonces », qui servira essentiellement à reproduire la fonction principale de la liste de diffusion.

J’ai compris que dans le cadre du processus d’importation, nous (je sais qu’il existe des scripts et que mon développeur devra s’en charger) pouvons obliger toutes les personnes importées à suivre la catégorie « Annonces », de sorte qu’elles recevront systématiquement un e-mail pour chaque publication (sauf si elles cessent manuellement de la suivre). Est-ce exact ?

Ce qui est moins clair pour moi, c’est l’expérience utilisateur pour les utilisateurs importés. Chacun aura un compte, mais je suppose qu’ils ne pourront pas se connecter tant qu’ils n’auront pas défini un mot de passe. Lors de leur première visite sur le site, Discourse leur demandera de le faire. C’est correct ?

Et que se passe-t-il s’ils ne définissent jamais de mot de passe ? (La plupart ne réalisent pas qu’ils ont maintenant des comptes Mailman ; il y a donc eu des réticences à devoir créer un autre compte. Soupir.) Si une personne ne visite jamais le site et ne se connecte jamais, recevra-t-elle toujours des e-mails pour les sujets et les publications de la catégorie « Annonces » ?

Pour ceux qui ont déjà réalisé une telle opération, quels types de problèmes de support avez-vous dû gérer après l’importation ?

Merci !

1 « J'aime »

If you already have a transactional relationship with these folks, i.e., you’re moving them to a new platform, there are ways to shortcut the user creation process. It’s for more advanced admins, but here are some command line (rails console) ideas that could work:

u = User.new({username: 'testuser', email: 'testuser@example.com', name: 'Test User', trust_level: 2, password: SecureRandom.hex});
u.activate();
t = u.email_tokens.create(email: u.email);
Jobs.enqueue(:critical_user_email, type: :account_created, user_id: u.id, email_token: t.token);

From my experience, this will create the new user with the details you provide, activate their account so they can receive email, and then send them an email letting them know that an account has been created for them on your Discourse site, and gives them a link to set up their account:

A new account was created for you at Your Discourse Site Name

Click the following link to choose a password for your new account:
https://discourse.example.org/u/password-reset/(randomdigits)

You would need to set up your Announcements category so that all new users are automatically Watching it, which is a site setting.

3 « J'aime »

Thanks! That seems relatively straightforward (and yes, these are all users on a list I manage and that I’m trying to move off Mailman).

Do you know what will happen if they never set up their account, in terms of them receiving email to the auto-Watching Announcements category?

There are smarter people around here than me on this topic, but I think that because you run the u.activate(); command, they’re already fully activated and the only thing they’re doing through the email is changing their password from the initial random string that nobody knows.

There is a notion that inactive users eventually stop getting emails, but I’m not sure if that would come into play here for “auto-watched” categories, I have only really thought of it in terms of the digest/summary recipients. Hopefully someone else can chime on that answer.

4 « J'aime »

Another quick question on imports. Do you know what will happen if you try to import an email address that’s already assigned to a user in the system? Will it just be skipped?

:man_shrugging:

I’d just give it a test with a throw-away address to find out.

I was afraid you’d say that. The Rails console approach proved vastly beyond my admin capabilities (Rails wasn’t even installed on our VPS, and I couldn’t see how I’d import 600 addresses that way anyway), so I’m having to bring in our developer. I’ll ask him to check.

You can get to the rails console on your self hosted Discourse site like this:

ssh ....
cd /var/discourse
./launcher enter app
rails c
2 « J'aime »

Thanks! I had to add sudu su before the third line to get permission to connect to the docker daemon, but then it worked and I was able to execute the lines in the Rails script above and create a test user. Yay!

How would this script expand to work with a list of 600 email addresses though? Running it 600 times seems… tedious. :slight_smile:

1 « J'aime »

You’d generate a script that either had that line for the 600 users or stick the data into some data structure and loop through it.

3 « J'aime »

Since no one here had any Ruby experience, we opted for creating a large file of all the commands and pasting them into the Rails console. Seems to work except that there are now four errors in Sidekiq (out of the first 50 test imports), and I don’t know what to do with them or what they mean. Were the users created? Did they just not receive the welcome email? Since retries are failing, should I just delete these errors and move on?

That would be a good thing for you to find out.

It’s hard for me to imagine how the user_id would be invalid.

Probably so, but you’ll want to figure out which users failed and why. Were there errors when you pasted the commands? If you can’t find that out, you’ll need to look at the users that exist and the ones that you expect to exist and see what the difference is.

If you don’t have easy means to scroll back through the stuff, you should work in smaller batches so that you can check on their progress more easily.

3 « J'aime »

I wasn’t alerted about this until quite a bit later, so there was no way to go back. It’s possible these errors are happening when an imported email address already exists in the system—I can test that. All the users I expected to have created were created.

But what I can’t figure out is if there’s any connection between the information in this screenshot and anything I could look up in Discourse. Are email_tokens something that can be linked back to any other information?

Sounds like I’ll just keep doing this in small batches and see if I can attach an error to one of these messages.

1 « J'aime »

Turns out these errors were generated every time there was an error in the import, things like usernames over 20 character, or two special characters in a row in a username, or possibly the email already being in use (I saw inconsistent results with that one). I just fixed each problem and moved on, and deleted all the errors from Sidekiq at the end.

2 « J'aime »