Coverage for src/couchers/constants.py: 100%

44 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-12-06 23:17 +0000

1from datetime import datetime, timedelta 

2 

3import pytz 

4 

5# terms of service version 

6TOS_VERSION = 2 

7 

8# community guidelines version 

9GUIDELINES_VERSION = 1 

10 

11EMAIL_REGEX = r"^[0-9a-z][0-9a-z\-\_\+\.]*@([0-9a-z\-]+\.)*[0-9a-z\-]+\.[a-z]{2,}$" 

12 

13BANNED_USERNAME_PHRASES = [ 

14 "admin", 

15 "couchers", 

16 "help", 

17 "moderation", 

18 "moderator", 

19 "noreply", 

20 "official", 

21 "security", 

22 "staff", 

23 "support", 

24 "system", 

25 "team", 

26] 

27 

28# expiry time for a verified phone number 

29PHONE_VERIFICATION_LIFETIME = timedelta(days=2 * 365) 

30 

31# shortest period between phone verification code requests 

32PHONE_REVERIFICATION_INTERVAL = timedelta(days=2) 

33 

34# expiry time for an sms code 

35SMS_CODE_LIFETIME = timedelta(hours=24) 

36 

37# max attempts to enter the sms code 

38SMS_CODE_ATTEMPTS = 3 

39 

40# Postal verification constants 

41POSTAL_VERIFICATION_CODE_LENGTH = 6 

42# Reduced alphabet to avoid confusion (no I, O, 0, 1) 

43POSTAL_VERIFICATION_CODE_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789" 

44# Code valid for 90 days after postcard sent 

45POSTAL_VERIFICATION_CODE_LIFETIME = timedelta(days=90) 

46# Max wrong code attempts before lockout 

47POSTAL_VERIFICATION_MAX_ATTEMPTS = 5 

48# Can only initiate once per 30 days 

49POSTAL_VERIFICATION_RATE_LIMIT = timedelta(days=30) 

50 

51SIGNUP_EMAIL_TOKEN_VALIDITY = timedelta(hours=48) 

52 

53DATETIME_MINUS_INFINITY = pytz.UTC.localize(datetime(1, 1, 1)) 

54DATETIME_INFINITY = pytz.UTC.localize(datetime(9876, 12, 31, hour=23, minute=59, second=59)) 

55 

56SERVER_THREADS = 128 

57 

58WORKER_THREADS = 1 

59 

60# how long the user has to undelete their account 

61UNDELETE_DAYS = 7 

62 

63# expiry time for preferred language cookie 

64PREFERRED_LANGUAGE_COOKIE_EXPIRY = timedelta(days=3650) 

65 

66# activeness probe settings 

67# wait about 11 months before sending one out 

68ACTIVENESS_PROBE_INACTIVITY_PERIOD = timedelta(days=333) 

69# times at which to send notifications after inactivity (cumulative since start of probe) 

70ACTIVENESS_PROBE_TIME_REMINDERS = [timedelta(days=0), timedelta(days=2, hours=8)] 

71# total time from initiation after which to expire the probe 

72ACTIVENESS_PROBE_EXPIRY_TIME = timedelta(days=4) 

73 

74HOST_REQUEST_MAX_REMINDERS = 1 

75HOST_REQUEST_REMINDER_INTERVAL = timedelta(days=2) 

76 

77# Note: Javascript's string.length is in utf16 code units, Python's len(str) is in utf8 code units. 

78HOST_REQUEST_MIN_LENGTH_UTF16 = 250 # Must match frontend 

79 

80ANTIBOT_FREQ = timedelta(hours=48) 

81 

82EVENT_REMINDER_TIMEDELTA = timedelta(hours=24) 

83 

84COMMUNITIES_SEARCH_FUZZY_SIMILARITY_THRESHOLD = 0.35 

85 

86UNKNOWN_ERROR_MESSAGE = "An unknown backend error occurred. Please consider filing a bug!" 

87 

88# NOTE: these codes are on purpose not translatable 

89NONEXISTENT_API_CALL_ERROR_MESSAGE = "API call does not exist. Please refresh and try again." 

90MISSING_AUTH_LEVEL_ERROR_MESSAGE = "Internal authentication error." 

91COOKIES_AND_AUTH_HEADER_ERROR_MESSAGE = 'Both "cookie" and "authorization" in request' 

92CALL_CANCELLED_ERROR_MESSAGE = "Call cancelled." 

93 

94# NOTE: the frontend uses these (and error codes) to distinguish between jailed and logged out 

95UNAUTHORIZED_ERROR_MESSAGE = "Unauthorized" 

96PERMISSION_DENIED_ERROR_MESSAGE = "Permission denied" 

97 

98GHOST_USERNAME = "ghost" 

99 

100# Donation drive start date - set to None to disable donation drive banner 

101# When set, users who haven't donated since this date will see a donation banner 

102DONATION_DRIVE_START = pytz.UTC.localize(datetime(2025, 11, 1)) 

103 

104DONATION_GOAL_USD = 5000 

105# exclude big donations from Aapeli + Itsi that we're hoping to do without :) 

106DONATION_OFFSET_USD = 2000 

107 

108# Photo gallery limits 

109GALLERY_MAX_PHOTOS_NOT_VERIFIED = 1 

110GALLERY_MAX_PHOTOS_VERIFIED = 4