Skip to content

Commit d8457f6

Browse files
authored
Merge pull request #10 from nextcloud/feat/rework-mail
Feat: mail account id search
2 parents 91ac37c + b6ee82b commit d8457f6

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

ex_app/lib/all_tools/mail.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from nc_py_api import Nextcloud
66
from nc_py_api.ex_app import LogLvl
77

8-
from ex_app.lib.all_tools.lib.decorator import dangerous_tool
8+
from ex_app.lib.all_tools.lib.decorator import safe_tool, dangerous_tool
99
from ex_app.lib.logger import log
1010

1111

@@ -17,7 +17,7 @@ def send_email(subject: str, body: str, account_id: int, from_email: str, to_ema
1717
Send an email to a list of emails
1818
:param subject: The subject of the email
1919
:param body: The body of the email
20-
:param account_id: The id of the account to send from
20+
:param account_id: The id of the account to send from, obtainable via get_mail_account_list
2121
:param to_emails: The emails to send
2222
"""
2323
i = 0
@@ -42,6 +42,21 @@ def send_email(subject: str, body: str, account_id: int, from_email: str, to_ema
4242
sleep(1)
4343
continue
4444

45+
@tool
46+
@safe_tool
47+
def get_mail_account_list():
48+
"""
49+
Lists all available email accounts including their account id
50+
:param subject: The subject of the email
51+
:param body: The body of the email
52+
:param account_id: The id of the account to send from
53+
:param to_emails: The emails to send
54+
"""
55+
56+
return nc.ocs('GET', '/ocs/v2.php/apps/mail/account/list')
57+
58+
4559
return [
4660
send_email,
61+
get_mail_account_list
4762
]

0 commit comments

Comments
 (0)