This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

archiver-bot: E2EE support, IPFS/Jellyfin deep links, ipfs.lassul.us proxy

+42 -3
+1 -2
2configs/services/archiver-bot.nix
··· 1 1 { 2 - self, 3 2 config, 4 3 pkgs, 5 4 ... ··· 54 53 export RADARR_API_KEY="$(${pkgs.libxml2}/bin/xmllint --xpath 'string(//ApiKey)' "$CREDENTIALS_DIRECTORY/radarr-config")" 55 54 export SONARR_API_KEY="$(${pkgs.libxml2}/bin/xmllint --xpath 'string(//ApiKey)' "$CREDENTIALS_DIRECTORY/sonarr-config")" 56 55 export JELLYFIN_API_KEY="$(cat "$CREDENTIALS_DIRECTORY/jellyfin-api-key")" 57 - exec ${self.packages.${pkgs.system}.archiver-bot}/bin/archiver-bot 56 + exec ${pkgs.callPackage ../../5pkgs/archiver-bot/package.nix { }}/bin/archiver-bot 58 57 ''; 59 58 60 59 serviceConfig = {
+2 -1
5pkgs/archiver-bot/package.nix
··· 12 12 build-system = [ python3Packages.setuptools ]; 13 13 14 14 dependencies = with python3Packages; [ 15 - matrix-nio 15 + (matrix-nio.override { withOlm = true; }) 16 16 aiohttp 17 + cffi 17 18 ]; 18 19 19 20 meta = {
+1
2configs/services/flix/default.nix
··· 436 436 "aspnetcore-runtime-6.0.36" 437 437 "dotnet-sdk-wrapped-6.0.428" 438 438 "dotnet-sdk-6.0.428" 439 + "olm-3.2.16" 439 440 ]; 440 441 441 442 # indexers
+38
5pkgs/archiver-bot/archiver_bot/__init__.py
··· 10 10 from aiohttp import web 11 11 from nio import ( 12 12 AsyncClient, 13 + AsyncClientConfig, 13 14 InviteMemberEvent, 14 15 LoginResponse, 15 16 MatrixRoom, ··· 338 339 return (f"❌ Failed to request {display}: {error}", f"❌ Failed to request <b>{display}</b>: {error}") 339 340 340 341 342 + async def trust_room_devices(client: AsyncClient, room_id: str): 343 + """Trust all devices of all members in a room.""" 344 + if not client.olm: 345 + return 346 + room = client.rooms.get(room_id) 347 + if not room: 348 + return 349 + for user_id in room.users: 350 + for device in client.device_store.active_user_devices(user_id): 351 + if not client.olm.is_device_verified(device): 352 + client.verify_device(device) 353 + log.info(f"Verified device {device.device_id} of {user_id}") 354 + 355 + 341 356 async def send_notice(client: AsyncClient, room_id: str, plain: str, html: str): 342 357 """Send a notice message to a room.""" 358 + await trust_room_devices(client, room_id) 343 359 await client.room_send( 344 360 room_id, 345 361 "m.room.message", ··· 514 530 515 531 async def run(): 516 532 """Main bot loop.""" 533 + client_config = AsyncClientConfig( 534 + store_sync_tokens=True, 535 + encryption_enabled=True, 536 + ) 517 537 client = AsyncClient( 518 538 MATRIX_HOMESERVER, 519 539 MATRIX_USER_ID, 520 540 device_id=MATRIX_DEVICE_ID, 521 541 store_path=STORE_PATH, 542 + config=client_config, 522 543 ) 523 544 client.access_token = MATRIX_ACCESS_TOKEN 524 545 client.user_id = MATRIX_USER_ID 546 + client.load_store() 547 + log.info(f"Crypto store loaded, olm={client.olm is not None}") 525 548 526 549 http = aiohttp.ClientSession() 527 550 ··· 535 558 await http.close() 536 559 await client.close() 537 560 sys.exit(1) 561 + 562 + # E2EE setup 563 + if client.olm: 564 + log.info("Uploading device keys...") 565 + key_upload = await client.keys_upload() 566 + log.info(f"Key upload result: {key_upload}") 567 + 568 + # Trust all known device keys so we can decrypt messages 569 + for user_id in client.device_store.users: 570 + for device in client.device_store.active_user_devices(user_id): 571 + if not client.olm.is_device_verified(device): 572 + client.verify_device(device) 573 + log.info(f"Verified device {device.device_id} of {user_id}") 574 + else: 575 + log.warning("Olm not available after sync — E2EE will not work") 538 576 539 577 # Register event callbacks only after initial sync 540 578 client.add_event_callback(lambda room, event: on_message(client, room, event, http), RoomMessageText)