initialize direct_imap and cleanup server state.
(self, acc)
| 362 | acc.add_account_plugin(logger, name="logger-" + acc._logid) |
| 363 | |
| 364 | def init_imap(self, acc): |
| 365 | """initialize direct_imap and cleanup server state.""" |
| 366 | from deltachat.direct_imap import DirectImap |
| 367 | |
| 368 | assert acc.is_configured() |
| 369 | if not hasattr(acc, "direct_imap"): |
| 370 | acc.direct_imap = DirectImap(acc) |
| 371 | addr = acc.get_config("addr") |
| 372 | if addr not in self._imap_cleaned: |
| 373 | imap = acc.direct_imap |
| 374 | for folder in imap.list_folders(): |
| 375 | if folder.lower() == "inbox" or folder.lower() == "deltachat": |
| 376 | assert imap.select_folder(folder) |
| 377 | imap.delete("1:*", expunge=True) |
| 378 | else: |
| 379 | imap.conn.folder.delete(folder) |
| 380 | acc.log(f"imap cleaned for addr {addr}") |
| 381 | self._imap_cleaned.add(addr) |
| 382 | |
| 383 | |
| 384 | class ACFactory: |
no test coverage detected