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

Exclude specified users from activity expiration #1635

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

akhil1508
Copy link

  • On my nextcloud setup, I want to keep activities only for a few months for all users
  • However, the admin activities should be there forever as they provide a great way of keeping track of admin actions and also user actions that set the activity user as admin

Copy link
Collaborator

@artonge artonge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

lib/Data.php Outdated Show resolved Hide resolved
Copy link
Collaborator

@artonge artonge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you take a look at the CI errors?

@akhil1508
Copy link
Author

Could you take a look at the CI errors?

@artonge Apologies, I didn't run PHP CS Fixer; should be good now

@akhil1508
Copy link
Author

akhil1508 commented Apr 15, 2024

@artonge I don't understand

Error: lib/AppInfo/Application.php:114:11: TooFewArguments: Too few arguments for OCA\Activity\Data::__construct - expecting config to be passed (see https://psalm.dev/025)

As I didn't change lib/AppInfo/Application.php

@miaulalala
Copy link
Collaborator

@artonge I don't understand

Error: lib/AppInfo/Application.php:114:11: TooFewArguments: Too few arguments for OCA\Activity\Data::__construct - expecting config to be passed (see psalm.dev/025)

As I didn't change lib/AppInfo/Application.php

You need to register the IConfig injection to

$context->registerService(Data::class, function (ContainerInterface $c) {
return new Data(
$c->get(IManager::class),
$c->get('ActivityConnectionAdapter'),
$c->get(LoggerInterface::class),
);
});

		$context->registerService(Data::class, function (ContainerInterface $c) {
			return new Data(
				$c->get(IManager::class),
				$c->get('ActivityConnectionAdapter'),
				$c->get(LoggerInterface::class),
				$c->get(IConfig::class),
			);
		});

@akhil1508 akhil1508 force-pushed the dev/exclude-from-expiry branch from 558589c to 750eef8 Compare April 16, 2024 08:38
@artonge
Copy link
Collaborator

artonge commented Apr 16, 2024

Could you also squash your commits into one?

@akhil1508 akhil1508 force-pushed the dev/exclude-from-expiry branch from 750eef8 to fac1883 Compare April 16, 2024 11:16
@akhil1508
Copy link
Author

Could you also squash your commits into one?

@artonge done

@miaulalala
Copy link
Collaborator

Tests need the new constructor properties :)

lib/Data.php Outdated
if (!empty($excludedUsers)) {
foreach ($excludedUsers as $user) {
$condition1 = [
'user' => [$user, '!=']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be only the affecteduser below.
This here would mean that actions of the given user would never expire.

Also this breaks the index usage of an already problematic query. So should only be used with care

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickvergessen I'm confused, is the affecteduser the user for whom the activity is fired off or is the affecteduser the user the user who the activity is for?

If a user deleted an account and an activity for admins is fired, would the affecteduser row be the deleted username or the admin username? I want all the activities that are fired for admin users to not expire, to maintain a history of important activities..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User is the actor of the action,
Affected user is the one viewing the activity stream

But then it shows a bit that the config option needs better explanation.
But I still think that only 1 of the checks should stay

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want all the activities that are fired for admin users to not expire, to maintain a history of important activities..

Btw there is also the audit log feature in Nextcloud which is specifically designed for things like this:
https://docs.nextcloud.com/server/latest/developer_manual/basics/logging.html#admin-audit-logging

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickvergessen But then I need to add some new code or patch the files on server as admin audit logs these user deletion and other important actions at "INFO" level.. It uses the loglevel variable and if I allow "INFO" level logs, I'm afraid performance takes a hit for my server :(

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be only the affecteduser below.

@nickvergessen Done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

@akhil1508
Copy link
Author

Tests need the new constructor properties :)

@miaulalala Done. I will squash again and fix commit push after final approval(s) to avoid doing it many times.

@artonge
Copy link
Collaborator

artonge commented May 7, 2024

Still one minor lint error

@akhil1508 akhil1508 force-pushed the dev/exclude-from-expiry branch 2 times, most recently from 029ca38 to df726e5 Compare May 10, 2024 17:40
@akhil1508 akhil1508 force-pushed the dev/exclude-from-expiry branch from 2a8292f to 6ed9908 Compare May 10, 2024 17:43
@akhil1508
Copy link
Author

Still one minor lint error

@artonge Fixed

@artonge
Copy link
Collaborator

artonge commented May 13, 2024

@artonge Fixed

Almost :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants