fix link references for api v1
This commit is contained in:
parent
b65b040a15
commit
2ce39ea06f
1 changed files with 7 additions and 9 deletions
|
@ -58,7 +58,7 @@ def new_message(msg):
|
||||||
logger.debug('-set_display-')
|
logger.debug('-set_display-')
|
||||||
|
|
||||||
avatar = Avatars.query.filter(Avatars.pnut_user == msg.user.username).one_or_none()
|
avatar = Avatars.query.filter(Avatars.pnut_user == msg.user.username).one_or_none()
|
||||||
if avatar is None or avatar.avatar != msg.user.content.avatar_image.link:
|
if avatar is None or avatar.avatar != msg.user.content.avatar_image.url:
|
||||||
set_matrix_avatar(msg.user)
|
set_matrix_avatar(msg.user)
|
||||||
logger.debug('-set_avatar-')
|
logger.debug('-set_avatar-')
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ def new_message(msg):
|
||||||
for link in msg.content.entities.links:
|
for link in msg.content.entities.links:
|
||||||
if 'title' in link:
|
if 'title' in link:
|
||||||
lnktext += link.title + "\n"
|
lnktext += link.title + "\n"
|
||||||
if 'link' in link:
|
if 'url' in link:
|
||||||
lnktext += link.link + "\n"
|
lnktext += link.url + "\n"
|
||||||
|
|
||||||
if len(lnktext) > 0:
|
if len(lnktext) > 0:
|
||||||
text += "\n" + lnktext
|
text += "\n" + lnktext
|
||||||
|
@ -189,7 +189,7 @@ def set_matrix_avatar(user):
|
||||||
token=config['MATRIX_AS_TOKEN'],
|
token=config['MATRIX_AS_TOKEN'],
|
||||||
identity=matrix_id)
|
identity=matrix_id)
|
||||||
|
|
||||||
dl = requests.get(user.content.avatar_image.link, stream=True)
|
dl = requests.get(user.content.avatar_image.url, stream=True)
|
||||||
dl.raise_for_status()
|
dl.raise_for_status()
|
||||||
with magic.Magic(flags=magic.MAGIC_MIME_TYPE) as m:
|
with magic.Magic(flags=magic.MAGIC_MIME_TYPE) as m:
|
||||||
mtype = m.id_buffer(dl.content)
|
mtype = m.id_buffer(dl.content)
|
||||||
|
@ -199,10 +199,10 @@ def set_matrix_avatar(user):
|
||||||
matrix_api.set_avatar_url(matrix_id, ul['content_uri'])
|
matrix_api.set_avatar_url(matrix_id, ul['content_uri'])
|
||||||
avatar = Avatars.query.filter(Avatars.pnut_user == user.username).one_or_none()
|
avatar = Avatars.query.filter(Avatars.pnut_user == user.username).one_or_none()
|
||||||
if avatar is None:
|
if avatar is None:
|
||||||
avatar = Avatars(pnut_user=user.username, avatar=user.content.avatar_image.link)
|
avatar = Avatars(pnut_user=user.username, avatar=user.content.avatar_image.url)
|
||||||
db_session.add(avatar)
|
db_session.add(avatar)
|
||||||
else:
|
else:
|
||||||
avatar.avatar = user.content.avatar_image.link
|
avatar.avatar = user.content.avatar_image.url
|
||||||
db_session.commit()
|
db_session.commit()
|
||||||
|
|
||||||
except MatrixRequestError:
|
except MatrixRequestError:
|
||||||
|
@ -309,6 +309,7 @@ if __name__ == '__main__':
|
||||||
'-d', action='store_true', dest='debug',
|
'-d', action='store_true', dest='debug',
|
||||||
help="debug logging"
|
help="debug logging"
|
||||||
)
|
)
|
||||||
|
# TODO: solve the database.py problem and enable this
|
||||||
# a_parser.add_argument(
|
# a_parser.add_argument(
|
||||||
# '-c', '--config', default="config.yaml",
|
# '-c', '--config', default="config.yaml",
|
||||||
# help="configuration file"
|
# help="configuration file"
|
||||||
|
@ -321,9 +322,6 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
# with open(args.config, 'rb') as config_file:
|
|
||||||
# config = yaml.load(config_file, Loader=yaml.SafeLoader)
|
|
||||||
|
|
||||||
configyaml = os.environ.get("CONFIG_FILE")
|
configyaml = os.environ.get("CONFIG_FILE")
|
||||||
|
|
||||||
with open(configyaml, "rb") as config_file:
|
with open(configyaml, "rb") as config_file:
|
||||||
|
|
Loading…
Reference in a new issue