Add a 'type' string to all etiquette jsonify outputs.

This commit is contained in:
voussoir 2020-04-02 22:43:20 -07:00
parent dd3d40de53
commit 5a16579fe3

View file

@ -5,6 +5,7 @@ dictionaries suitable for JSON serializing.
def album(a, minimal=False):
j = {
'type': 'album',
'id': a.id,
'description': a.description,
'title': a.title,
@ -19,6 +20,7 @@ def album(a, minimal=False):
def bookmark(b):
j = {
'type': 'bookmark',
'id': b.id,
'author': user_or_none(b.get_author()),
'url': b.url,
@ -28,6 +30,7 @@ def bookmark(b):
def exception(e):
j = {
'type': 'error',
'error_type': e.error_type,
'error_message': e.error_message,
}
@ -37,6 +40,7 @@ def photo(p, include_albums=True, include_tags=True):
tags = p.get_tags()
tags.sort(key=lambda x: x.name)
j = {
'type': 'photo',
'id': p.id,
'author': user_or_none(p.get_author()),
'extension': p.extension,
@ -64,6 +68,7 @@ def photo(p, include_albums=True, include_tags=True):
def tag(t, include_synonyms=False, minimal=False):
j = {
'type': 'tag',
'id': t.id,
'name': t.name,
}
@ -78,6 +83,7 @@ def tag(t, include_synonyms=False, minimal=False):
def user(u):
j = {
'type': 'user',
'id': u.id,
'username': u.username,
'created': u.created,