How to manually send invitation link when it is not sent automatically

Before embarking on any of this, MAKE SURE THE COURSE IS ACTUALLY "PUBLISHED" - strange things happen without any error messages when the course is not yet published 😏
----------------------------------------------------------------------------------------------------------------------------------------------
Canvas send invitation link breaks occasionally.  To force it manually, take the following steps:

1. log on to canvas: (use id_ed25519 key)|

mike@alderaanIII:/mnt/c/Users/micro$ ssh canvas 

2. open the rails console:

duxtel@canvas:/var/canvas$ sudo RAILS_ENV=production bundle exec rails console

3. force the user to 'active' status (substitute added users email address accordingly)

cc = CommunicationChannel.find_by(path: 'meverest@duxtel.com.au')
user = cc.user
course.enroll_user(user, 'StudentEnrollment', enrollment_state: 'active')

4. log on to canvas.duxtel.com interface, go to people, click on options (three vertical dots) for each user and click 'resend invitation'

OR BY API:

# 1. Get User ID from email
curl -H "Authorization: Bearer Ckj19U7NZYayPQB7OurpiYUl1NQKHnS06LIVvEteOYbVEOUcYgILbCc8EsDabbsz" \

# 2. Enroll user by ID
 -H "Authorization: Bearer Ckj19U7NZYayPQB7OurpiYUl1NQKHnS06LIVvEteOYbVEOUcYgILbCc8EsDabbsz" \
 -F "enrollment[user_id]=151" \
 -F "enrollment[type]=StudentEnrollment" \
 -F "enrollment[enrollment_state]=active"