Removed redundant _action_wrapper decorator

This commit is contained in:
Fabio Manganiello 2022-08-05 19:00:48 +02:00
parent cbe2e7bbfe
commit 7ab02e705d
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -8,8 +8,6 @@ import re
from aiohttp import ClientConnectionError, ServerDisconnectedError from aiohttp import ClientConnectionError, ServerDisconnectedError
from dataclasses import dataclass from dataclasses import dataclass
from functools import wraps
from typing import Callable
from async_lru import alru_cache from async_lru import alru_cache
from nio import ( from nio import (
@ -61,7 +59,6 @@ from platypush.message.event.matrix import (
MatrixStickerEvent, MatrixStickerEvent,
) )
from platypush.message.response import Response
from platypush.plugins import RunnablePlugin, action from platypush.plugins import RunnablePlugin, action
from platypush.schemas.matrix import ( from platypush.schemas.matrix import (
MatrixDeviceSchema, MatrixDeviceSchema,
@ -90,18 +87,6 @@ class Credentials:
} }
def _action_wrapper(f: Callable) -> Callable:
@wraps(f)
def _wrapper(*args, **kwargs):
try:
return f(*args, **kwargs)
except Exception as e:
logger.exception(e)
return Response(errors=[str(e)])
return _wrapper
class MatrixClient(AsyncClient): class MatrixClient(AsyncClient):
def __init__( def __init__(
self, self,
@ -576,7 +561,6 @@ class MatrixPlugin(RunnablePlugin):
self._connect() self._connect()
@action @action
@_action_wrapper
def send_message( def send_message(
self, self,
room_id: str, room_id: str,
@ -610,7 +594,6 @@ class MatrixPlugin(RunnablePlugin):
) )
@action @action
@_action_wrapper
def get_profile(self, user_id: str): def get_profile(self, user_id: str):
""" """
Retrieve the details about a user. Retrieve the details about a user.
@ -623,7 +606,6 @@ class MatrixPlugin(RunnablePlugin):
return MatrixProfileSchema().dump(profile) return MatrixProfileSchema().dump(profile)
@action @action
@_action_wrapper
def get_room(self, room_id: str): def get_room(self, room_id: str):
""" """
Retrieve the details about a room. Retrieve the details about a room.
@ -654,7 +636,6 @@ class MatrixPlugin(RunnablePlugin):
return MatrixRoomSchema().dump(room) return MatrixRoomSchema().dump(room)
@action @action
@_action_wrapper
def get_devices(self): def get_devices(self):
""" """
Get the list of devices associated to the current user. Get the list of devices associated to the current user.
@ -666,7 +647,6 @@ class MatrixPlugin(RunnablePlugin):
return MatrixDeviceSchema().dump(response.devices, many=True) return MatrixDeviceSchema().dump(response.devices, many=True)
@action @action
@_action_wrapper
def get_joined_rooms(self): def get_joined_rooms(self):
""" """
Retrieve the rooms that the user has joined. Retrieve the rooms that the user has joined.
@ -677,7 +657,6 @@ class MatrixPlugin(RunnablePlugin):
return [self.get_room(room_id).output for room_id in response.rooms] return [self.get_room(room_id).output for room_id in response.rooms]
@action @action
@_action_wrapper
def upload_keys(self): def upload_keys(self):
""" """
Synchronize the E2EE keys with the homeserver. Synchronize the E2EE keys with the homeserver.