Mail list: name everyone who wrote in the thread, and call the user "me"
The sender column showed participants[0], and participants are rebuilt
newest message first — so replying to a thread put the user in that slot
and the list named them instead of the person who wrote in.
Thread summaries (list and search) now carry `senders`: the distinct From
addresses of the thread's visible messages, oldest first, with the same
Trash/Spam visibility as the message count. The list joins them and shows
the user's own account addresses as "me" ("me, Alice" for a thread the
user started), and the avatar prefers the other side of the conversation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@ from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.api.schemas import SearchOut, SearchThreadHit
|
||||
from app.api.threads import _summary
|
||||
from app.api.threads import _summary, thread_senders
|
||||
from app.db import get_session
|
||||
from app.identity.deps import CurrentUser
|
||||
from app.models import Thread
|
||||
@@ -56,8 +56,12 @@ async def search(
|
||||
select(Thread).where(Thread.id.in_(order), Thread.user_id == user.id)
|
||||
)
|
||||
}
|
||||
senders = await thread_senders(db, user.id, list(threads))
|
||||
results = [
|
||||
SearchThreadHit(thread=_summary(threads[tid]), highlights=highlights.get(tid, {}))
|
||||
SearchThreadHit(
|
||||
thread=_summary(threads[tid], senders=senders.get(tid)),
|
||||
highlights=highlights.get(tid, {}),
|
||||
)
|
||||
for tid in order
|
||||
if tid in threads
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user