This commit is contained in:
Tim Bendt
2025-07-10 10:48:08 -04:00
parent 7cc1c30356
commit f7474a3805
5 changed files with 117 additions and 117 deletions

View File

@@ -7,7 +7,7 @@ from .client import (
list_accounts,
list_folders,
delete_message,
archive_message,
archive_messages,
get_message_content,
)
@@ -16,6 +16,6 @@ __all__ = [
"list_accounts",
"list_folders",
"delete_message",
"archive_message",
"archive_messages",
"get_message_content",
]

View File

@@ -116,28 +116,28 @@ async def delete_message(message_id: int) -> bool:
return False
async def archive_message(message_id: int) -> bool:
"""
Archive a message by its ID.
# async def archive_message(message_id: int) -> [str, bool]:
# """
# Archive a message by its ID.
Args:
message_id: The ID of the message to archive
# Args:
# message_id: The ID of the message to archive
Returns:
True if archiving was successful, False otherwise
"""
try:
process = await asyncio.create_subprocess_shell(
f"himalaya message move Archives {message_id}",
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
stdout, stderr = await process.communicate()
# Returns:
# True if archiving was successful, False otherwise
# """
# try:
# process = await asyncio.create_subprocess_shell(
# f"himalaya message move Archives {message_id}",
# stdout=asyncio.subprocess.PIPE,
# stderr=asyncio.subprocess.PIPE,
# )
# stdout, stderr = await process.communicate()
return process.returncode == 0
except Exception as e:
logging.error(f"Exception during message archiving: {e}")
return False
# return [stdout.decode(), process.returncode == 0]
# except Exception as e:
# logging.error(f"Exception during message archiving: {e}")
# return False
async def archive_messages(message_ids: List[str]) -> Tuple[Optional[str], bool]:
@@ -197,8 +197,7 @@ async def get_message_content(message_id: int) -> Tuple[Optional[str], bool]:
content = stdout.decode()
return content, True
else:
logging.error(f"Error retrieving message content: {
stderr.decode()}")
logging.error(f"Error retrieving message content: {stderr.decode()}")
return None, False
except Exception as e:
logging.error(f"Exception during message content retrieval: {e}")