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

whowas: return all responses from the server #372

Merged
merged 6 commits into from
Aug 29, 2024

Conversation

brunnre8
Copy link
Contributor

Whowas results are a list of all known RPL_WHOWASUSER replies. Return the most recent event as the top level and add the rest to a historical field as an array.

Example:

:inspircd.server.example 314 val someone ident3 127.0.0.1 * :Realname
:inspircd.server.example 312 val someone My.Little.Server :Sun Mar 20 2022 10:59:26
:inspircd.server.example 314 val someone ident2 127.0.0.1 * :Realname
:inspircd.server.example 312 val someone My.Little.Server :Sun Mar 20 2022 10:59:16
:inspircd.server.example 314 val someone ident1 127.0.0.1 * :Realname
:inspircd.server.example 312 val someone My.Little.Server :Sun Mar 19 2022 9:23:06
:inspircd.server.example 369 val someone :End of WHOWAS

whowas {
  nick: 'someone',
  ident: 'ident3',
  hostname: '127.0.0.1',
  real_name: 'Realname',
  server: 'My.Little.Server',
  server_info: 'Sun Mar 20 2022 10:59:26',
  historical: [
    {
      nick: 'someone',
      ident: 'ident2',
      hostname: '127.0.0.1',
      real_name: 'Realname',
      server: 'My.Little.Server',
      server_info: 'Sun Mar 20 2022 10:59:16'
    },
    {
      nick: 'someone',
      ident: 'ident1',
      hostname: '127.0.0.1',
      real_name: 'Realname',
      server: 'My.Little.Server',
      server_info: 'Sun Mar 19 2022 9:23:06'
    }
  ]
}

Fixes: #371

Whowas results are a list of all known RPL_WHOWASUSER replies.
Return the most recent event as the top level and add the
rest to a `historical` field as an array.

Example:

```
:inspircd.server.example 314 val someone ident3 127.0.0.1 * :Realname
:inspircd.server.example 312 val someone My.Little.Server :Sun Mar 20 2022 10:59:26
:inspircd.server.example 314 val someone ident2 127.0.0.1 * :Realname
:inspircd.server.example 312 val someone My.Little.Server :Sun Mar 20 2022 10:59:16
:inspircd.server.example 314 val someone ident1 127.0.0.1 * :Realname
:inspircd.server.example 312 val someone My.Little.Server :Sun Mar 19 2022 9:23:06
:inspircd.server.example 369 val someone :End of WHOWAS

whowas {
  nick: 'someone',
  ident: 'ident3',
  hostname: '127.0.0.1',
  real_name: 'Realname',
  server: 'My.Little.Server',
  server_info: 'Sun Mar 20 2022 10:59:26',
  historical: [
    {
      nick: 'someone',
      ident: 'ident2',
      hostname: '127.0.0.1',
      real_name: 'Realname',
      server: 'My.Little.Server',
      server_info: 'Sun Mar 20 2022 10:59:16'
    },
    {
      nick: 'someone',
      ident: 'ident1',
      hostname: '127.0.0.1',
      real_name: 'Realname',
      server: 'My.Little.Server',
      server_info: 'Sun Mar 19 2022 9:23:06'
    }
  ]
}
```

Fixes: kiwiirc#371
@brunnre8
Copy link
Contributor Author

@ItsOnlyBinary something along those lines? Or what did you have in mind?

I tried to do it with only one cache key, but it gets rather hairy as we don't know which numeric replies we get in between responses... so in the end I opted for the second key, that we can use as a scratch space.

@brunnre8 brunnre8 marked this pull request as ready for review January 4, 2024 18:00
@Sam-Scheding
Copy link

Why not add ident3 to historical too? So:

whowas {
  nick: 'someone',
  ident: 'ident3',
  hostname: '127.0.0.1',
  real_name: 'Realname',
  server: 'My.Little.Server',
  server_info: 'Sun Mar 20 2022 10:59:26',
  historical: [
    {
      nick: 'someone',
      ident: 'ident3',
      hostname: '127.0.0.1',
      real_name: 'Realname',
      server: 'My.Little.Server',
      server_info: 'Sun Mar 20 2022 10:59:26'
    },
    {
      nick: 'someone',
      ident: 'ident2',
      hostname: '127.0.0.1',
      real_name: 'Realname',
      server: 'My.Little.Server',
      server_info: 'Sun Mar 20 2022 10:59:16'
    },
    {
      nick: 'someone',
      ident: 'ident1',
      hostname: '127.0.0.1',
      real_name: 'Realname',
      server: 'My.Little.Server',
      server_info: 'Sun Mar 19 2022 9:23:06'
    }
  ]

That way it's still backwards compatible, as required here, but anybody parsing historical data can just loop over the historical array without needing separate logic to handle the most recent identity.

(I don't have anything to do with this project. I just consume it, and was looking through issues)

@brunnre8
Copy link
Contributor Author

brunnre8 commented Mar 6, 2024

not sure if duplicating the info really benefits you much?

But yeah you have a point.
I could do that, at the cost of making the response longer.
Unsure if by then a new event wouldn't make more sense though

@ItsOnlyBinary ItsOnlyBinary merged commit 35e87c4 into kiwiirc:master Aug 29, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

whowas swallows older replies
3 participants