calendar: remove self-notification emails (CalDAV sync replaces them)
Remove three redundant email flows since all devices sync via CalDAV: - Auto-adding mail@luyx.org as attendee on outgoing invites - Forwarding invites to mail@luyx.org on accept/tentative - Emailing todos to mail@luyx.org on todo add
This commit is contained in:
@@ -34,7 +34,6 @@ from icalendar import Alarm, Calendar, Event, Todo, vCalAddress, vText
|
||||
|
||||
DEFAULT_TIMEZONE = "America/Los_Angeles"
|
||||
DEFAULT_FROM = "youlu@luyanxin.com"
|
||||
DEFAULT_OWNER_EMAIL = "mail@luyx.org" # Always added as attendee
|
||||
CALENDAR_DIR = Path.home() / ".openclaw" / "workspace" / "calendars" / "home"
|
||||
TASKS_DIR = Path.home() / ".openclaw" / "workspace" / "calendars" / "tasks"
|
||||
PRODID = "-//OpenClaw//Calendar//EN"
|
||||
@@ -148,12 +147,7 @@ def cmd_send(args):
|
||||
|
||||
recipients = [addr.strip() for addr in args.to.split(",")]
|
||||
|
||||
# Always include owner as attendee
|
||||
all_attendees = list(recipients)
|
||||
if DEFAULT_OWNER_EMAIL not in all_attendees:
|
||||
all_attendees.append(DEFAULT_OWNER_EMAIL)
|
||||
|
||||
for addr in all_attendees:
|
||||
for addr in recipients:
|
||||
event.add("attendee", f"mailto:{addr}", parameters={
|
||||
"ROLE": "REQ-PARTICIPANT",
|
||||
"RSVP": "TRUE",
|
||||
@@ -176,11 +170,8 @@ def cmd_send(args):
|
||||
if args.description:
|
||||
body += f"\n\n{args.description}"
|
||||
|
||||
# Email goes to all attendees (including owner)
|
||||
all_to = ", ".join(all_attendees)
|
||||
|
||||
# Build MIME email
|
||||
email_str = _build_calendar_email(args.sender, all_to, args.subject, body, ics_bytes, method="REQUEST")
|
||||
email_str = _build_calendar_email(args.sender, ", ".join(recipients), args.subject, body, ics_bytes, method="REQUEST")
|
||||
|
||||
if args.dry_run:
|
||||
print("=== ICS Content ===")
|
||||
@@ -352,20 +343,6 @@ def cmd_reply(args):
|
||||
_send_email(email_str, args.account)
|
||||
print(f"Calendar invite {partstat.lower()}: {summary} (replied to {organizer_email})")
|
||||
|
||||
# Forward invite to owner on accept/tentative
|
||||
if partstat in ("ACCEPTED", "TENTATIVE"):
|
||||
fwd_body = f"{prefix}: {summary}"
|
||||
fwd_email = _build_calendar_email(
|
||||
args.sender, DEFAULT_OWNER_EMAIL,
|
||||
f"{prefix}: {summary}", fwd_body,
|
||||
ics_path.read_bytes(), method="REQUEST",
|
||||
)
|
||||
try:
|
||||
_send_email(fwd_email, args.account)
|
||||
print(f"Forwarded invite to {DEFAULT_OWNER_EMAIL}")
|
||||
except subprocess.CalledProcessError:
|
||||
print(f"Warning: Failed to forward invite to {DEFAULT_OWNER_EMAIL}")
|
||||
|
||||
# Save to / remove from local calendar
|
||||
if CALENDAR_DIR.is_dir():
|
||||
dest = CALENDAR_DIR / f"{uid}.ics"
|
||||
@@ -526,24 +503,11 @@ def cmd_todo_add(args):
|
||||
cal.add_component(todo)
|
||||
ics_bytes = cal.to_ical()
|
||||
|
||||
# Build email body
|
||||
prio_label = PRIORITY_LABELS.get(priority, "中")
|
||||
body = f"待办事项: {args.summary}\n截止日期: {due_date}\n优先级: {prio_label}"
|
||||
if args.description:
|
||||
body += f"\n\n{args.description}"
|
||||
|
||||
# Build MIME email
|
||||
email_str = _build_calendar_email(
|
||||
DEFAULT_FROM, DEFAULT_OWNER_EMAIL,
|
||||
f"📋 待办: {args.summary}",
|
||||
body, ics_bytes, method="REQUEST",
|
||||
)
|
||||
|
||||
if args.dry_run:
|
||||
print("=== ICS Content ===")
|
||||
print(ics_bytes.decode())
|
||||
print("=== Email Message ===")
|
||||
print(email_str)
|
||||
return
|
||||
|
||||
# Save to TASKS_DIR (without METHOD for CalDAV)
|
||||
@@ -555,13 +519,6 @@ def cmd_todo_add(args):
|
||||
# Sync
|
||||
_sync_calendar()
|
||||
|
||||
# Email the VTODO to owner
|
||||
try:
|
||||
_send_email(email_str)
|
||||
print(f"Emailed todo to {DEFAULT_OWNER_EMAIL}")
|
||||
except subprocess.CalledProcessError:
|
||||
print(f"Warning: Failed to email todo to {DEFAULT_OWNER_EMAIL}")
|
||||
|
||||
|
||||
def _format_todo_digest(todos):
|
||||
"""Format todos into the Chinese priority-grouped digest. Returns string or None."""
|
||||
|
||||
Reference in New Issue
Block a user