Coverage for app/backend/src/couchers/urls.py: 91%

77 statements  

« prev     ^ index     » next       coverage.py v7.14.2, created at 2026-06-21 09:29 +0000

1# The source of truth for URLs is 

2# //docs/urls.md 

3# Please make sure this file stays in sync with that file as well as 

4# //app/web/src/routes.ts 

5 

6 

7from couchers.config import config 

8 

9 

10def app_link() -> str: 

11 return f"{config.BASE_URL}/" 

12 

13 

14def icon_url() -> str: 

15 return f"{config.BASE_URL}/logo512.png" 

16 

17 

18def profile_link() -> str: 

19 return f"{config.BASE_URL}/profile" 

20 

21 

22def user_link(*, username: str) -> str: 

23 return f"{config.BASE_URL}/user/{username}" 

24 

25 

26def edit_profile_link() -> str: 

27 return f"{config.BASE_URL}/profile/edit" 

28 

29 

30def signup_link(*, token: str) -> str: 

31 return f"{config.BASE_URL}/signup?token={token}" 

32 

33 

34def account_settings_link() -> str: 

35 return f"{config.BASE_URL}/account-settings" 

36 

37 

38def notification_settings_link() -> str: 

39 return f"{config.BASE_URL}/account-settings/notifications" 

40 

41 

42def feature_preview_link() -> str: 

43 return f"{config.BASE_URL}/preview" 

44 

45 

46def password_reset_link(*, password_reset_token: str) -> str: 

47 return f"{config.BASE_URL}/complete-password-reset?token={password_reset_token}" 

48 

49 

50def host_request_link_host() -> str: 

51 return f"{config.BASE_URL}/messages/hosting/" 

52 

53 

54def host_request_link_guest() -> str: 

55 return f"{config.BASE_URL}/messages/surfing/" 

56 

57 

58def host_request(*, host_request_id: str) -> str: 

59 return f"{config.BASE_URL}/messages/request/{host_request_id}" 

60 

61 

62def messages_link() -> str: 

63 return f"{config.BASE_URL}/messages/" 

64 

65 

66def chat_link(*, chat_id: int) -> str: 

67 return f"{config.BASE_URL}/messages/chats/{chat_id}" 

68 

69 

70def event_link(*, occurrence_id: int, slug: str = "e") -> str: 

71 return f"{config.BASE_URL}/event/{occurrence_id}/{slug}" 

72 

73 

74def community_link(*, node_id: int, slug: str = "e") -> str: 

75 return f"{config.BASE_URL}/community/{node_id}/{slug}" 

76 

77 

78def discussion_link(*, discussion_id: str, slug: str = "e") -> str: 

79 return f"{config.BASE_URL}/discussion/{discussion_id}/{slug}" 

80 

81 

82def leave_reference_link(*, reference_type: str, to_user_id: str, host_request_id: str | None = None) -> str: 

83 assert reference_type in ["friend", "surfed", "hosted"] 

84 if host_request_id: 84 ↛ 87line 84 didn't jump to line 87 because the condition on line 84 was always true

85 return f"{config.BASE_URL}/leave-reference/{reference_type}/{to_user_id}/{host_request_id}" 

86 else: 

87 return f"{config.BASE_URL}/leave-reference/{reference_type}/{to_user_id}" 

88 

89 

90def profile_references_link() -> str: 

91 return f"{config.BASE_URL}/profile/references" 

92 

93 

94def friend_requests_link(*, from_user_id: int | None = None) -> str: 

95 url = f"{config.BASE_URL}/connections/friends/" 

96 if from_user_id is not None: 

97 url += f"?from={from_user_id}" 

98 return url 

99 

100 

101def media_upload_url(*, path: str) -> str: 

102 return f"{config.MEDIA_SERVER_UPLOAD_BASE_URL}/{path}" 

103 

104 

105def change_email_link(*, confirmation_token: str) -> str: 

106 return f"{config.BASE_URL}/confirm-email?token={confirmation_token}" 

107 

108 

109def donation_url() -> str: 

110 return f"{config.BASE_URL}/donate" 

111 

112 

113def donation_cancelled_url() -> str: 

114 return f"{config.BASE_URL}/donate?cancelled=true" 

115 

116 

117def donation_success_url() -> str: 

118 return f"{config.BASE_URL}/donate?success=true" 

119 

120 

121def complete_strong_verification_url(*, verification_attempt_token: str) -> str: 

122 return f"{config.BASE_URL}/complete-strong-verification?verification_attempt_token={verification_attempt_token}" 

123 

124 

125def delete_account_link(*, account_deletion_token: str) -> str: 

126 return f"{config.BASE_URL}/delete-account?token={account_deletion_token}" 

127 

128 

129def recover_account_link(*, account_undelete_token: str) -> str: 

130 return f"{config.BASE_URL}/recover-account?token={account_undelete_token}" 

131 

132 

133def unsubscribe_link(*, payload: str, sig: str) -> str: 

134 return f"{config.BASE_URL}/quick-link?payload={payload}&sig={sig}" 

135 

136 

137def quick_link(*, payload: str, sig: str) -> str: 

138 return f"{config.BASE_URL}/quick-link?payload={payload}&sig={sig}" 

139 

140 

141def media_url(*, filename: str, size: str) -> str: 

142 return f"{config.MEDIA_SERVER_BASE_URL}/img/{size}/{filename}" 

143 

144 

145def console_link(*, page: str) -> str: 

146 return f"{config.CONSOLE_BASE_URL}/{page}" 

147 

148 

149def invite_code_link(*, code: str) -> str: 

150 return f"{config.BASE_URL}/invite?code={code}" 

151 

152 

153def postal_verification_link(*, code: str) -> str: 

154 return f"{config.BASE_URL}/verify-postal?c={code}"