MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / list_emails

Method list_emails

src/services/temp_mail.py:848–900  ·  view source on GitHub ↗

列出邮箱 Args: limit: 返回数量上限 offset: 分页偏移 **kwargs: 额外查询参数,透传给 admin API Returns: 邮箱列表

(self, limit: int = 50, offset: int = 0, **kwargs)

Source from the content-addressed store, hash-verified

846 return None
847
848 def list_emails(self, limit: int = 50, offset: int = 0, **kwargs) -> List[Dict[str, Any]]:
849 """
850 列出邮箱
851
852 Args:
853 limit: 返回数量上限
854 offset: 分页偏移
855 **kwargs: 额外查询参数,透传给 admin API
856
857 Returns:
858 邮箱列表
859 """
860 params = {k: v for k, v in kwargs.items() if v is not None}
861 raw_limit = params.pop("limit", limit)
862 raw_offset = params.pop("offset", offset)
863 params["limit"] = self._normalize_admin_limit(raw_limit, default=50)
864 params["offset"] = self._normalize_offset(raw_offset, default=0)
865
866 try:
867 response = self._request_admin_mails_with_limit_fallback(
868 offset=params["offset"],
869 extra_params={k: v for k, v in params.items() if k not in ("limit", "offset")},
870 preferred_limit=params["limit"],
871 )
872 mails = response.get("results", [])
873 if not isinstance(mails, list):
874 raise EmailServiceError(f"API 返回数据格式错误: {response}")
875
876 emails: List[Dict[str, Any]] = []
877 for mail in mails:
878 address = (mail.get("address") or "").strip()
879 mail_id = mail.get("id") or address
880 email_info = {
881 "id": mail_id,
882 "service_id": mail_id,
883 "email": address,
884 "subject": mail.get("subject"),
885 "from": mail.get("source"),
886 "created_at": mail.get("createdAt") or mail.get("created_at"),
887 "raw_data": mail,
888 }
889 emails.append(email_info)
890
891 if address:
892 cached = self._email_cache.get(address, {})
893 self._email_cache[address] = {**cached, **email_info}
894
895 self.update_status(True)
896 return emails
897 except Exception as e:
898 logger.warning(f"列出 TempMail 邮箱失败: {e}")
899 self.update_status(False, e)
900 return list(self._email_cache.values())
901
902 def delete_email(self, email_id: str) -> bool:
903 """

Callers

nothing calls this directly

Calls 7

_normalize_offsetMethod · 0.95
EmailServiceErrorClass · 0.85
warningMethod · 0.80
getMethod · 0.45
update_statusMethod · 0.45

Tested by

no test coverage detected