Skip to content

Commit

Permalink
Symlink folders for non-public convos (to support slack-export-viewer…
Browse files Browse the repository at this point in the history
… & other slack zip importers)

This is pulled in from wolever#4 except for undoing groups.json -> mpims.json commit.
  • Loading branch information
huyz committed Aug 22, 2020
1 parent 6a563f4 commit c5ee545
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions wayslack.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,13 +872,83 @@ def refresh(self):
class ArchiveGroups(BaseArchiver):
name = "groups"

def _fixup_symlinks(self):
for chan in self.get_list():
chan_name_dir = self.archive.path / to_str(chan.name)
if chan_name_dir.exists():
continue
if chan_name_dir.is_symlink():
chan_name_dir.unlink()
symlink_target = os.path.relpath(
str(chan.path),
str(chan_name_dir.parent),
)
chan_name_dir.symlink_to(symlink_target)

archive_channels = self.archive.path / "groups.json"
if not archive_channels.exists():
if archive_channels.is_symlink():
archive_channels.unlink()
archive_channels.symlink_to("_private/default/_groups/groups.json")

def refresh(self):
BaseArchiver.refresh(self)
self._fixup_symlinks()


class ArchiveMPIMs(BaseArchiver):
name = "mpims"

def _fixup_symlinks(self):
for chan in self.get_list():
chan_name_dir = self.archive.path / to_str(chan.name)
if chan_name_dir.exists():
continue
if chan_name_dir.is_symlink():
chan_name_dir.unlink()
symlink_target = os.path.relpath(
str(chan.path),
str(chan_name_dir.parent),
)
chan_name_dir.symlink_to(symlink_target)

archive_channels = self.archive.path / "mpims.json"
if not archive_channels.exists():
if archive_channels.is_symlink():
archive_channels.unlink()
archive_channels.symlink_to("_private/default/_mpims/mpims.json")

def refresh(self):
BaseArchiver.refresh(self)
self._fixup_symlinks()


class ArchiveIMs(BaseArchiver):
name = "ims"

def _fixup_symlinks(self):
for chan in self.get_list():
chan_name_dir = self.archive.path / to_str(chan.id)
if chan_name_dir.exists():
continue
if chan_name_dir.is_symlink():
chan_name_dir.unlink()
symlink_target = os.path.relpath(
str(chan.path),
str(chan_name_dir.parent),
)
chan_name_dir.symlink_to(symlink_target)

archive_channels = self.archive.path / "dms.json"
if not archive_channels.exists():
if archive_channels.is_symlink():
archive_channels.unlink()
archive_channels.symlink_to("_private/default/_ims/ims.json")

def refresh(self):
BaseArchiver.refresh(self)
self._fixup_symlinks()


class ArchiveUsers(BaseArchiver):
name = "users"
Expand Down

0 comments on commit c5ee545

Please sign in to comment.