2019-12-08 17:18:38 +00:00
|
|
|
import apiService, { getMastodonSocketURI, ProcessedWS } from '../api/api.service.js'
|
2021-01-13 20:17:10 +00:00
|
|
|
import timelineFetcher from '../timeline_fetcher/timeline_fetcher.service.js'
|
2019-04-03 16:04:46 +00:00
|
|
|
import notificationsFetcher from '../notifications_fetcher/notifications_fetcher.service.js'
|
2022-06-15 15:34:11 +00:00
|
|
|
import listsFetcher from '../../services/lists_fetcher/lists_fetcher.service.js'
|
2022-07-18 13:08:50 +00:00
|
|
|
import announcementsFetcher from '../../services/announcements_fetcher/announcements_fetcher.service.js'
|
2022-10-06 15:59:16 +00:00
|
|
|
import configFetcher from '../config_fetcher/config_fetcher.service.js'
|
2022-11-06 21:26:05 +00:00
|
|
|
import reportsFetcher from '../reports_fetcher/reports_fetcher.service.js'
|
2016-11-26 17:57:08 +00:00
|
|
|
|
2019-11-24 11:57:46 +00:00
|
|
|
const backendInteractorService = credentials => ({
|
2022-06-15 14:12:05 +00:00
|
|
|
startFetchingTimeline ({ timeline, store, userId = false, listId = false, tag }) {
|
|
|
|
return timelineFetcher.startFetching({ timeline, store, credentials, userId, listId, tag })
|
2021-01-13 20:17:10 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
fetchTimeline (args) {
|
|
|
|
return timelineFetcher.fetchAndUpdate({ ...args, credentials })
|
2019-11-24 11:57:46 +00:00
|
|
|
},
|
2019-04-04 16:03:56 +00:00
|
|
|
|
2019-11-24 11:57:46 +00:00
|
|
|
startFetchingNotifications ({ store }) {
|
2019-04-04 16:03:56 +00:00
|
|
|
return notificationsFetcher.startFetching({ store, credentials })
|
2019-11-24 11:57:46 +00:00
|
|
|
},
|
2017-02-16 10:17:47 +00:00
|
|
|
|
2022-10-06 15:59:16 +00:00
|
|
|
startFetchingConfig ({ store }) {
|
|
|
|
return configFetcher.startFetching({ store, credentials })
|
|
|
|
},
|
|
|
|
|
2021-01-13 20:17:10 +00:00
|
|
|
fetchNotifications (args) {
|
|
|
|
return notificationsFetcher.fetchAndUpdate({ ...args, credentials })
|
2019-11-24 11:57:46 +00:00
|
|
|
},
|
2019-05-08 03:36:35 +00:00
|
|
|
|
2022-06-15 15:34:11 +00:00
|
|
|
startFetchingLists ({ store }) {
|
|
|
|
return listsFetcher.startFetching({ store, credentials })
|
|
|
|
},
|
|
|
|
|
2022-07-18 13:08:50 +00:00
|
|
|
startFetchingAnnouncements ({ store }) {
|
|
|
|
return announcementsFetcher.startFetching({ store, credentials })
|
|
|
|
},
|
|
|
|
|
2022-11-06 21:26:05 +00:00
|
|
|
startFetchingReports ({ store, state, limit, page, pageSize }) {
|
|
|
|
return reportsFetcher.startFetching({ store, credentials, state, limit, page, pageSize })
|
|
|
|
},
|
|
|
|
|
2019-12-08 17:18:38 +00:00
|
|
|
startUserSocket ({ store }) {
|
2019-11-24 20:01:12 +00:00
|
|
|
const serv = store.rootState.instance.server.replace('http', 'ws')
|
2019-11-24 16:50:28 +00:00
|
|
|
const url = serv + getMastodonSocketURI({ credentials, stream: 'user' })
|
2019-12-08 17:18:38 +00:00
|
|
|
return ProcessedWS({ url, id: 'User' })
|
2019-11-24 16:50:28 +00:00
|
|
|
},
|
|
|
|
|
2022-08-30 13:37:36 +00:00
|
|
|
getSupportedTranslationlanguages ({ store }) {
|
|
|
|
return apiService.getSupportedTranslationlanguages({ store, credentials })
|
|
|
|
},
|
|
|
|
|
2019-11-24 11:57:46 +00:00
|
|
|
...Object.entries(apiService).reduce((acc, [key, func]) => {
|
|
|
|
return {
|
|
|
|
...acc,
|
|
|
|
[key]: (args) => func({ credentials, ...args })
|
|
|
|
}
|
|
|
|
}, {}),
|
2016-11-26 17:57:08 +00:00
|
|
|
|
2019-11-24 11:57:46 +00:00
|
|
|
verifyCredentials: apiService.verifyCredentials
|
|
|
|
})
|
2016-11-26 17:57:08 +00:00
|
|
|
|
|
|
|
export default backendInteractorService
|