Separate system accounts and household people, add generation directory and consented member location sharing

This commit is contained in:
Codex
2026-10-18 20:00:43 +08:00
parent 67bc5a1ba9
commit 3b2c046060
52 changed files with 1497 additions and 311 deletions
+9 -3
View File
@@ -185,7 +185,7 @@ class Journal:
mode = query.get('mode', 'feed')
if mode == 'feed': entries = [e for e in entries if e['visibility'] == 'household']
elif mode == 'mine': entries = [e for e in entries if e['ownerId'] == user['id']]
elif mode == 'person': entries = [e for e in entries if e['ownerId'] == query.get('person')]
elif mode == 'person': entries = [e for e in entries if e['ownerId'] == query.get('person') or query.get('person') in e.get('participantIds', [])]
for field, compare in [('from', lambda x, y: x >= y), ('to', lambda x, y: x <= y)]:
if query.get(field):
self.date(query[field]); entries = [e for e in entries if compare(e['occurredOn'], query[field])]
@@ -222,8 +222,10 @@ class Journal:
trash = [dict(self.public_media(m), references=references.get(m['id'], 0)) for m in owned if m.get('trashedAt') or m['status'] == 'removed']
trash.sort(key=lambda m: m.get('trashedAt') or m['at'], reverse=True)
people = {e['ownerId']: e['authorName'] for e in a.objects('journal_entries') if self.visible(user, e)}
member_people = [dict(id=m['personId'],name=m['name']) for m in a.MEMBERS.snapshot(user)['items']]
people.update({m['id']:m['name'] for m in member_people})
return dict(items=items, total=len(entries), page=page, uploads=uploads[:50], trash=trash[:50], cleanup=cleanup[:50], people=people,
connection=a.BAIDU.status(user), chunkSize=CHUNK, maxFile=MAX_FILE)
memberPeople=member_people,connection=a.BAIDU.status(user), chunkSize=CHUNK, maxFile=MAX_FILE)
def date(self, value):
try:
@@ -263,9 +265,13 @@ class Journal:
if item.get('trashedAt') and mid not in (old or {}).get('mediaIds', []):
raise a.Problem('请先恢复已删除的附件再添加到记事', 409)
if not text and not ids: raise a.Problem('请写下内容或添加附件')
participants = data.get('participantIds', (old or {}).get('participantIds', []))
allowed = {m['personId'] for m in a.MEMBERS.rows(a.HOUSEHOLDS.scope(user))}
if not isinstance(participants, list) or len(participants)>100 or any(not isinstance(p,str) or p not in allowed for p in participants) or len(set(participants))!=len(participants):
raise a.Problem('请选择本家庭登记的参与人物')
now = dt.datetime.now(dt.timezone.utc).isoformat()
entry = dict(id=old['id'] if old else secrets.token_hex(8), familyId=a.HOUSEHOLDS.scope(user),
ownerId=user['id'], authorName=user['name'], text=text, category=category,
ownerId=user['id'], authorName=user['name'], text=text, category=category,participantIds=participants,
visibility=visibility, occurredOn=self.date(data.get('occurredOn')),
mediaIds=ids, createdAt=old['createdAt'] if old else now, updatedAt=now,
revision=(old or {}).get('revision', 0)+1, clientId=client, deleted=False)