Fix bugs in manual bridging that were added by the previous fix
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
from typing import Optional, Tuple, Coroutine, Dict, Any
|
||||
from typing import Optional, Tuple, Awaitable
|
||||
import asyncio
|
||||
|
||||
from telethon.tl.types import ChatForbidden, ChannelForbidden
|
||||
@@ -105,8 +105,7 @@ async def bridge(evt: CommandEvent) -> EventID:
|
||||
|
||||
|
||||
async def cleanup_old_portal_while_bridging(evt: CommandEvent, portal: "po.Portal"
|
||||
) -> Tuple[
|
||||
bool, Optional[Coroutine[None, None, None]]]:
|
||||
) -> Tuple[bool, Optional[Awaitable[None]]]:
|
||||
if not portal.mxid:
|
||||
await evt.reply("The portal seems to have lost its Matrix room between you"
|
||||
"calling `$cmdprefix+sp bridge` and this command.\n\n"
|
||||
@@ -156,10 +155,6 @@ async def confirm_bridge(evt: CommandEvent) -> Optional[EventID]:
|
||||
evt.sender.command_status = None
|
||||
is_logged_in = await evt.sender.is_logged_in() and not status["force_use_bot"]
|
||||
async with portal._room_create_lock:
|
||||
if portal.mxid:
|
||||
return await evt.reply("The portal seems to have created a Matrix room while you were "
|
||||
"calling this command.\n\n"
|
||||
"Please start over by calling the bridge command again.")
|
||||
await _locked_confirm_bridge(evt, portal=portal, room_id=bridge_to_mxid,
|
||||
is_logged_in=is_logged_in)
|
||||
|
||||
|
||||
@@ -302,9 +302,6 @@ class BasePortal(MautrixBasePortal, ABC):
|
||||
await self.cleanup_room(self.main_intent, self.mxid, message, puppets_only)
|
||||
if delete:
|
||||
await self.delete()
|
||||
else:
|
||||
self.delete_matrix()
|
||||
self.mxid = None
|
||||
|
||||
# endregion
|
||||
# region Database conversion
|
||||
@@ -331,21 +328,18 @@ class BasePortal(MautrixBasePortal, ABC):
|
||||
async def delete(self) -> None:
|
||||
self.delete_sync()
|
||||
|
||||
def delete_matrix(self) -> None:
|
||||
try:
|
||||
del self.by_mxid[self.mxid]
|
||||
except KeyError:
|
||||
pass
|
||||
DBMessage.delete_all(self.mxid)
|
||||
|
||||
def delete_sync(self) -> None:
|
||||
try:
|
||||
del self.by_tgid[self.tgid_full]
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
del self.by_mxid[self.mxid]
|
||||
except KeyError:
|
||||
pass
|
||||
if self._db_instance:
|
||||
self._db_instance.delete()
|
||||
self.delete_matrix()
|
||||
DBMessage.delete_all(self.mxid)
|
||||
self.deleted = True
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user