This commit is contained in:
Felipe M 2021-01-25 16:14:45 +01:00
parent e363ebf5ca
commit f685c48614
Signed by: fmartingr
GPG Key ID: 716BC147715E716F
5 changed files with 9 additions and 8 deletions

View File

@ -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

View File

@ -41,7 +41,6 @@ def incoming_platform_message_view(platform, path=None):
return {}
@app.route("/healthz")
def healthz():
return {}

View File

@ -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)

View File

@ -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"],

View File

@ -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