Skip to content

Commit 74bcb11

Browse files
plugyawnneiljp
andcommitted
model: Set status of bots to be a static "bot" value.
This will be picked up using earlier commits, to show it differently in the UI. With a different status, bots are now explicitly placed at the end of the user list. Tests updated. Original logic by Progyan, simplified using logic suggested in review by neiljp in #1187. Co-authored-by: neiljp (Neil Pilgrim) <[email protected]>
1 parent 09fe2b7 commit 74bcb11

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

tests/conftest.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,25 +1021,25 @@ def user_dict(logged_on_user: Dict[str, Any]) -> Dict[str, Dict[str, Any]]:
10211021
10221022
"email": "[email protected]",
10231023
"full_name": "Email Gateway",
1024-
"status": "inactive",
1024+
"status": "bot",
10251025
"user_id": 6,
10261026
},
10271027
10281028
"email": "[email protected]",
10291029
"full_name": "Zulip Feedback Bot",
1030-
"status": "inactive",
1030+
"status": "bot",
10311031
"user_id": 1,
10321032
},
10331033
10341034
"email": "[email protected]",
10351035
"full_name": "Notification Bot",
1036-
"status": "inactive",
1036+
"status": "bot",
10371037
"user_id": 5,
10381038
},
10391039
10401040
"email": "[email protected]",
10411041
"full_name": "Welcome Bot",
1042-
"status": "inactive",
1042+
"status": "bot",
10431043
"user_id": 4,
10441044
},
10451045
}
@@ -1075,12 +1075,6 @@ def user_list(logged_on_user: Dict[str, Any]) -> List[Dict[str, Any]]:
10751075
"status": "active",
10761076
"user_id": logged_on_user["user_id"],
10771077
},
1078-
{
1079-
"email": "[email protected]",
1080-
"full_name": "Email Gateway",
1081-
"status": "inactive",
1082-
"user_id": 6,
1083-
},
10841078
{
10851079
"full_name": "Human 1",
10861080
"email": "[email protected]",
@@ -1105,22 +1099,28 @@ def user_list(logged_on_user: Dict[str, Any]) -> List[Dict[str, Any]]:
11051099
"user_id": 14,
11061100
"status": "inactive",
11071101
},
1102+
{
1103+
"email": "[email protected]",
1104+
"full_name": "Email Gateway",
1105+
"status": "bot",
1106+
"user_id": 6,
1107+
},
11081108
{
11091109
"email": "[email protected]",
11101110
"full_name": "Notification Bot",
1111-
"status": "inactive",
1111+
"status": "bot",
11121112
"user_id": 5,
11131113
},
11141114
{
11151115
"email": "[email protected]",
11161116
"full_name": "Welcome Bot",
1117-
"status": "inactive",
1117+
"status": "bot",
11181118
"user_id": 4,
11191119
},
11201120
{
11211121
"email": "[email protected]",
11221122
"full_name": "Zulip Feedback Bot",
1123-
"status": "inactive",
1123+
"status": "bot",
11241124
"user_id": 1,
11251125
},
11261126
]

zulipterminal/model.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,10 @@ def get_all_users(self) -> List[Dict[str, Any]]:
10351035
}
10361036
continue
10371037
email = user["email"]
1038-
if email in presences: # presences currently subset of all users
1038+
if user["is_bot"]:
1039+
# Bot has no dynamic status, so avoid presence lookup
1040+
status = "bot"
1041+
elif email in presences: # presences currently subset of all users
10391042
"""
10401043
* Aggregate our information on a user's presence across their
10411044
* clients.
@@ -1086,6 +1089,7 @@ def get_all_users(self) -> List[Dict[str, Any]]:
10861089
"user_id": user["user_id"],
10871090
"status": status,
10881091
}
1092+
10891093
self._all_users_by_id[user["user_id"]] = user
10901094
self.user_id_email_dict[user["user_id"]] = email
10911095

@@ -1096,7 +1100,7 @@ def get_all_users(self) -> List[Dict[str, Any]]:
10961100
"full_name": bot["full_name"],
10971101
"email": email,
10981102
"user_id": bot["user_id"],
1099-
"status": "inactive",
1103+
"status": "bot",
11001104
}
11011105
self._cross_realm_bots_by_id[bot["user_id"]] = bot
11021106
self._all_users_by_id[bot["user_id"]] = bot

0 commit comments

Comments
 (0)