logo

pleroma-fe

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

backend_interactor_service.js (1744B)


  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. const backendInteractorService = credentials => ({
  7. startFetchingTimeline ({ timeline, store, userId = false, listId = false, statusId = false, tag }) {
  8. return timelineFetcher.startFetching({ timeline, store, credentials, userId, listId, statusId, tag })
  9. },
  10. fetchTimeline (args) {
  11. return timelineFetcher.fetchAndUpdate({ ...args, credentials })
  12. },
  13. startFetchingNotifications ({ store }) {
  14. return notificationsFetcher.startFetching({ store, credentials })
  15. },
  16. fetchNotifications (args) {
  17. return notificationsFetcher.fetchAndUpdate({ ...args, credentials })
  18. },
  19. startFetchingFollowRequests ({ store }) {
  20. return followRequestFetcher.startFetching({ store, credentials })
  21. },
  22. startFetchingLists ({ store }) {
  23. return listsFetcher.startFetching({ store, credentials })
  24. },
  25. startUserSocket ({ store }) {
  26. const serv = store.rootState.instance.server.replace('http', 'ws')
  27. const url = serv + getMastodonSocketURI({ credentials, stream: 'user' })
  28. return ProcessedWS({ url, id: 'User' })
  29. },
  30. ...Object.entries(apiService).reduce((acc, [key, func]) => {
  31. return {
  32. ...acc,
  33. [key]: (args) => func({ credentials, ...args })
  34. }
  35. }, {}),
  36. verifyCredentials: apiService.verifyCredentials
  37. })
  38. export default backendInteractorService