From b5b81d2ae16b88899248c9ea73f6ca1c9104a06d Mon Sep 17 00:00:00 2001 From: Adrian Rudnik Date: Wed, 29 Nov 2023 17:19:40 +0100 Subject: [PATCH] Rework on pusher services (#39) --- frontend/src/components/auth/MyAvatar.vue | 4 +- frontend/src/components/auth/UserAvatar.vue | 32 --- frontend/src/components/parts/ActiveUsers.vue | 12 +- .../src/components/parts/ClientAvatar.vue | 40 ++++ .../search/SearchResultFocusDialog.vue | 19 +- frontend/src/locales/en.yaml | 6 +- frontend/src/plugins/api.ts | 7 + frontend/src/stores/session.ts | 50 ++-- frontend/src/stores/users.ts | 21 +- frontend/src/views/OtpAuthView.vue | 4 + frontend/src/websocket/index.ts | 17 +- frontend/src/websocket/messages/about_you.ts | 4 +- frontend/src/websocket/messages/global.ts | 24 +- .../src/websocket/messages/user_client.ts | 12 + .../src/websocket/messages/user_current.ts | 10 - .../src/websocket/messages/user_goodbye.ts | 4 +- .../src/websocket/messages/user_welcome.ts | 10 +- service/http/service.http | 132 +++++++++++ service/internal/access/auth.go | 77 ------ service/internal/access/errors.go | 6 - service/internal/auth/error.go | 5 + .../{access/logger.go => auth/log.go} | 2 +- service/internal/{access => auth}/otp.go | 22 +- service/internal/{access => auth}/password.go | 2 +- service/internal/auth/role.go | 7 + service/internal/auth/token.go | 100 ++++++++ service/internal/auth/user.go | 74 ++++++ .../{paths_linux.go => path_linux.go} | 0 .../collector/{paths_mac.go => path_mac.go} | 0 .../{paths_windows.go => path_windows.go} | 0 service/internal/config/config.go | 4 + service/internal/config/{types.go => type.go} | 31 ++- service/internal/device/endpoint.go | 40 ++++ service/internal/device/list.go | 55 +++++ service/internal/device/push3api/client.go | 59 +++++ service/internal/device/push3api/fat.go | 17 ++ .../config.go => device/push3api/types.go} | 2 +- service/internal/parser/{logger.go => log.go} | 0 service/internal/pusher/client.go | 79 +++++-- service/internal/pusher/guard.go | 31 +++ service/internal/pusher/guards.go | 19 -- .../pusher/{interfaces.go => interface.go} | 4 +- service/internal/pusher/{logger.go => log.go} | 0 service/internal/pusher/manager.go | 219 ++++++++++-------- service/internal/pusher/types.go | 4 - service/internal/pusher/user.go | 1 + service/internal/pusher/websocket.go | 20 +- service/internal/pushermsg/about_you.go | 25 -- .../{user_goodbye.go => client_goodbye.go} | 14 +- service/internal/pushermsg/client_id.go | 26 +++ service/internal/pushermsg/client_state.go | 53 +++++ service/internal/pushermsg/client_welcome.go | 40 ++++ .../internal/pushermsg/suggestion_created.go | 17 ++ service/internal/pushermsg/user_current.go | 43 ---- service/internal/pushermsg/user_welcome.go | 34 --- .../sourcer/abletonsrc/sample_ref_parser.go | 75 ++++-- .../sourcer/abletonsrc/sample_ref_xml.go | 50 +++- service/internal/stats/{logger.go => log.go} | 0 service/internal/stats/{stats.go => stat.go} | 0 service/internal/suggest/entry.go | 9 + service/internal/suggest/list.go | 55 +++++ service/internal/tagger/{logger.go => log.go} | 0 service/internal/ui/{logger.go => log.go} | 0 service/internal/ui/opener.go | 6 +- service/internal/util/anonymizer.go | 7 + service/internal/util/namelizer.go | 14 -- .../internal/webservice/{logger.go => log.go} | 0 .../internal/webservice/middleware_auth.go | 64 +++-- service/internal/webservice/push_client.go | 2 - service/internal/webservice/push_guard.go | 1 - service/internal/webservice/route_auth.go | 157 +++++++++++++ .../{routes_config.go => route_config.go} | 31 ++- .../webservice/{routes_os.go => route_os.go} | 10 +- service/internal/webservice/route_pusher.go | 24 ++ service/internal/webservice/route_suggest.go | 48 ++++ service/internal/webservice/route_user.go | 18 ++ service/internal/webservice/routes_access.go | 98 -------- service/internal/webservice/server.go | 23 +- service/internal/webservice/validation.go | 5 - .../internal/workload/{files.go => file.go} | 0 .../internal/workload/{pushes.go => push.go} | 0 service/main.go | 13 +- website/docs/search/api/users.md | 56 +++++ 83 files changed, 1629 insertions(+), 677 deletions(-) delete mode 100644 frontend/src/components/auth/UserAvatar.vue create mode 100644 frontend/src/components/parts/ClientAvatar.vue create mode 100644 frontend/src/websocket/messages/user_client.ts delete mode 100644 frontend/src/websocket/messages/user_current.ts create mode 100644 service/http/service.http delete mode 100644 service/internal/access/auth.go delete mode 100644 service/internal/access/errors.go create mode 100644 service/internal/auth/error.go rename service/internal/{access/logger.go => auth/log.go} (87%) rename service/internal/{access => auth}/otp.go (63%) rename service/internal/{access => auth}/password.go (97%) create mode 100644 service/internal/auth/role.go create mode 100644 service/internal/auth/token.go create mode 100644 service/internal/auth/user.go rename service/internal/collector/{paths_linux.go => path_linux.go} (100%) rename service/internal/collector/{paths_mac.go => path_mac.go} (100%) rename service/internal/collector/{paths_windows.go => path_windows.go} (100%) rename service/internal/config/{types.go => type.go} (89%) create mode 100644 service/internal/device/endpoint.go create mode 100644 service/internal/device/list.go create mode 100644 service/internal/device/push3api/client.go create mode 100644 service/internal/device/push3api/fat.go rename service/internal/{push3/config.go => device/push3api/types.go} (72%) rename service/internal/parser/{logger.go => log.go} (100%) create mode 100644 service/internal/pusher/guard.go delete mode 100644 service/internal/pusher/guards.go rename service/internal/pusher/{interfaces.go => interface.go} (78%) rename service/internal/pusher/{logger.go => log.go} (100%) delete mode 100644 service/internal/pusher/types.go create mode 100644 service/internal/pusher/user.go delete mode 100644 service/internal/pushermsg/about_you.go rename service/internal/pushermsg/{user_goodbye.go => client_goodbye.go} (50%) create mode 100644 service/internal/pushermsg/client_id.go create mode 100644 service/internal/pushermsg/client_state.go create mode 100644 service/internal/pushermsg/client_welcome.go create mode 100644 service/internal/pushermsg/suggestion_created.go delete mode 100644 service/internal/pushermsg/user_current.go delete mode 100644 service/internal/pushermsg/user_welcome.go rename service/internal/stats/{logger.go => log.go} (100%) rename service/internal/stats/{stats.go => stat.go} (100%) create mode 100644 service/internal/suggest/entry.go create mode 100644 service/internal/suggest/list.go rename service/internal/tagger/{logger.go => log.go} (100%) rename service/internal/ui/{logger.go => log.go} (100%) create mode 100644 service/internal/util/anonymizer.go rename service/internal/webservice/{logger.go => log.go} (100%) delete mode 100644 service/internal/webservice/push_client.go delete mode 100644 service/internal/webservice/push_guard.go create mode 100644 service/internal/webservice/route_auth.go rename service/internal/webservice/{routes_config.go => route_config.go} (84%) rename service/internal/webservice/{routes_os.go => route_os.go} (81%) create mode 100644 service/internal/webservice/route_pusher.go create mode 100644 service/internal/webservice/route_suggest.go create mode 100644 service/internal/webservice/route_user.go delete mode 100644 service/internal/webservice/routes_access.go delete mode 100644 service/internal/webservice/validation.go rename service/internal/workload/{files.go => file.go} (100%) rename service/internal/workload/{pushes.go => push.go} (100%) create mode 100644 website/docs/search/api/users.md diff --git a/frontend/src/components/auth/MyAvatar.vue b/frontend/src/components/auth/MyAvatar.vue index 315c1b0d..82e5ef00 100644 --- a/frontend/src/components/auth/MyAvatar.vue +++ b/frontend/src/components/auth/MyAvatar.vue @@ -8,7 +8,7 @@

- {{ username }} [{{ isAdmin ? t('role.admin') : t('role.guest') }}] + {{ displayName }} [{{ isAdmin ? t('role.admin') : t('role.guest') }}]