diff --git a/butterrobot/admin/blueprint.py b/butterrobot/admin/blueprint.py index 2d6560d..c59b1b3 100644 --- a/butterrobot/admin/blueprint.py +++ b/butterrobot/admin/blueprint.py @@ -42,7 +42,7 @@ def load_logged_in_user(): g.user = None else: try: - user = UserQuery.get(user_id) + user = UserQuery.get(id=user_id) g.user = user except UserQuery.NotFound: g.user = None diff --git a/butterrobot/app.py b/butterrobot/app.py index 8301a5d..582f22a 100644 --- a/butterrobot/app.py +++ b/butterrobot/app.py @@ -41,7 +41,6 @@ def incoming_platform_message_view(platform, path=None): return {} - @app.route("/healthz") def healthz(): return {} diff --git a/butterrobot/db.py b/butterrobot/db.py index 5d67c43..13051e7 100644 --- a/butterrobot/db.py +++ b/butterrobot/db.py @@ -32,7 +32,7 @@ class Query: Allows retrieving object by multiple columns. Raises `NotFound` error if query return no results. """ - row = db[cls.tablename].find_one() + row = db[cls.tablename].find_one(**kwargs) if not row: raise cls.NotFound return cls.obj(**row) @@ -109,14 +109,14 @@ class ChannelQuery(Query): @classmethod def get(cls, _id): - channel = super().get(_id) + channel = super().get(id=_id) plugins = ChannelPluginQuery.get_from_channel_id(_id) channel.plugins = {plugin.plugin_id: plugin for plugin in plugins} return channel @classmethod def get_by_platform(cls, platform, platform_channel_id): - result = cls.tablename.find_one( + result = db[cls.tablename].find_one( platform=platform, platform_channel_id=platform_channel_id ) if not result: @@ -154,8 +154,8 @@ class ChannelPluginQuery(Query): @classmethod def get_from_channel_id(cls, channel_id): - yield from [cls.obj(**row) for row in cls.tablename.find(channel_id=channel_id)] + yield from [cls.obj(**row) for row in db[cls.tablename].find(channel_id=channel_id)] @classmethod def delete_by_channel(cls, channel_id): - cls.tablename.delete(channel_id=channel_id) + cls.delete(channel_id=channel_id) diff --git a/butterrobot/platforms/slack.py b/butterrobot/platforms/slack.py index 2cb829e..f8a615e 100644 --- a/butterrobot/platforms/slack.py +++ b/butterrobot/platforms/slack.py @@ -82,7 +82,7 @@ class SlackPlatform(Platform): logger.debug("Parsing message", platform=cls.ID, data=data) return Message( id=data["event"].get("thread_ts", data["event"]["ts"]), - author=data["event"]["user"], + author=data["event"].get("user"), from_bot="bot_id" in data["event"], date=datetime.fromtimestamp(int(float(data["event"]["event_ts"]))), text=data["event"]["text"], diff --git a/butterrobot/plugins.py b/butterrobot/plugins.py index c85ab1c..97ee686 100644 --- a/butterrobot/plugins.py +++ b/butterrobot/plugins.py @@ -8,6 +8,7 @@ import structlog from butterrobot.objects import Message + logger = structlog.get_logger(__name__) @@ -63,4 +64,5 @@ def get_available_plugins(): module=ep.module_name, ) + logger.info("Plugins loaded", plugins=list(plugins.keys())) return plugins