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

ack_bulk not finished #622

Open
3 tasks done
NotTrueFalse opened this issue Dec 3, 2023 · 7 comments
Open
3 tasks done

ack_bulk not finished #622

NotTrueFalse opened this issue Dec 3, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@NotTrueFalse
Copy link

Summary

The function ack_bulk is not finished

Reproduction Steps

function in http.py file named ack_bulk() isn't finished, no bug, its more of an improvement request.

Code

No response

Expected Results

I found this function in http.py file named ack_bulk(), but it seems that it's used nowhere else in the code.
I tried multiple to search for ways to retreive all message containing a mention using the recent_mentions() function, but it didn't get all of them, and when I try to delete them, I got rate limited. So the problem is that ack_bulk is not finished (to ack every channel / guild where there is a ping), and the other problem is that there are no function to make it work like discord does. It use some weird function to get all recent message_Id and channel_Id of a server and then ack_bulk with a BulkReadState completed. On top of that I tried to ack() every guild of a client, and got cloudflare rate limited, so this function would be very appreciated.

Actual Results

Nothing.

The ideal solution would be to finish the function and add another function to get all recent message_Id : channel_Id, to create a good BulkReadState, and then to ack_bulk properly. besides that, the function to retreive such message and channel could be very usefull just to retreive message that hasn't been acked yet.

System Information

  • Python v3.11.5-final
  • discord.py v2.3.2-final
  • aiohttp v3.8.5
  • system info: Windows 10 10.0.19045

Checklist

  • I have searched the open issues for duplicates.
  • I have shared the entire traceback.
  • I am using a user token (and it isn't visible in the code).

Additional Information

I found interesting stuff: add a breakpoint at line:column -> 1:841 , to the function that is looking like this function C(e,t){let n=l.flatMap in file d91931f73a4d8b14d93f.js.

It's the only thing I found about discord filtering message and channel id to then ack_bulk them.
If something already exist, I'm sorry to disturb the project and will close this issue ASAP.

@NotTrueFalse NotTrueFalse added the unconfirmed bug Unconfirmed bug label Dec 3, 2023
@dolfies dolfies added enhancement New feature or request and removed unconfirmed bug Unconfirmed bug labels Dec 27, 2023
@dolfies
Copy link
Owner

dolfies commented Dec 27, 2023

Hello, sorry for the late response. The reason why this was never implemented is because I couldn't really think of a good API interface for it. How do you think this should be implemented/usable?

@dolfies
Copy link
Owner

dolfies commented Dec 27, 2023

FWIW, the recent_mentions() function is the same API call that's used in the official client's inbox tab.

@NotTrueFalse
Copy link
Author

I know that recent_mentions exists, I use it to get recent message, but I can't use it to ack them, or else I would have a lot of rate limit errors. So a function to create a payload that look like this :

[
    {
        "channel_id": "x",
        "message_id": "y",
        "read_state_type": 0
    },
    {
        "channel_id": "z",
        "message_id": "w",
        "read_state_type": 0
    },...
]

and then post it to /api/v9/read-states/ack-bulk would be the best.
So it ack guilds that has channel with channel_id, and then return the list of channel.

I'm sorry if its not clear, but I think just call recent_mentions, gather channel & messages ids to put them in a list to post to the api is a good solution. I think it needs state stuff or just the sessions to post it.
That was my idea, so then I would just have to do client.ack_all() or client.ack_bulk() or any other name you can think of, then it will return the channel in a list.

@dolfies
Copy link
Owner

dolfies commented Dec 28, 2023

Yeah I know how the API request looks, but I'm not sure how to implement it in a user-friendly way. Raw JSON is not user friendly.

@NotTrueFalse
Copy link
Author

NotTrueFalse commented Dec 28, 2023

async def recent_ack_bulk(
        self,
        limit: int = 25,
        before: Optional[Snowflake] = None,
        guild_id: Optional[Snowflake] = None,
        roles: bool = True,
        everyone: bool = True,
   ) -> List[MessageableChannel]:
        #create bulkreadstates from recent mentions
        bulks = []
        channels = []
        mentions = await self.get_recent_mentions(limit=limit, before=before, guild_id=guild_id, roles=roles, everyone=everyone)
        for message in mentions:
            if message != None:
                channel = await self.get_channel(message.channel_id)
                message = await self.get_message(message.channel_id, message.id)
                bulk = read_state.BulkReadState(channel_id=message.channel_id, message_id=message.id, timestamp=message.timestamp)
                channels.append(channel)
        #ack bulkreadstates
        await self.ack_bulk(bulks)
        return channels

is something like that good? I don't know if I'm supposed to use another function to get recent mentions. I created this function inside http.py, I don't know how to access get_channel from guild.py nor fetch_message from abc.py.
For now that's what I had in mind, I didn't test it, just made it up like that.
It's like a version of recents_mentions where it ack all of it and return message instead of just returning messages.

@dolfies
Copy link
Owner

dolfies commented Dec 28, 2023

This doesn't really work. One function should preferably only make a single API call per iteration, and this implementation is way too specific. Marking all messages as read isn't the bulk ack endpoint's only use, and I don't see a reason to tie this into the get recent mentions endpoint.

Preferably, I'd have a client.ack() function that somehow accepts some form of ReadState object that I can construct resource (channel) ID/entity (message) ID pairs from. The issue is it's hard to make this ergonomic.

@NotTrueFalse
Copy link
Author

hmm okay, I don't know what do you mean by ergonomic, but I think you have the right idea. I'm sorry if I wasn't able to help a lot, my goal was just to know if it was possible to make this function. If I can help by doing anything, don't mind to ask me 👍.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants