| 244 | # ==== |
| 245 | |
| 246 | async def get_conversations(self, user_id=None, platform_id=None): |
| 247 | async with self.get_db() as session: |
| 248 | session: AsyncSession |
| 249 | query = select(ConversationV2) |
| 250 | |
| 251 | if user_id: |
| 252 | query = query.where(ConversationV2.user_id == user_id) |
| 253 | if platform_id: |
| 254 | query = query.where(ConversationV2.platform_id == platform_id) |
| 255 | # order by |
| 256 | query = query.order_by(desc(ConversationV2.created_at)) |
| 257 | result = await session.execute(query) |
| 258 | |
| 259 | return result.scalars().all() |
| 260 | |
| 261 | async def get_conversation_by_id(self, cid): |
| 262 | async with self.get_db() as session: |