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

83 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-07-21 21:52 +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 dashboard_link() -> str: 

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

20 

21 

22def profile_link() -> str: 

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

24 

25 

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

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

28 

29 

30def edit_profile_link() -> str: 

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

32 

33 

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

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

36 

37 

38def account_settings_link() -> str: 

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

40 

41 

42def notification_settings_link() -> str: 

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

44 

45 

46def feature_preview_link() -> str: 

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

48 

49 

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

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

52 

53 

54def host_request_link_host() -> str: 

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

56 

57 

58def host_request_link_guest() -> str: 

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

60 

61 

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

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

64 

65 

66def messages_link() -> str: 

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

68 

69 

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

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

72 

73 

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

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

76 

77 

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

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

80 

81 

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

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

84 

85 

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

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

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

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

90 else: 

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

92 

93 

94def profile_references_link() -> str: 

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

96 

97 

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

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

100 if from_user_id is not None: 

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

102 return url 

103 

104 

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

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

107 

108 

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

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

111 

112 

113def donation_url() -> str: 

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

115 

116 

117def donation_cancelled_url() -> str: 

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

119 

120 

121def donation_success_url() -> str: 

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

123 

124 

125def strong_verification_url() -> str: 

126 return f"{config.BASE_URL}/strong-verification" 

127 

128 

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

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

131 

132 

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

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

135 

136 

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

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

139 

140 

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

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

143 

144 

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

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

147 

148 

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

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

151 

152 

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

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

155 

156 

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

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

159 

160 

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

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

163 

164 

165def terms_of_service_url() -> str: 

166 return f"{config.BASE_URL}/terms"