feat(signal): make signal-cli attachments directory configurable
The inbound attachment loop hardcoded ~/.local/share/signal-cli/attachments as the source path. That is the daemon's default on Linux but not on macOS or Windows, and breaks if the daemon was launched with XDG_DATA_HOME set. Add SignalConfig.attachments_dir as an optional override. When unset the behavior is unchanged; when set the value is run through Path.expanduser() so ~ is honored. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
committed by
Xubin Ren
co-authored by
Claude Opus 4.7
parent
ad7c1ac381
commit
83aed43682
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
import pytest
|
||||
@@ -71,6 +72,7 @@ def _make_channel(
|
||||
group_allow_from: list[str] | None = None,
|
||||
require_mention: bool = True,
|
||||
group_buffer_size: int = 20,
|
||||
attachments_dir: str | None = None,
|
||||
) -> SignalChannel:
|
||||
config = SignalConfig(
|
||||
enabled=True,
|
||||
@@ -87,6 +89,7 @@ def _make_channel(
|
||||
require_mention=require_mention,
|
||||
),
|
||||
group_message_buffer_size=group_buffer_size,
|
||||
attachments_dir=attachments_dir,
|
||||
)
|
||||
return SignalChannel(config, MessageBus())
|
||||
|
||||
@@ -471,6 +474,21 @@ class TestGroupBuffer:
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class TestAttachmentsDir:
|
||||
def test_default_attachments_dir(self):
|
||||
ch = _make_channel()
|
||||
expected = Path.home() / ".local/share/signal-cli/attachments"
|
||||
assert ch._signal_attachments_dir() == expected
|
||||
|
||||
def test_configured_attachments_dir(self, tmp_path):
|
||||
ch = _make_channel(attachments_dir=str(tmp_path / "custom"))
|
||||
assert ch._signal_attachments_dir() == tmp_path / "custom"
|
||||
|
||||
def test_attachments_dir_expands_user(self):
|
||||
ch = _make_channel(attachments_dir="~/signal-attachments")
|
||||
assert ch._signal_attachments_dir() == Path.home() / "signal-attachments"
|
||||
|
||||
|
||||
class TestHandleDataMessageDM:
|
||||
def _make_dm_channel(self, policy="open", allow_from=None) -> tuple[SignalChannel, list]:
|
||||
ch = _make_channel(dm_enabled=True, dm_policy=policy, dm_allow_from=allow_from or [])
|
||||
|
||||
Reference in New Issue
Block a user