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

basic notify_push usage with session handling #3876

Merged
merged 33 commits into from
Jan 3, 2023

Conversation

alangecker
Copy link
Collaborator

@alangecker alangecker commented Jun 20, 2022

Summary

keeps track of current active sessions on a board and shows them in the UI, including real time updates via notify_push.

screen

it is not very useful in itself, but acts as a base and is probably most of the work towards getting live updates for changes #256 finally, because the server needs to know to whom it sends these updates.

If this step goes through, I'm also happy to work on the actual live updates :)

Part of the code is thankfully taken from @juliushaertl sessions in text

Requirement

it needs notify_push installed and running.

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Tests (unit, integration, api and/or acceptance) are included
  • Documentation (manuals or wiki) has been updated or is not required

@alangecker alangecker force-pushed the sessions branch 3 times, most recently from 717e1da to f4dd246 Compare June 24, 2022 12:38
@alangecker
Copy link
Collaborator Author

alangecker commented Jun 24, 2022

tests and analysis currently still fail with errors, which seem totally unrelated to my changes.
Is master broken or do I oversee somthing?

  • ERROR: UndefinedMethod - lib/Service/CirclesService.php:61:21 - Method OCA\Circles\CirclesManager::startSuperSession does not exist

    • Other PR's like also fail, so probably not my fault :)
  • .

    1) OCA\Deck\Db\AssignmentMapperTest::testFind
    OCA\Deck\NoPermissionException: Creating boards has been disabled for your account.
    
    /home/runner/work/deck/deck/apps/deck/lib/Service/BoardService.php:316
    /home/runner/work/deck/deck/apps/deck/tests/integration/database/AssignmentMapperTest.php:98
    /home/runner/work/deck/deck/apps/deck/tests/integration/database/AssignmentMapperTest.php:93
    
  • Error: Your lock file does not contain a compatible set of packages. Please run composer update.
    (didn't modify the compose files)

Copy link
Member

@juliushaertl juliushaertl left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the pull request. This is a great start and I'm very sorry that it took so long to give some feedback. I had a first look at the code and the general approach. I've added some first remarks in the code.

I'll take some time the next days to setup notify_push locally so I can also give this a first test run.

Regarding the test failures, maybe you can rebase your changes. We had some CI failures lately but latest master should pass fine now.

lib/AppInfo/Application.php Outdated Show resolved Hide resolved
lib/AppInfo/Application.php Outdated Show resolved Hide resolved
lib/Controller/SessionController.php Show resolved Hide resolved
lib/Db/SessionMapper.php Outdated Show resolved Hide resolved
lib/Event/SessionClosedEvent.php Outdated Show resolved Hide resolved
src/components/Controls.vue Outdated Show resolved Hide resolved
src/components/board/Board.vue Outdated Show resolved Hide resolved
src/components/board/Board.vue Outdated Show resolved Hide resolved
src/components/board/Board.vue Outdated Show resolved Hide resolved
src/components/board/Board.vue Outdated Show resolved Hide resolved
@juliushaertl
Copy link
Member

Maybe to also kick of some discussion for the next steps, I'm not sure if you have thought about the live update process already, but there is probably a need for an improved approach from the refreshBoard that is currently happening. We already track and expose last modified dates for different elements so that might be an option so that the notify_push queue could advertise the last change date and the vuex store could refresh the content of just the affected items then.

@alangecker
Copy link
Collaborator Author

alangecker commented Aug 4, 2022

@juliushaertl
thanks for all the feedback 🙂
It is now rebased (hopefully fixing the CI issues) and I resolved some of the smaller points, will continue on it but maybe won't find much time in the next 2 weeks

@juliushaertl
Copy link
Member

Thanks for the update, looking forward to that :)

@matbgn
Copy link

matbgn commented Oct 4, 2022

@juliushaertl any plan for the review/merge of this highly awaited MR?

@alangecker
Copy link
Collaborator Author

I've added now some integration tests and would say that it is now ready to be reviewed from my side 🙂

@juliushaertl
Copy link
Member

Thanks, I'll have another look next week.

@matbgn
Copy link

matbgn commented Oct 28, 2022

@juliushaertl kindly reminder 😸 ❤️

@juliushaertl
Copy link
Member

Sorry for the delay, has been busy times 🙈 I'll schedule it next week again

@juliushaertl juliushaertl self-requested a review October 28, 2022 07:06
public function notifyAllSessions(IQueue $queue, int $boardId, $event, $excludeUserId, $body) {
$activeSessions = $this->sessionMapper->findAllActive($boardId);

foreach ($activeSessions as $session) {
Copy link
Member

Choose a reason for hiding this comment

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

What would be nice is if we can somehow pass the current session id over on each request from the frontend so that we do not push notifications for the sessions own changes.

Maybe we could wrap axios in some way so that the session (if present) is added as a header to all requests through https://axios-http.com/docs/config_defaults

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've added this now as proposed: ae6774f

It feels a bit hacky, but couldn't think about a more beautiful way. maybe someone has suggestions? 🙂

Copy link
Member

Choose a reason for hiding this comment

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

For the create session and close session events the initiating methods in the Session Service already have the token for the session that caused the event, but I guess for other changes taking the token from a HTTP header is the best approach. Nitpick: I would probably put the burden of finding out the token on the event emitting side, rather than always assuming that the current request is the source of truth. (Think e.g. when a change on board A triggers an automated change on board B in the distant future, then we wouldn't want to set the token from board A.)

alangecker and others added 23 commits January 3, 2023 12:43
Signed-off-by: chandi Langecker <git@chandi.it>
there is now no regular refreshing anymore, only after update events

Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Co-authored-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: chandi Langecker <git@chandi.it>
Co-authored-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: chandi Langecker <git@chandi.it>
Co-authored-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: chandi Langecker <git@chandi.it>
which resolves the dependency issue:
nextcloud-libraries/notify_push-client#5
(during the rebase the commit with an workaround got reverted nextcloud@5aa36aa)

Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: chandi Langecker <git@chandi.it>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
@juliushaertl
Copy link
Member

Pushed a commit to make the static analysis happy. Good to go from my side once CI is green 👍

@alangecker
Copy link
Collaborator Author

I've just created an issue for further discussions about the session closing/creation topic #4354
maybe someone is motivated to put some thinking effort into it? 🙃

@juliushaertl nice, big thanks for the commit, reviewing and everything else :)

@marcelklehr marcelklehr merged commit 5a97b0e into nextcloud:master Jan 3, 2023
@juliushaertl
Copy link
Member

Thanks a lot for your awesome contribution. So great to see the first part being merged. Keep up the great work. ❤️

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.

6 participants