@@ -81,8 +81,8 @@ def write_notification_digest(
8181 )
8282 total_notification_count = len (posts )
8383 # Construct the message
84- subject = lexicon [ "subject" ]. format (
85- post_count = total_notification_count
84+ subject = pluralise (
85+ lexicon [ "subject" ]. format ( post_count = total_notification_count )
8686 )
8787 frequency = {
8888 "hourly" : lexicon ["frequency_hourly" ],
@@ -118,8 +118,64 @@ def write_notification_digest(
118118 wikis = "\n " .join (write_wikis_digest (posts , lexicon )),
119119 outro = outro ,
120120 )
121- subject = pluralise (subject )
122- body = finalise_digest (body )
121+ body = postprocess_message (body )
122+ body = convert_syntax (body , user ["delivery" ])
123+ return subject , body
124+
125+ def write_signup_confirmation (
126+ self ,
127+ user : CachedUserConfig ,
128+ ) -> Tuple [str , str ]:
129+ """Writes a signup confirmation message."""
130+ lexicon = self .build_lexicon (user ["language" ])
131+ frequency = {
132+ "hourly" : lexicon ["frequency_hourly" ],
133+ "8hourly" : lexicon ["frequency_8hourly" ],
134+ "daily" : lexicon ["frequency_daily" ],
135+ "weekly" : lexicon ["frequency_weekly" ],
136+ "monthly" : lexicon ["frequency_monthly" ],
137+ "test" : lexicon ["frequency_test" ],
138+ }.get (user ["frequency" ], "undefined" )
139+
140+ subject = lexicon ["signup_confirmation_subject" ]
141+
142+ body = lexicon ["signup_confirmation_body" ].format (
143+ link_site = lexicon ["link_site" ],
144+ link_your_config = lexicon ["link_your_config" ].format (
145+ link_site = lexicon ["link_site" ]
146+ ),
147+ frequency = frequency ,
148+ )
149+ body = postprocess_message (body )
150+ body = convert_syntax (body , user ["delivery" ])
151+ return subject , body
152+
153+ def write_methodchange_confirmation (
154+ self ,
155+ user : CachedUserConfig ,
156+ ) -> Tuple [str , str ]:
157+ """Writes a delivery method change confirmation message."""
158+ lexicon = self .build_lexicon (user ["language" ])
159+
160+ subject = lexicon ["methodchange_confirmation_subject" ]
161+
162+ body = lexicon ["methodchange_confirmation_message" ].format (
163+ link_site = lexicon ["link_site" ],
164+ link_your_config = lexicon ["link_your_config" ].format (
165+ link_site = lexicon ["link_site" ]
166+ ),
167+ old_method = (
168+ lexicon ["method_pm" ]
169+ if user ["delivery" ] == "pm"
170+ else lexicon ["method_email" ]
171+ ),
172+ new_method = (
173+ lexicon ["method_pm" ]
174+ if user ["delivery" ] == "email"
175+ else lexicon ["method_email" ]
176+ ),
177+ )
178+ body = postprocess_message (body )
123179 body = convert_syntax (body , user ["delivery" ])
124180 return subject , body
125181
@@ -345,8 +401,8 @@ def make_plural(match: Match[str]) -> str:
345401 return multiple
346402
347403
348- def finalise_digest (digest : str ) -> str :
349- """Performs final postprocessing on a digest ."""
404+ def postprocess_message (digest : str ) -> str :
405+ """Performs final postprocessing on a message ."""
350406 return emojize (pluralise (digest ), variant = "emoji_type" )
351407
352408
0 commit comments