Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update read state of mentioned users #235

Open
github-actions bot opened this issue Oct 22, 2024 · 0 comments
Open

update read state of mentioned users #235

github-actions bot opened this issue Oct 22, 2024 · 0 comments
Labels

Comments

@github-actions
Copy link

... # TODO: update read state of mentioned users

            "last_message_id": str(self.last_read_id),
            "id": str(self.channel.id),
        }

    @classmethod
    async def create_or_add(
            cls, user: models.User, channel: models.Channel, mentions: int = 1, last_read_id: Optional[int] = None,
    ) -> ReadState:
        state, created = await cls.get_or_create(user=user, channel=channel, defaults={
            "count": mentions,
            "last_read_id": last_read_id or 0,
        })
        if not created:
            state.count += mentions
            state.last_read_id = last_read_id or state.last_read_id
            await state.save(update_fields=["count", "last_read_id"])

        return state

    @classmethod
    async def update_from_message(cls, message: models.Message) -> None:
        if message.channel.type in (ChannelType.DM, ChannelType.GROUP_DM):
            for user in await message.channel.recipients.filter(id__not=message.author.id):
                await models.ReadState.create_or_add(user, message.channel)
        elif message.channel.type in GUILD_CHANNELS:
            ...  # TODO: update read state of mentioned users
@github-actions github-actions bot added the todo label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants