mirror of
https://github.com/etesync/server
synced 2024-11-18 23:08:08 +00:00
Exclude unset fields so fix removedMemberships return value.
This commit is contained in:
parent
d63c34693f
commit
15988235f2
@ -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)
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user