Skip to content

Commit a06c753

Browse files
committed
feat: add mail inbox tools
Signed-off-by: Jana Peper <jana.peper@nextcloud.com>
1 parent 153a2fb commit a06c753

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

ex_app/lib/all_tools/mail.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,39 @@ def send_email(subject: str, body: str, account_id: int, from_email: str, to_ema
4949
def get_mail_account_list():
5050
"""
5151
Lists all available email accounts including their account id
52-
:param subject: The subject of the email
53-
:param body: The body of the email
54-
:param account_id: The id of the account to send from
55-
:param to_emails: The emails to send
5652
"""
5753

5854
return nc.ocs('GET', '/ocs/v2.php/apps/mail/account/list')
55+
56+
57+
@tool
58+
@safe_tool
59+
def get_mail_folder_list(account_id: int):
60+
"""
61+
Lists all mail folders account. You need to get the correct account id matching the request first before using this tool.
62+
:param account_id: The id of the account to list as integer, obtainable via get_mail_account_list
63+
"""
64+
65+
return nc.ocs('GET', '/ocs/v2.php/apps/mail/mailbox/list', json={'accountId': account_id})
66+
67+
68+
@tool
69+
@safe_tool
70+
def list_mails(folder_id: int, n_mails: int = 30):
71+
"""
72+
Lists all messages in a mailbox folder. You need to get the correct folder id matching the request first before using this tool.
73+
:param folder_id: The id of the folder to list as integer, obtainable via folder
74+
:param n_mails: The number of mails to receive. Optional, default is 10
75+
:return: a list of mails/messages, including timestamps
76+
"""
77+
return nc.ocs('GET', '/ocs/v2.php/apps/mail/mailbox/messages/list', json={'mailboxId': folder_id, 'limit': n_mails})
5978

6079

6180
return [
6281
send_email,
63-
get_mail_account_list
82+
get_mail_account_list,
83+
get_mail_folder_list,
84+
list_mails,
6485
]
6586

6687
def get_category_name():

0 commit comments

Comments
 (0)