Coverage for functions \ flipdare \ message \ user_message.py: 95%
40 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
1#!/usr/bin/env python
2# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved.
3#
4# This file is part of Flipdare's proprietary software and contains
5# confidential and copyrighted material. Unauthorised copying,
6# modification, distribution, or use of this file is strictly
7# prohibited without prior written permission from Flipdare Pty Ltd.
8#
9# This software includes third-party components licensed under MIT,
10# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details.
11#
13from __future__ import annotations
15from enum import StrEnum
16from flipdare.generated import RestrictionCategory, StopwatchDuration
18__all__ = ["UserMessage", "NotificationMessage", "StripeWebhookMessage"]
21class UserMessage(StrEnum):
22 SUPPORT = "If the problem persists, please contact support with the error code."
24 _CHAT_BLOCK = "Comment block due to '{category_label}' and low reputation. Contact support if you have questions."
25 _RESTRICTION_APPLIED = '''A restriction of "{restriction_type.label}" until {expires_at_str} has been placed on your account.
26The flag was caused by "{flag_duration.label}", because of "{reason}."'''
28 _RESTRICTION_REMOVED = """Congrats! your restriction of '{restriction_type.label}' has been removed.
29Go extreme (within the rules)!"""
31 @classmethod
32 def chat_block(cls, category_label: str) -> str:
33 return cls._CHAT_BLOCK.format(category_label=category_label)
35 @classmethod
36 def restriction_removed(cls, restriction_type: RestrictionCategory) -> str:
37 return cls._RESTRICTION_REMOVED.format(restriction_type=restriction_type)
39 @classmethod
40 def restriction_applied(
41 cls,
42 restriction_type: RestrictionCategory,
43 flag_duration: StopwatchDuration,
44 expires_at_str: str,
45 reason: str,
46 ) -> str:
47 return cls._RESTRICTION_APPLIED.format(
48 restriction_type=restriction_type,
49 flag_duration=flag_duration,
50 expires_at_str=expires_at_str,
51 reason=reason,
52 )
54 AUTOMATED_FLAG_ACTION_REASON = (
55 "Automatic temporary System flag (will be reviewed by support team)."
56 )
57 FLAG_ACTION_REASON = "Violation of community guidelines."
59 UNSUBSCRIBE_OK = """You have been unsubscribed from flipdare emails.
60Please allow up to 48 hours for this to take effect."""
62 DELETE_OK = """Your account deletion request has been received.
63Check your email for a confirmation code to complete the process."""
65 DELETE_CONFIRM_OK = """Your account deletion has been completed.
66We're sorry to see you go!
67You will need to contact support if you wish to re-activate your account.
68 """
70 CONTACT_OK = """Your message has been sent to flipdare support.
71We will get back to you as soon as possible."""
74class NotificationMessage(StrEnum):
75 FRIEND_REQ_ACCEPTED = "{name} accepted your friend request!"
76 FRIEND_REQ_SENT = "{name} sent you a friend request!"
78 GROUP_REQ = "{name} has created a new group {group_name}."
79 GROUP_UPDATE = "The group {group_name} has been updated."
81 DARE_NEW = "You have received a new dare from {from_name}!"
82 DARE_UPDATE = "The dare from {from_name} to {to_name} has been updated.."
84 GROUP_DARE_NEW = "A new group dare has been created in {group_name}."
85 GROUP_DARE_UPDATE = "A dare in {group_name} has been updated."
88class StripeMessage(StrEnum):
89 DISPUTE_EXPRESS_INSTRUCT = """Use the link provided to access your Stripe Dashboard
90and manage the dispute directly with Stripe support."""
92 DISPUTE_STANDARD_INSTRUCT = """Use the link provided to access your Stripe Dashboard
93and manage the dispute directly with Stripe support.
94If you have trouble accessing your dashboard, please contact Stripe support for assistance."""
97class StripeWebhookMessage(StrEnum):
98 """Raw HTML templates for Stripe callbacks."""
100 # NOTE: this uses string.Template formatting.
102 RETURN_POST_TEMPLATE = """
103 <script>
104 if (window.OnboardingHandler) {
105 OnboardingHandler.postMessage('$TITLE - $MESSAGE - $CODE');
106 } else {
107 window.close();
108 }
109 </script>
110 """
112 PAY_POST_TEMPLATE = """
113 <script>
114 if (window.PaymentHandler) {
115 PaymentHandler.postMessage('$PAYMENT_INTENT_ID - $MESSAGE - $PAYMENT_METHOD_ID');
116 } else {
117 window.close();
118 }
119 </script>
120 """
122 REDIRECT_TMPL = """<script>window.location.href="$URL"</script>"""