Passed
Push — main ( 2c1a84...8b4e52 )
by Jochen
04:45
created

announce_user_details_updated()   A

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 2
dl 0
loc 7
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
"""
2
byceps.announce.handlers.user
3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4
5
Announce user events.
6
7
:Copyright: 2006-2021 Jochen Kupperschmidt
8
:License: Revised BSD (see `LICENSE` file for details)
9
"""
10
11 1
from ...events.user import (
12
    UserAccountCreated,
13
    UserAccountDeleted,
14
    UserAccountSuspended,
15
    UserAccountUnsuspended,
16
    UserDetailsUpdated,
17
    UserEmailAddressChanged,
18
    UserEmailAddressInvalidated,
19
    UserScreenNameChanged,
20
)
21 1
from ...services.webhooks.transfer.models import OutgoingWebhook
22
23 1
from ..helpers import call_webhook
24 1
from ..text_assembly import user
25
26
27 1
def announce_user_account_created(
28
    event: UserAccountCreated, webhook: OutgoingWebhook
29
) -> None:
30
    """Announce that a user account has been created."""
31 1
    text = user.assemble_text_for_user_account_created(event)
32
33 1
    call_webhook(webhook, text)
34
35
36 1
def announce_user_screen_name_changed(
37
    event: UserScreenNameChanged, webhook: OutgoingWebhook
38
) -> None:
39
    """Announce that a user's screen name has been changed."""
40 1
    text = user.assemble_text_for_user_screen_name_changed(event)
41
42 1
    call_webhook(webhook, text)
43
44
45 1
def announce_user_email_address_changed(
46
    event: UserEmailAddressChanged, webhook: OutgoingWebhook
47
) -> None:
48
    """Announce that a user's email address has been changed."""
49 1
    text = user.assemble_text_for_user_email_address_changed(event)
50
51 1
    call_webhook(webhook, text)
52
53
54 1
def announce_user_email_address_invalidated(
55
    event: UserEmailAddressInvalidated, webhook: OutgoingWebhook
56
) -> None:
57
    """Announce that a user's email address has been invalidated."""
58 1
    text = user.assemble_text_for_user_email_address_invalidated(event)
59
60 1
    call_webhook(webhook, text)
61
62
63 1
def announce_user_details_updated(
64
    event: UserDetailsUpdated, webhook: OutgoingWebhook
65
) -> None:
66
    """Announce that a user's details have been changed."""
67 1
    text = user.assemble_text_for_user_details_updated(event)
68
69 1
    call_webhook(webhook, text)
70
71
72 1
def announce_user_account_suspended(
73
    event: UserAccountSuspended, webhook: OutgoingWebhook
74
) -> None:
75
    """Announce that a user account has been suspended."""
76 1
    text = user.assemble_text_for_user_account_suspended(event)
77
78 1
    call_webhook(webhook, text)
79
80
81 1
def announce_user_account_unsuspended(
82
    event: UserAccountUnsuspended, webhook: OutgoingWebhook
83
) -> None:
84
    """Announce that a user account has been unsuspended."""
85 1
    text = user.assemble_text_for_user_account_unsuspended(event)
86
87 1
    call_webhook(webhook, text)
88
89
90 1
def announce_user_account_deleted(
91
    event: UserAccountDeleted, webhook: OutgoingWebhook
92
) -> None:
93
    """Announce that a user account has been deleted."""
94 1
    text = user.assemble_text_for_user_account_deleted(event)
95
96
    call_webhook(webhook, text)
97