← All ivy-nodes
IVYXSTUDIO · IVY NODE
H
Has mail
ivy.node.has-mail · v0.1.0
ivyx✓
Says whether a statement came with an e-mail to mark: true when both the mail's uid and the mailbox login are known, false for a file dropped into a folder or posted by a webhook. Lets one agent serve every source without a mark step that fails for want of a mailbox.
#mail#routing
Inputs
| Field | Type | Description |
|---|---|---|
| uid | string | The e-mail's id in the mailbox, when there was one. |
| username | string | The mailbox login, when there was one. |
Outputs
| Field | Type | Description |
|---|---|---|
| has_mailrequired | boolean | True when there is an e-mail to mark. |
Source
python
# Input preparation
inp = __ivy_ctx__["nodes"][__ivy_node_id__]["input"]
# Compute
class HasMail:
"Has mail"
def run(self, inp):
out = {}
# Whether a statement came with an e-mail to mark: a uid and a mailbox login.
uid = str(inp.get("uid") or "").strip()
username = str(inp.get("username") or "").strip()
out = {"has_mail": bool(uid) and bool(username)}
return out
result = HasMail().run(inp)
# Output collection (the runner reads it here)
out = __ivy_ctx__["nodes"][__ivy_node_id__]["output"]
out.update(result)Tests
Requires: python:3.9
- mail
A uid and a login mean there is an e-mail to mark.
- none
Nothing known means nothing to mark.
- blank-uid
A uid of spaces is no uid, so a dropped file with a login still has nothing to mark.