mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	user_topic: Add user_topic event.
We now send a new user_topic event while muting and unmuting topics. fetch_initial_state_data now returns an additional user_topics array to the client that will maintain the user-topic relationship data. This will support any future addition of new features to modify the relationship between a user-topic pair. This commit adds the relevent backend code and schema for the new event.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							8b674ee3d7
						
					
				
				
					commit
					1291e7000b
				
			@@ -15,12 +15,15 @@ from zerver.models import UserProfile, UserTopic, get_stream
 | 
			
		||||
def get_user_topics(
 | 
			
		||||
    user_profile: UserProfile,
 | 
			
		||||
    include_deactivated: bool = False,
 | 
			
		||||
    include_stream_name: bool = False,
 | 
			
		||||
    visibility_policy: Optional[int] = None,
 | 
			
		||||
) -> List[UserTopicDict]:
 | 
			
		||||
    """
 | 
			
		||||
    Fetches UserTopic objects associated with the target user.
 | 
			
		||||
    * include_deactivated: Whether to include those associated with
 | 
			
		||||
      deactivated streams.
 | 
			
		||||
    * include_stream_name: Whether to include stream names in the
 | 
			
		||||
      returned dictionaries.
 | 
			
		||||
    * visibility_policy: If specified, returns only UserTopic objects
 | 
			
		||||
      with the specified visibility_policy value.
 | 
			
		||||
    """
 | 
			
		||||
@@ -40,6 +43,9 @@ def get_user_topics(
 | 
			
		||||
 | 
			
		||||
    result = []
 | 
			
		||||
    for row in rows:
 | 
			
		||||
        if not include_stream_name:
 | 
			
		||||
            del row["stream__name"]
 | 
			
		||||
 | 
			
		||||
        row["last_updated"] = datetime_to_timestamp(row["last_updated"])
 | 
			
		||||
        result.append(row)
 | 
			
		||||
 | 
			
		||||
@@ -53,6 +59,7 @@ def get_topic_mutes(
 | 
			
		||||
    user_topics = get_user_topics(
 | 
			
		||||
        user_profile=user_profile,
 | 
			
		||||
        include_deactivated=include_deactivated,
 | 
			
		||||
        include_stream_name=True,
 | 
			
		||||
        visibility_policy=UserTopic.MUTED,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user