def check_channel_member(e: TextMessageEventObject): ret = [] user_oids = ProfileManager.get_channel_member_oids(e.channel_oid, available_only=True) user_name_dict = IdentitySearcher.get_batch_user_name(user_oids, e.channel_model, on_not_found="(N/A)") for user_oid, user_name in sorted(user_name_dict.items(), key=lambda x: x[1]): ret.append(f"<li>`{user_oid}` - {user_name}</li>") ret = '\n'.join(ret) return [ HandledMessageEventText(content=f"<ul>{ret}</ul>", force_extra=True) ]
def get(self, request, *args, **kwargs): root_oid = get_root_oid(request) channel_data = self.get_channel_data(*args, **kwargs) channel_oid = channel_data.model.id attach_member = ProfileManager.can_control_profile_member( ProfileManager.get_user_permissions(channel_oid, root_oid)) member_list = {} if attach_member: member_list = IdentitySearcher.get_batch_user_name( ProfileManager.get_channel_member_oids(channel_oid, available_only=True), channel_data.model) member_list = sorted(member_list.items(), key=lambda item: item[1]) return render_template( self.request, _("Attach Profile"), "account/channel/prof/attach.html", { "channel_oid": channel_oid, "attachable_profiles": ProfileManager.get_attachable_profiles(channel_data.model.get_oid(), root_oid), "member_list": member_list }, nav_param=kwargs)
def get_user_channel_message_count_interval( channel_data: ChannelModel, *, hours_within: Optional[int] = None, start: Optional[datetime] = None, end: Optional[datetime] = None, period_count: Optional[int] = None, tz: Optional[tzinfo] = None, available_only: bool = True) -> UserMessageCountIntervalResult: data = MessageRecordStatisticsManager.get_user_messages_total_count( channel_data.id, hours_within=hours_within, start=start, end=end, period_count=period_count, tzinfo_=tz) uname_dict = IdentitySearcher.get_batch_user_name( ProfileManager.get_channel_member_oids( channel_data.id, available_only=available_only), channel_data) return UserMessageCountIntervalResult(original_result=data, uname_dict=uname_dict, available_only=available_only)