Use an enum for user email notification types

Created on 8 October 2015, about 9 years ago
Updated 13 September 2024, about 1 month ago

Problem/Motivation

The _user_mail_notify() function is responsible for sending out notification emails to users.
It has these types of emails:

  • register_admin_created: Welcome message for user created by the admin.
  • register_no_approval_required: Welcome message when user self-registers.
  • register_pending_approval: Welcome message, user pending admin approval.
  • password_reset: Password recovery request.
  • status_activated: Account activated.
  • status_blocked: Account blocked.
  • cancel_confirm: Account cancellation request.
  • status_canceled: Account canceled.

They are simple strings and so any change to them can break some contrib codes. Therefore these should be enum. If nothing will change (ie. no code breaks in the future) they should nonetheless become constants.

Proposed resolution

They currently exist as strings, in order to allow adding/modifying/deleting these values, and make code more referential (IDE completion, static analysis), the possible values should be converted to an enum. This also prevents using this internal (underscore prefixed) function for values it is not intended to handle.

Remaining tasks

Create an enum, doesnt need to be string backed as values are only used in-memory.
Convert string usages to enum.
Add backwards compatible string/enum parameter just like FileSystem.

User interface changes

Nil

Introduced terminology

Nil

API changes

Existing usages converted
Deprecation

Data model changes

Nil

Release notes snippet

@todo, A release note snippet and changelog should be created

Feature request
Status

Needs work

Version

11.0 🔥

Component
User system 

Last updated 1 day ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024