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

Add local user and post count to nodeinfo responses #1325

Merged
merged 2 commits into from
Jan 11, 2023

Conversation

sleepdeprecation
Copy link
Contributor

@sleepdeprecation sleepdeprecation commented Jan 9, 2023

Description

This fixes #1307 (at least partially). The nodeinfo endpoint should now return the total users on an instance, along with their post count.

I have a couple outstanding questions, specifically around the extra bits I didn't add to the NodeInfoUsers struct (the active users in the past month/active users in the past 6 months).

It doesn't look like there are currently database functions for querying users active since $date (and if there are, I can add those metrics to the node info response). I'm not familiar enough with the GTS database structure to be able to quickly write those queries, but I am willing to dive in and figure it out if you the maintainers would like that (and also split that bit out into a new issue and pull request because it feels like added scope).

So my main question is do you want those recently active stats in this response? Because I can see arguments around privacy both for and against it, and I don't know what your preference would be.

Checklist

Please put an x inside each checkbox to indicate that you've read and followed it: [ ] -> [x]

If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).

  • I/we have read the GoToSocial contribution guidelines.
  • I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat.
  • I/we have performed a self-review of added code.
  • I/we have written code that is legible and maintainable by others.
  • I/we have commented the added code, particularly in hard-to-understand areas.
  • I/we have made any necessary changes to documentation.
  • I/we have added tests that cover new code.
  • I/we have run tests and they pass locally with the changes.
  • I/we have run go fmt ./... and golangci-lint run.

Just as a note, I have run the tests locally, but they're failing on the internal/media package, and I'm not sure if it's related or if it's because I'm running on an m2 macbook and there might be some weirdness there. The output log was too long for my terminal's scrollback, but I can try adjusting that and running the tests again too.

I'm not sure if there are any changes necessary to the documentation, but if there are, let me know and I'll make them.

And similarly, I'm not sure if there are new tests to write or old tests to modify, thanks to my limited scrollback. I'm certainly willing to add tests, but there aren't any for the internal/processing/federation package yet, and I'm not entirely sure where to best look at existing tests for guidance on how to structure new tests.

Let me know if this sounds good, or if there's any additional work you would like me to do.

This fixes superseriousbusiness#1307 (at least partially). The nodeinfo endpoint should now
return the total users on an instance, along with their post count.
@tsmethurst
Copy link
Contributor

Thank you, this looks really good!

I'm not sure if it's related or if it's because I'm running on an m2 macbook and there might be some weirdness there.

probably! they seem to run fine on the CI/CD system in any case so I think it's all good

I'm not sure if there are any changes necessary to the documentation, but if there are, let me know and I'll make them.

You should regenerate the swagger API documentation, since the nodeinfo struct has changed :) instructions for this are in the contributing.md

I'm certainly willing to add tests, but there aren't any for the internal/processing/federation package yet, and I'm not entirely sure where to best look at existing tests for guidance on how to structure new tests.

I think it could be interesting to add a test in internal/api/nodeinfo to validate the json returned via the API. You could model this on the tests in (for example) internal/api/wellknown/webfinger. You could do this if you feel like going above and beyond :P But don't worry about it too much.

@sleepdeprecation
Copy link
Contributor Author

@tsmethurst I updated the docs, I may look into adding an api test, but I haven't used testify before and need to read some of their docs and also detangle how the webfinger api tests work before I can really think about that.

@tsmethurst
Copy link
Contributor

No worries, I'll merge this as-is then. We'll probably end up doing some refactoring later and can add the tests then. Thank you for your help! :)

@tsmethurst tsmethurst merged commit 3512325 into superseriousbusiness:main Jan 11, 2023
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.

[bug] Nodeinfo does not return any users
2 participants