logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://anongit.hacktivis.me/git/pleroma-fe.git/

backend_interactor_service.js (2010B)


  1. import apiService, { getMastodonSocketURI, ProcessedWS } from '../api/api.service.js'
  2. import timelineFetcher from '../timeline_fetcher/timeline_fetcher.service.js'
  3. import notificationsFetcher from '../notifications_fetcher/notifications_fetcher.service.js'
  4. import followRequestFetcher from '../../services/follow_request_fetcher/follow_request_fetcher.service'
  5. import listsFetcher from '../../services/lists_fetcher/lists_fetcher.service.js'
  6. import bookmarkFoldersFetcher from '../../services/bookmark_folders_fetcher/bookmark_folders_fetcher.service.js'
  7. const backendInteractorService = credentials => ({
  8. startFetchingTimeline ({ timeline, store, userId = false, listId = false, statusId = false, bookmarkFolderId = false, tag }) {
  9. return timelineFetcher.startFetching({ timeline, store, credentials, userId, listId, statusId, bookmarkFolderId, tag })
  10. },
  11. fetchTimeline (args) {
  12. return timelineFetcher.fetchAndUpdate({ ...args, credentials })
  13. },
  14. startFetchingNotifications ({ store }) {
  15. return notificationsFetcher.startFetching({ store, credentials })
  16. },
  17. fetchNotifications (args) {
  18. return notificationsFetcher.fetchAndUpdate({ ...args, credentials })
  19. },
  20. startFetchingFollowRequests ({ store }) {
  21. return followRequestFetcher.startFetching({ store, credentials })
  22. },
  23. startFetchingLists ({ store }) {
  24. return listsFetcher.startFetching({ store, credentials })
  25. },
  26. startFetchingBookmarkFolders ({ store }) {
  27. return bookmarkFoldersFetcher.startFetching({ store, credentials })
  28. },
  29. startUserSocket ({ store }) {
  30. const serv = store.rootState.instance.server.replace('http', 'ws')
  31. const url = getMastodonSocketURI({}, serv)
  32. return ProcessedWS({ url, id: 'Unified', credentials })
  33. },
  34. ...Object.entries(apiService).reduce((acc, [key, func]) => {
  35. return {
  36. ...acc,
  37. [key]: (args) => func({ credentials, ...args })
  38. }
  39. }, {}),
  40. verifyCredentials: apiService.verifyCredentials
  41. })
  42. export default backendInteractorService