Fix Mail Maildir paths and oCIS auth
Mail: INBOX is a subfolder (INBOX/cur), not the account root. Removed special-case mapping that pointed INBOX to root dir. Files: oCIS user may differ from MCP user (e.g. stefan -> admin). Added _ocis_user() mapping for WebDAV paths and auth. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+6
-2
@@ -22,8 +22,12 @@ OCIS_CREDS = {u: (d['username'], d['password']) for u, d in _cfg['ocis_users'].i
|
||||
mcp = FastMCP("Files", stateless_http=True,
|
||||
transport_security={"enable_dns_rebinding_protection": False})
|
||||
|
||||
def _ocis_user(u):
|
||||
c = OCIS_CREDS.get(u)
|
||||
return c[0] if c else u
|
||||
|
||||
def _auth(u): c = OCIS_CREDS.get(u); return httpx.BasicAuth(c[0], c[1]) if c else None
|
||||
def _dav(u, p=""): return f"{OCIS}/remote.php/dav/files/{u}/{p.lstrip('/')}"
|
||||
def _dav(u, p=""): return f"{OCIS}/remote.php/dav/files/{_ocis_user(u)}/{p.lstrip('/')}"
|
||||
|
||||
def _propfind(user, path="", depth=1):
|
||||
body = '<?xml version="1.0"?><d:propfind xmlns:d="DAV:"><d:prop><d:resourcetype/><d:displayname/><d:getcontentlength/><d:getlastmodified/><d:getcontenttype/></d:prop></d:propfind>'
|
||||
@@ -35,7 +39,7 @@ def _parse_pf(xml, user):
|
||||
entries = []
|
||||
try: root = ET.fromstring(xml)
|
||||
except: return entries
|
||||
bp = f"/remote.php/dav/files/{user}/"
|
||||
bp = f"/remote.php/dav/files/{_ocis_user(user)}/"
|
||||
for resp in root.findall("d:response", ns):
|
||||
href = resp.findtext("d:href", "", ns) or ""
|
||||
rel = href.split(bp, 1)[-1].rstrip("/") if bp in href else href.rstrip("/")
|
||||
|
||||
Reference in New Issue
Block a user