MCPcopy
hub / github.com/learnhouse/learnhouse / send_role_changed_email

Function send_role_changed_email

apps/api/src/services/users/emails.py:243–282  ·  view source on GitHub ↗

Send an email notifying a user that their role has changed in an organization.

(
    email: EmailStr,
    username: str,
    org_name: str,
    new_role_name: str,
    lang: str = "en",
)

Source from the content-addressed store, hash-verified

241
242
243def send_role_changed_email(
244 email: EmailStr,
245 username: str,
246 org_name: str,
247 new_role_name: str,
248 lang: str = "en",
249):
250 """
251 Send an email notifying a user that their role has changed in an organization.
252 """
253 safe_username = html.escape(username)
254 safe_org_name = html.escape(org_name)
255 safe_role_name = html.escape(new_role_name)
256
257 heading = t(lang, "role_changed.heading")
258 body_1 = t(
259 lang, "role_changed.body_1",
260 username=safe_username, org_name=safe_org_name, role=safe_role_name,
261 )
262 body_2 = t(lang, "role_changed.body_2")
263
264 body_content = f"""
265 <h1 style="{STYLES['h1']}">{heading}</h1>
266 <p style="{STYLES['p']}">
267 {body_1}
268 </p>
269 <p style="{STYLES['p']}">
270 {body_2}
271 </p>
272 """
273
274 return send_email(
275 to=email,
276 subject=t(lang, "role_changed.subject", org_name=safe_org_name),
277 body=_email_layout(
278 title=heading,
279 body_content=body_content,
280 footer_note=t(lang, "role_changed.footer", org_name=safe_org_name),
281 ),
282 )
283
284
285def send_email_verification_email(

Calls 3

tFunction · 0.90
send_emailFunction · 0.90
_email_layoutFunction · 0.85