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'
|
2019-11-19 14:07:15 +00:00
|
|
|
import followRequestFetcher from '../../services/follow_request_fetcher/follow_request_fetcher.service'
|
2022-06-15 15:34:11 +00:00
|
|
|
import listsFetcher from '../../services/lists_fetcher/lists_fetcher.service.js'
|
2022-07-18 11:31:43 +00:00
|
|
|
import announcementsFetcher from '../../services/announcements_fetcher/announcements_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
|
|
|
|
2021-01-13 20:17:10 +00:00
|
|
|
fetchNotifications (args) {
|
|
|
|
return notificationsFetcher.fetchAndUpdate({ ...args, credentials })
|
|
|
|
},
|
|
|
|
|
2020-01-21 15:51:49 +00:00
|
|
|
startFetchingFollowRequests ({ store }) {
|
2019-11-19 14:07:15 +00:00
|
|
|
return followRequestFetcher.startFetching({ store, 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 11:31:43 +00:00
|
|
|
startFetchingAnnouncements ({ store }) {
|
|
|
|
return announcementsFetcher.startFetching({ store, credentials })
|
|
|
|
},
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
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
|