feat: Add recent published section and filter self-interactions

- Add "Publicaciones Recientes" section to dashboard showing published posts
- Filter out self-generated interactions in X API (thread auto-replies)
- Improve username resolution for X interactions using user expansions
- Pass recent_published data to dashboard template

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-28 23:29:02 +00:00
parent 7427e818a5
commit f4f0a2d230
4 changed files with 77 additions and 5 deletions

View File

@@ -214,30 +214,45 @@ class XPublisher(BasePublisher):
return []
async def get_comments(self, post_id: str) -> List[Dict]:
"""Obtener respuestas a un tweet."""
"""Obtener respuestas a un tweet (excluyendo las propias)."""
if not self.client:
return []
try:
# Obtener ID del usuario autenticado para filtrar auto-respuestas
me = self.client.get_me()
my_user_id = str(me.data.id) if me.data else None
# Buscar respuestas al tweet
query = f"conversation_id:{post_id}"
tweets = self.client.search_recent_tweets(
query=query,
max_results=50,
tweet_fields=['created_at', 'author_id', 'in_reply_to_user_id']
tweet_fields=['created_at', 'author_id', 'in_reply_to_user_id'],
user_fields=['username'],
expansions=['author_id']
)
if not tweets.data:
return []
# Crear mapa de usuarios para obtener usernames
users_map = {}
if tweets.includes and 'users' in tweets.includes:
for user in tweets.includes['users']:
users_map[str(user.id)] = user.username
# Filtrar tweets propios (auto-respuestas del hilo)
return [
{
"id": str(tweet.id),
"text": tweet.text,
"author_id": str(tweet.author_id),
"username": users_map.get(str(tweet.author_id), "unknown"),
"created_at": tweet.created_at.isoformat() if tweet.created_at else None
}
for tweet in tweets.data
if str(tweet.author_id) != my_user_id # Excluir tweets propios
]
except tweepy.TweepyException: