aboutsummaryrefslogtreecommitdiff
path: root/src/services
diff options
context:
space:
mode:
Diffstat (limited to 'src/services')
-rw-r--r--src/services/api/api.service.js4
-rw-r--r--src/services/entity_normalizer/entity_normalizer.service.js25
-rw-r--r--src/services/follow_manipulate/follow_manipulate.js15
-rw-r--r--src/services/notifications_fetcher/notifications_fetcher.service.js1
-rw-r--r--src/services/timeline_fetcher/timeline_fetcher.service.js2
5 files changed, 29 insertions, 18 deletions
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index 7db1d094..ee6bf151 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -496,7 +496,8 @@ const fetchTimeline = ({
userId = false,
tag = false,
withMuted = false,
- withMove = false
+ withMove = false,
+ withRelationships = false
}) => {
const timelineUrls = {
public: MASTODON_PUBLIC_TIMELINE,
@@ -542,6 +543,7 @@ const fetchTimeline = ({
params.push(['count', 20])
params.push(['with_muted', withMuted])
+ params.push(['with_relationships', withRelationships])
const queryString = map(params, (param) => `${param[0]}=${param[1]}`).join('&')
url += `?${queryString}`
diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js
index 84169a7b..97f9f2ae 100644
--- a/src/services/entity_normalizer/entity_normalizer.service.js
+++ b/src/services/entity_normalizer/entity_normalizer.service.js
@@ -73,7 +73,7 @@ export const parseUser = (data) => {
output.background_image = data.pleroma.background_image
output.token = data.pleroma.chat_token
- if (relationship) {
+ if (relationship && !relationship) {
output.follows_you = relationship.followed_by
output.requested = relationship.requested
output.following = relationship.following
@@ -82,6 +82,9 @@ export const parseUser = (data) => {
output.showing_reblogs = relationship.showing_reblogs
output.subscribed = relationship.subscribing
}
+ if (relationship) {
+ output.relationship = relationship
+ }
output.allow_following_move = data.pleroma.allow_following_move
@@ -137,16 +140,10 @@ export const parseUser = (data) => {
output.statusnet_profile_url = data.statusnet_profile_url
- output.statusnet_blocking = data.statusnet_blocking
-
output.is_local = data.is_local
output.role = data.role
output.show_role = data.show_role
- output.follows_you = data.follows_you
-
- output.muted = data.muted
-
if (data.rights) {
output.rights = {
moderator: data.rights.delete_others_notice,
@@ -160,10 +157,16 @@ export const parseUser = (data) => {
output.hide_follows_count = data.hide_follows_count
output.hide_followers_count = data.hide_followers_count
output.background_image = data.background_image
- // on mastoapi this info is contained in a "relationship"
- output.following = data.following
// Websocket token
output.token = data.token
+
+ // Convert relationsip data to expected format
+ output.relationship = {
+ muting: data.muted,
+ blocking: data.statusnet_blocking,
+ followed_by: data.follows_you,
+ following: data.following
+ }
}
output.created_at = new Date(data.created_at)
@@ -317,6 +320,9 @@ export const parseStatus = (data) => {
? String(output.in_reply_to_user_id)
: null
+ if (data.account.pleroma.relationship) {
+ data.account.pleroma.relationship = undefined
+ }
output.user = parseUser(masto ? data.account : data.user)
output.attentions = ((masto ? data.mentions : data.attentions) || []).map(parseUser)
@@ -342,7 +348,6 @@ export const parseNotification = (data) => {
}
const masto = !data.hasOwnProperty('ntype')
const output = {}
-
if (masto) {
output.type = mastoDict[data.type] || data.type
output.seen = data.pleroma.is_seen
diff --git a/src/services/follow_manipulate/follow_manipulate.js b/src/services/follow_manipulate/follow_manipulate.js
index 29b38a0f..c5d86afa 100644
--- a/src/services/follow_manipulate/follow_manipulate.js
+++ b/src/services/follow_manipulate/follow_manipulate.js
@@ -1,15 +1,18 @@
-const fetchUser = (attempt, user, store) => new Promise((resolve, reject) => {
+const fetchRelationship = (attempt, user, store) => new Promise((resolve, reject) => {
setTimeout(() => {
- store.state.api.backendInteractor.fetchUser({ id: user.id })
- .then((user) => store.commit('addNewUsers', [user]))
- .then(() => resolve([user.following, user.requested, user.locked, attempt]))
+ store.state.api.backendInteractor.fetchUserRelationship({ id: user.id })
+ .then((relationship) => {
+ store.commit('updateUserRelationship', [relationship])
+ return relationship
+ })
+ .then((relationship) => resolve([relationship.following, relationship.requested, user.locked, attempt]))
.catch((e) => reject(e))
}, 500)
}).then(([following, sent, locked, attempt]) => {
if (!following && !(locked && sent) && attempt <= 3) {
// If we BE reports that we still not following that user - retry,
// increment attempts by one
- fetchUser(++attempt, user, store)
+ fetchRelationship(++attempt, user, store)
}
})
@@ -31,7 +34,7 @@ export const requestFollow = (user, store) => new Promise((resolve, reject) => {
// don't know that yet.
// Recursive Promise, it will call itself up to 3 times.
- return fetchUser(1, user, store)
+ return fetchRelationship(1, user, store)
.then(() => {
resolve()
})
diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js
index 864e32f8..eb6d84c4 100644
--- a/src/services/notifications_fetcher/notifications_fetcher.service.js
+++ b/src/services/notifications_fetcher/notifications_fetcher.service.js
@@ -48,7 +48,6 @@ const fetchNotifications = ({ store, args, older }) => {
update({ store, notifications, older })
return notifications
}, () => store.dispatch('setNotificationsError', { value: true }))
- .catch(() => store.dispatch('setNotificationsError', { value: true }))
}
const startFetching = ({ credentials, store }) => {
diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js
index c6b28ad5..96fafff9 100644
--- a/src/services/timeline_fetcher/timeline_fetcher.service.js
+++ b/src/services/timeline_fetcher/timeline_fetcher.service.js
@@ -31,6 +31,7 @@ const fetchAndUpdate = ({
const { getters } = store
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
const hideMutedPosts = getters.mergedConfig.hideMutedPosts
+ const replyVisibility = getters.mergedConfig.replyVisibility
if (older) {
args['until'] = until || timelineData.minId
@@ -41,6 +42,7 @@ const fetchAndUpdate = ({
args['userId'] = userId
args['tag'] = tag
args['withMuted'] = !hideMutedPosts
+ args['withRelationships'] = replyVisibility === 'following'
const numStatusesBeforeFetch = timelineData.statuses.length