mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	home: Extract updates to last_reminder to a function.
This commit is contained in:
		@@ -91,6 +91,19 @@ def detect_narrowed_window(request: HttpRequest,
 | 
				
			|||||||
            narrow.append(["topic", narrow_topic])
 | 
					            narrow.append(["topic", narrow_topic])
 | 
				
			||||||
    return narrow, narrow_stream, narrow_topic
 | 
					    return narrow, narrow_stream, narrow_topic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def update_last_reminder(user_profile: Optional[UserProfile]) -> None:
 | 
				
			||||||
 | 
					    """Reset our don't-spam-users-with-email counter since the
 | 
				
			||||||
 | 
					    user has since logged in
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    if user_profile is None:  # nocoverage
 | 
				
			||||||
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if user_profile.last_reminder is not None:  # nocoverage
 | 
				
			||||||
 | 
					        # TODO: Look into the history of last_reminder; we may have
 | 
				
			||||||
 | 
					        # eliminated that as a useful concept for non-bot users.
 | 
				
			||||||
 | 
					        user_profile.last_reminder = None
 | 
				
			||||||
 | 
					        user_profile.save(update_fields=["last_reminder"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def sent_time_in_epoch_seconds(user_message: Optional[UserMessage]) -> Optional[float]:
 | 
					def sent_time_in_epoch_seconds(user_message: Optional[UserMessage]) -> Optional[float]:
 | 
				
			||||||
    if user_message is None:
 | 
					    if user_message is None:
 | 
				
			||||||
        return None
 | 
					        return None
 | 
				
			||||||
@@ -153,14 +166,7 @@ def home_real(request: HttpRequest) -> HttpResponse:
 | 
				
			|||||||
                                      notification_settings_null=True,
 | 
					                                      notification_settings_null=True,
 | 
				
			||||||
                                      narrow=narrow)
 | 
					                                      narrow=narrow)
 | 
				
			||||||
    user_has_messages = (register_ret['max_message_id'] != -1)
 | 
					    user_has_messages = (register_ret['max_message_id'] != -1)
 | 
				
			||||||
 | 
					    update_last_reminder(user_profile)
 | 
				
			||||||
    # Reset our don't-spam-users-with-email counter since the
 | 
					 | 
				
			||||||
    # user has since logged in
 | 
					 | 
				
			||||||
    if user_profile.last_reminder is not None:  # nocoverage
 | 
					 | 
				
			||||||
        # TODO: Look into the history of last_reminder; we may have
 | 
					 | 
				
			||||||
        # eliminated that as a useful concept for non-bot users.
 | 
					 | 
				
			||||||
        user_profile.last_reminder = None
 | 
					 | 
				
			||||||
        user_profile.save(update_fields=["last_reminder"])
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Brand new users get narrowed to PM with welcome-bot
 | 
					    # Brand new users get narrowed to PM with welcome-bot
 | 
				
			||||||
    needs_tutorial = user_profile.tutorial_status == UserProfile.TUTORIAL_WAITING
 | 
					    needs_tutorial = user_profile.tutorial_status == UserProfile.TUTORIAL_WAITING
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user