1
0
mirror of https://github.com/etesync/server synced 2024-12-29 10:48:07 +00:00

Exclude unset fields so fix removedMemberships return value.

This commit is contained in:
Tom Hacohen 2020-12-28 08:42:48 +02:00
parent d63c34693f
commit 15988235f2
2 changed files with 4 additions and 4 deletions

View File

@ -176,8 +176,9 @@ def collection_list_common(
context = Context(user, prefetch)
data: t.List[CollectionOut] = [CollectionOut.from_orm_context(item, context) for item in result]
ret = CollectionListResponse(data=data, stoken=new_stoken, done=done)
stoken_obj = get_stoken_obj(stoken)
removedMemberships = None
if stoken_obj is not None:
# FIXME: honour limit? (the limit should be combined for data and this because of stoken)
remed_qs = models.CollectionMemberRemoved.objects.filter(user=user, stoken__id__gt=stoken_obj.id)
@ -188,9 +189,8 @@ def collection_list_common(
remed = remed_qs.values_list("collection__uid", flat=True)
if len(remed) > 0:
removedMemberships = [{"uid": x} for x in remed]
ret.removedMemberships = [{"uid": x} for x in remed]
ret = CollectionListResponse(data=data, stoken=new_stoken, done=done, removedMemberships=removedMemberships)
return MsgpackResponse(content=ret)

View File

@ -24,7 +24,7 @@ class MsgpackResponse(Response):
return b""
if isinstance(content, BaseModel):
content = content.dict()
content = content.dict(exclude_unset=True)
return msgpack.packb(content, use_bin_type=True)