Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add account data to export command #14969

Merged
merged 6 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
adopt #14973
  • Loading branch information
dklimpel committed Feb 14, 2023
commit 6dfbf5ac9796b8f543ac4167d766448f2135e24b
4 changes: 2 additions & 2 deletions synapse/app/admin_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import os
import sys
import tempfile
from typing import Dict, List, Optional
from typing import List, Mapping, Optional

from twisted.internet import defer, task

Expand Down Expand Up @@ -223,7 +223,7 @@ def write_connections(self, connections: List[JsonDict]) -> None:
print(json.dumps(connection), file=f)

def write_account_data(
self, file_name: str, account_data: Dict[str, JsonDict]
self, file_name: str, account_data: Mapping[str, JsonDict]
) -> None:
account_data_directory = os.path.join(
self.base_directory, "user_data", "account_data"
Expand Down
9 changes: 5 additions & 4 deletions synapse/handlers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import abc
import logging
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set
from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, Set

from synapse.api.constants import Direction, Membership
from synapse.events import EventBase
Expand Down Expand Up @@ -264,7 +264,8 @@ async def export_user_data(self, user_id: str, writer: "ExfiltrationWriter") ->
)

# Get all account data the user has global and in rooms
global_data, by_room_data = await self._store.get_account_data_for_user(user_id)
global_data = await self._store.get_global_account_data_for_user(user_id)
by_room_data = await self._store.get_room_account_data_for_user(user_id)
writer.write_account_data("global", global_data)
for room_id in by_room_data:
writer.write_account_data(room_id, by_room_data[room_id])
Expand Down Expand Up @@ -348,13 +349,13 @@ def write_connections(self, connections: List[JsonDict]) -> None:

@abc.abstractmethod
def write_account_data(
self, file_name: str, account_data: Dict[str, JsonDict]
self, file_name: str, account_data: Mapping[str, JsonDict]
) -> None:
"""Write the account data of a user.

Args:
file_name: file name to write data
account_data: dict of global or room account_data
account_data: mapping of global or room account_data
"""
raise NotImplementedError()

Expand Down