Merge branch 'api-refactor' into shigusegubu-themes3
This commit is contained in:
commit
59d3aaadef
32 changed files with 101 additions and 124 deletions
|
|
@ -106,6 +106,8 @@ export const promisedRequest = async ({
|
||||||
.get('content-type')
|
.get('content-type')
|
||||||
.split(';')
|
.split(';')
|
||||||
.map((x) => x.toLowerCase().trim())
|
.map((x) => x.toLowerCase().trim())
|
||||||
|
const contentLength = parseInt(response.headers.get('content-length'))
|
||||||
|
if (contentLength === 0) return null
|
||||||
|
|
||||||
switch (contentType) {
|
switch (contentType) {
|
||||||
case 'text/plain':
|
case 'text/plain':
|
||||||
|
|
@ -130,8 +132,7 @@ export const promisedRequest = async ({
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new StatusCodeError(
|
throw new Error(
|
||||||
response.status,
|
|
||||||
error,
|
error,
|
||||||
{ url, options },
|
{ url, options },
|
||||||
response,
|
response,
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ const MASTODON_STATUS_CONTEXT_URL = (id) => `/api/v1/statuses/${id}/context`
|
||||||
const MASTODON_STATUS_SOURCE_URL = (id) => `/api/v1/statuses/${id}/source`
|
const MASTODON_STATUS_SOURCE_URL = (id) => `/api/v1/statuses/${id}/source`
|
||||||
const MASTODON_STATUS_HISTORY_URL = (id) => `/api/v1/statuses/${id}/history`
|
const MASTODON_STATUS_HISTORY_URL = (id) => `/api/v1/statuses/${id}/history`
|
||||||
const MASTODON_USER_URL = '/api/v1/accounts'
|
const MASTODON_USER_URL = '/api/v1/accounts'
|
||||||
const MASTODON_USER_LOOKUP_URL = '/api/v1/accounts/lookup'
|
const MASTODON_USER_LOOKUP_URL = ({ acct }) => `/api/v1/accounts/lookup${paramsString({ acct })}`
|
||||||
const MASTODON_POLL_URL = (id = '') => `/api/v1/polls/${id}`
|
const MASTODON_POLL_URL = (id = '') => `/api/v1/polls/${id}`
|
||||||
const MASTODON_STATUS_FAVORITEDBY_URL = (id) =>
|
const MASTODON_STATUS_FAVORITEDBY_URL = (id) =>
|
||||||
`/api/v1/statuses/${id}/favourited_by`
|
`/api/v1/statuses/${id}/favourited_by`
|
||||||
|
|
@ -194,9 +194,8 @@ export const fetchUser = ({ id, credentials }) =>
|
||||||
|
|
||||||
export const fetchUserByName = ({ name, credentials }) =>
|
export const fetchUserByName = ({ name, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_USER_LOOKUP_URL,
|
url: MASTODON_USER_LOOKUP_URL({ acct: name }),
|
||||||
credentials,
|
credentials,
|
||||||
params: { acct: name },
|
|
||||||
})
|
})
|
||||||
.then(({ data }) => data.id)
|
.then(({ data }) => data.id)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|
@ -274,10 +273,10 @@ export const fetchStatusHistory = ({ status, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_STATUS_HISTORY_URL(status.id),
|
url: MASTODON_STATUS_HISTORY_URL(status.id),
|
||||||
credentials,
|
credentials,
|
||||||
}).then(({ data }) => {
|
}).then(({ data, ...rest }) => {
|
||||||
return [...data].reverse().map((item) => {
|
return [...data].reverse().map((item) => {
|
||||||
item.originalStatus = status
|
item.originalStatus = status
|
||||||
return parseStatus(item)
|
return { ...rest, data: parseStatus(item) }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -313,6 +312,7 @@ export const fetchTimeline = ({
|
||||||
|
|
||||||
notifications: MASTODON_USER_NOTIFICATIONS_URL,
|
notifications: MASTODON_USER_NOTIFICATIONS_URL,
|
||||||
}
|
}
|
||||||
|
const urlFunc = timelineUrls[timeline]
|
||||||
|
|
||||||
const twoArgs = new Set([
|
const twoArgs = new Set([
|
||||||
'user',
|
'user',
|
||||||
|
|
@ -346,8 +346,6 @@ export const fetchTimeline = ({
|
||||||
|
|
||||||
const isNotifications = timeline === 'notifications'
|
const isNotifications = timeline === 'notifications'
|
||||||
|
|
||||||
const urlFunc = timelineUrls[timeline]
|
|
||||||
|
|
||||||
if (timeline === 'media') {
|
if (timeline === 'media') {
|
||||||
params.onlyMedia = true
|
params.onlyMedia = true
|
||||||
}
|
}
|
||||||
|
|
@ -364,7 +362,7 @@ export const fetchTimeline = ({
|
||||||
params.folderId = bookmarkFolderId
|
params.folderId = bookmarkFolderId
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNotifications && includeTypes.size > 0) {
|
if (isNotifications && includeTypes.length > 0) {
|
||||||
params.includeTypes = includeTypes
|
params.includeTypes = includeTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ const BookmarkFolderEdit = {
|
||||||
|
|
||||||
fetchBookmarkFolders({
|
fetchBookmarkFolders({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((folders) => {
|
}).then(({ data: folders }) => {
|
||||||
const folder = folders.find((folder) => folder.id === this.id)
|
const folder = folders.find((folder) => folder.id === this.id)
|
||||||
if (!folder) return
|
if (!folder) return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ const Chat = {
|
||||||
maxId,
|
maxId,
|
||||||
sinceId,
|
sinceId,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((messages) => {
|
}).then(({ data: messages }) => {
|
||||||
// Clear the current chat in case we're recovering from a ws connection loss.
|
// Clear the current chat in case we're recovering from a ws connection loss.
|
||||||
if (isFirstFetch) {
|
if (isFirstFetch) {
|
||||||
chatService.clear(chatMessageService)
|
chatService.clear(chatMessageService)
|
||||||
|
|
@ -310,10 +310,11 @@ const Chat = {
|
||||||
let chat = this.findOpenedChatByRecipientId(this.recipientId)
|
let chat = this.findOpenedChatByRecipientId(this.recipientId)
|
||||||
if (!chat) {
|
if (!chat) {
|
||||||
try {
|
try {
|
||||||
chat = await getOrCreateChat({
|
const { data } = await getOrCreateChat({
|
||||||
accountId: this.recipientId,
|
accountId: this.recipientId,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
|
chat = data
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error creating or getting a chat', e)
|
console.error('Error creating or getting a chat', e)
|
||||||
this.errorLoadingChat = true
|
this.errorLoadingChat = true
|
||||||
|
|
@ -383,7 +384,7 @@ const Chat = {
|
||||||
params,
|
params,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then(({ data }) => {
|
||||||
this.$store.dispatch('addChatMessages', {
|
this.$store.dispatch('addChatMessages', {
|
||||||
chatId: this.currentChat.id,
|
chatId: this.currentChat.id,
|
||||||
updateMaxId: false,
|
updateMaxId: false,
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ const LoginForm = {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
if (error === 'mfa_required') {
|
if (error.errorData?.error === 'mfa_required') {
|
||||||
this.requireMFA({ settings: error })
|
this.requireMFA({ settings: error })
|
||||||
} else if (error.identifier === 'password_reset_required') {
|
} else if (error.identifier === 'password_reset_required') {
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
|
|
|
||||||
|
|
@ -635,11 +635,6 @@ const PostStatusForm = {
|
||||||
// Don't apply preview if not loading, because it means
|
// Don't apply preview if not loading, because it means
|
||||||
// user has closed the preview manually.
|
// user has closed the preview manually.
|
||||||
if (!this.previewLoading) return
|
if (!this.previewLoading) return
|
||||||
if (!data.error) {
|
|
||||||
this.preview = data
|
|
||||||
} else {
|
|
||||||
this.preview = { error: data.error }
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.preview = { error }
|
this.preview = { error }
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ const RemoteUserResolver = {
|
||||||
id,
|
id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
.then((externalUser) => {
|
.then(({ data: externalUser }) => {
|
||||||
if (externalUser.error) {
|
if (externalUser.error) {
|
||||||
this.error = true
|
this.error = true
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -490,7 +490,7 @@ const AppearanceTab = {
|
||||||
background,
|
background,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then(({ data }) => {
|
||||||
this.$store.commit('addNewUsers', [data])
|
this.$store.commit('addNewUsers', [data])
|
||||||
this.$store.commit('setCurrentUser', data)
|
this.$store.commit('setCurrentUser', data)
|
||||||
this.backgroundPreview = null
|
this.backgroundPreview = null
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ const ComposingTab = {
|
||||||
updateProfile({
|
updateProfile({
|
||||||
params,
|
params,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((user) => {
|
}).then(({ data: user }) => {
|
||||||
this.$store.commit('addNewUsers', [user])
|
this.$store.commit('addNewUsers', [user])
|
||||||
this.$store.commit('setCurrentUser', user)
|
this.$store.commit('setCurrentUser', user)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ const DataImportExportTab = {
|
||||||
return importFollows({
|
return importFollows({
|
||||||
file,
|
file,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) => {
|
}).then(({ data: status }) => {
|
||||||
if (!status) {
|
if (!status) {
|
||||||
throw new Error('failed')
|
throw new Error('failed')
|
||||||
}
|
}
|
||||||
|
|
@ -74,7 +74,7 @@ const DataImportExportTab = {
|
||||||
return importBlocks({
|
return importBlocks({
|
||||||
file,
|
file,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) => {
|
}).then(({ data: status }) => {
|
||||||
if (!status) {
|
if (!status) {
|
||||||
throw new Error('failed')
|
throw new Error('failed')
|
||||||
}
|
}
|
||||||
|
|
@ -84,13 +84,13 @@ const DataImportExportTab = {
|
||||||
return importMutes({
|
return importMutes({
|
||||||
file,
|
file,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) => {
|
}).then(({ data: status }) => {
|
||||||
if (!status) {
|
if (!status) {
|
||||||
throw new Error('failed')
|
throw new Error('failed')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
generateExportableUsersContent(users) {
|
generateExportableUsersContent({ data: users }) {
|
||||||
// Get addresses
|
// Get addresses
|
||||||
return users
|
return users
|
||||||
.map((user) => {
|
.map((user) => {
|
||||||
|
|
@ -121,7 +121,7 @@ const DataImportExportTab = {
|
||||||
listBackups({
|
listBackups({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then(({ data: res }) => {
|
||||||
this.backups = res
|
this.backups = res
|
||||||
this.listBackupsError = false
|
this.listBackupsError = false
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ const GeneralTab = {
|
||||||
updateProfile({
|
updateProfile({
|
||||||
params,
|
params,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((user) => {
|
}).then(({ data: user }) => {
|
||||||
this.$store.commit('addNewUsers', [user])
|
this.$store.commit('addNewUsers', [user])
|
||||||
this.$store.commit('setCurrentUser', user)
|
this.$store.commit('setCurrentUser', user)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ const MutesAndBlocks = {
|
||||||
return importFollows({
|
return importFollows({
|
||||||
file,
|
file,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) => {
|
}).then(({ data: status }) => {
|
||||||
if (!status) {
|
if (!status) {
|
||||||
throw new Error('failed')
|
throw new Error('failed')
|
||||||
}
|
}
|
||||||
|
|
@ -70,7 +70,7 @@ const MutesAndBlocks = {
|
||||||
return importBlocks({
|
return importBlocks({
|
||||||
file,
|
file,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) => {
|
}).then(({ data: status }) => {
|
||||||
if (!status) {
|
if (!status) {
|
||||||
throw new Error('failed')
|
throw new Error('failed')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ const ProfileTab = {
|
||||||
params,
|
params,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
.then((user) => {
|
.then(({ data: user }) => {
|
||||||
this.$store.commit('addNewUsers', [user])
|
this.$store.commit('addNewUsers', [user])
|
||||||
this.$store.commit('setCurrentUser', user)
|
this.$store.commit('setCurrentUser', user)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ const Mfa = {
|
||||||
|
|
||||||
return generateMfaBackupCodes({
|
return generateMfaBackupCodes({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((res) => {
|
}).then(({ data: res }) => {
|
||||||
this.backupCodes.codes = res.codes
|
this.backupCodes.codes = res.codes
|
||||||
this.backupCodes.inProgress = false
|
this.backupCodes.inProgress = false
|
||||||
})
|
})
|
||||||
|
|
@ -122,7 +122,7 @@ const Mfa = {
|
||||||
this.setupState.setupOTPState = 'prepare'
|
this.setupState.setupOTPState = 'prepare'
|
||||||
mfaSetupOTP({
|
mfaSetupOTP({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((res) => {
|
}).then(({ data: res }) => {
|
||||||
this.otpSettings = res
|
this.otpSettings = res
|
||||||
this.setupState.setupOTPState = 'confirm'
|
this.setupState.setupOTPState = 'confirm'
|
||||||
})
|
})
|
||||||
|
|
@ -134,13 +134,13 @@ const Mfa = {
|
||||||
token: this.otpConfirmToken,
|
token: this.otpConfirmToken,
|
||||||
password: this.currentPassword,
|
password: this.currentPassword,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((res) => {
|
|
||||||
if (res.error) {
|
|
||||||
this.error = res.error
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.completeSetup()
|
|
||||||
})
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.completeSetup()
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
this.error = error
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
completeSetup() {
|
completeSetup() {
|
||||||
|
|
@ -161,7 +161,7 @@ const Mfa = {
|
||||||
|
|
||||||
// fetch settings from server
|
// fetch settings from server
|
||||||
async fetchSettings() {
|
async fetchSettings() {
|
||||||
const result = await settingsMFA({
|
const { data: result } = await settingsMFA({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
if (result.error) return
|
if (result.error) return
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ export default {
|
||||||
mfaDisableOTP({
|
mfaDisableOTP({
|
||||||
password: this.currentPassword,
|
password: this.currentPassword,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((res) => {
|
}).then(({ data: res }) => {
|
||||||
this.inProgress = false
|
this.inProgress = false
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
this.error = res.error
|
this.error = res.error
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ const SecurityTab = {
|
||||||
deleteAccount({
|
deleteAccount({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
password: this.deleteAccountConfirmPasswordInput,
|
password: this.deleteAccountConfirmPasswordInput,
|
||||||
}).then((res) => {
|
}).then(({ data: res }) => {
|
||||||
if (res.status === 'success') {
|
if (res.status === 'success') {
|
||||||
this.$store.dispatch('logout')
|
this.$store.dispatch('logout')
|
||||||
this.$router.push({ name: 'root' })
|
this.$router.push({ name: 'root' })
|
||||||
|
|
@ -94,7 +94,7 @@ const SecurityTab = {
|
||||||
newPasswordConfirmation: this.changePasswordInputs[2],
|
newPasswordConfirmation: this.changePasswordInputs[2],
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}
|
}
|
||||||
changePassword(params).then((res) => {
|
changePassword(params).then(({ data: res }) => {
|
||||||
if (res.status === 'success') {
|
if (res.status === 'success') {
|
||||||
this.changedPassword = true
|
this.changedPassword = true
|
||||||
this.changePasswordError = false
|
this.changePasswordError = false
|
||||||
|
|
@ -111,7 +111,7 @@ const SecurityTab = {
|
||||||
password: this.changeEmailPassword,
|
password: this.changeEmailPassword,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}
|
}
|
||||||
changeEmail(params).then((res) => {
|
changeEmail(params).then(({ data: res }) => {
|
||||||
if (res.status === 'success') {
|
if (res.status === 'success') {
|
||||||
this.changedEmail = true
|
this.changedEmail = true
|
||||||
this.changeEmailError = false
|
this.changeEmailError = false
|
||||||
|
|
@ -127,7 +127,7 @@ const SecurityTab = {
|
||||||
password: this.moveAccountPassword,
|
password: this.moveAccountPassword,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}
|
}
|
||||||
moveAccount(params).then((res) => {
|
moveAccount(params).then(({ data: res }) => {
|
||||||
if (res.status === 'success') {
|
if (res.status === 'success') {
|
||||||
this.movedAccount = true
|
this.movedAccount = true
|
||||||
this.moveAccountError = false
|
this.moveAccountError = false
|
||||||
|
|
@ -163,7 +163,7 @@ const SecurityTab = {
|
||||||
listAliases({
|
listAliases({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then(({ data: res }) => {
|
||||||
this.aliases = res.aliases
|
this.aliases = res.aliases
|
||||||
this.listAliasesError = false
|
this.listAliasesError = false
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -600,7 +600,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateProfile({ params })
|
updateProfile({ params })
|
||||||
.then((user) => {
|
.then(({ data: user }) => {
|
||||||
this.newFields.splice(this.newFields.length)
|
this.newFields.splice(this.newFields.length)
|
||||||
merge(this.newFields, user.fields)
|
merge(this.newFields, user.fields)
|
||||||
this.$store.commit('addNewUsers', [user])
|
this.$store.commit('addNewUsers', [user])
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const WhoToFollow = {
|
||||||
fetchUser({
|
fetchUser({
|
||||||
id,
|
id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((externalUser) => {
|
}).then(({ data: externalUser }) => {
|
||||||
if (!externalUser.error) {
|
if (!externalUser.error) {
|
||||||
this.$store.commit('addNewUsers', [externalUser])
|
this.$store.commit('addNewUsers', [externalUser])
|
||||||
this.users.push(externalUser)
|
this.users.push(externalUser)
|
||||||
|
|
@ -34,7 +34,7 @@ const WhoToFollow = {
|
||||||
getWhoToFollow() {
|
getWhoToFollow() {
|
||||||
const credentials = useOAuthStore().token
|
const credentials = useOAuthStore().token
|
||||||
if (credentials) {
|
if (credentials) {
|
||||||
suggestions({ credentials }).then((reply) => {
|
suggestions({ credentials }).then(({ data: reply }) => {
|
||||||
this.showWhoToFollow(reply)
|
this.showWhoToFollow(reply)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ function showWhoToFollow(panel, reply) {
|
||||||
fetchUser({
|
fetchUser({
|
||||||
id: name,
|
id: name,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((externalUser) => {
|
}).then(({ data: externalUser }) => {
|
||||||
if (!externalUser.error) {
|
if (!externalUser.error) {
|
||||||
panel.$store.commit('addNewUsers', [externalUser])
|
panel.$store.commit('addNewUsers', [externalUser])
|
||||||
toFollow.id = externalUser.id
|
toFollow.id = externalUser.id
|
||||||
|
|
@ -36,7 +36,7 @@ function getWhoToFollow(panel) {
|
||||||
panel.usersToFollow.forEach((toFollow) => {
|
panel.usersToFollow.forEach((toFollow) => {
|
||||||
toFollow.name = 'Loading...'
|
toFollow.name = 'Loading...'
|
||||||
})
|
})
|
||||||
suggestions({ credentials }).then((reply) => {
|
suggestions({ credentials }).then(({ data: reply }) => {
|
||||||
showWhoToFollow(panel, reply)
|
showWhoToFollow(panel, reply)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ const defaultApi = ({ rootState, commit }, { path, value }) => {
|
||||||
return updateProfile({
|
return updateProfile({
|
||||||
params,
|
params,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((result) => {
|
}).then(({ data: result }) => {
|
||||||
commit('addNewUsers', [result])
|
commit('addNewUsers', [result])
|
||||||
commit('setCurrentUser', result)
|
commit('setCurrentUser', result)
|
||||||
})
|
})
|
||||||
|
|
@ -22,7 +22,7 @@ const notificationsApi = ({ rootState, commit }, { path, value, oldValue }) => {
|
||||||
return updateNotificationSettings({
|
return updateNotificationSettings({
|
||||||
settings,
|
settings,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((result) => {
|
}).then(({ data: result }) => {
|
||||||
if (result.status === 'success') {
|
if (result.status === 'success') {
|
||||||
commit('confirmProfileOption', { name, value })
|
commit('confirmProfileOption', { name, value })
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,10 @@ function humanizeErrors(errors) {
|
||||||
export function StatusCodeError(statusCode, body, options, response) {
|
export function StatusCodeError(statusCode, body, options, response) {
|
||||||
this.name = 'StatusCodeError'
|
this.name = 'StatusCodeError'
|
||||||
this.statusCode = statusCode
|
this.statusCode = statusCode
|
||||||
this.message =
|
this.statusText = body.error.error || body.error
|
||||||
statusCode + ' - ' + (JSON && JSON.stringify ? JSON.stringify(body) : body)
|
this.details = JSON && JSON.stringify ? JSON.stringify(body) : body
|
||||||
|
this.errorData = body.error
|
||||||
|
this.message = statusCode + ' - ' + statusText
|
||||||
this.error = body // legacy attribute
|
this.error = body // legacy attribute
|
||||||
this.options = options
|
this.options = options
|
||||||
this.response = response
|
this.response = response
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { promiseInterval } from 'src/services/promise_interval/promise_interval.
|
||||||
const fetchAndUpdate = ({ store, credentials }) => {
|
const fetchAndUpdate = ({ store, credentials }) => {
|
||||||
return fetchFollowRequests({ credentials })
|
return fetchFollowRequests({ credentials })
|
||||||
.then(
|
.then(
|
||||||
(requests) => {
|
({ data: requests }) => {
|
||||||
store.commit('setFollowRequests', requests)
|
store.commit('setFollowRequests', requests)
|
||||||
store.commit('addNewUsers', requests)
|
store.commit('addNewUsers', requests)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -83,27 +83,23 @@ const fetchAndUpdate = ({ store, credentials, older = false, sinceId }) => {
|
||||||
const fetchNotifications = ({ store, args, older }) => {
|
const fetchNotifications = ({ store, args, older }) => {
|
||||||
return fetchTimeline(args)
|
return fetchTimeline(args)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.errors) {
|
|
||||||
if (
|
|
||||||
response.status === 400 &&
|
|
||||||
response.statusText.includes('Invalid value for enum')
|
|
||||||
) {
|
|
||||||
response.statusText
|
|
||||||
.matchAll(/(\w+) - Invalid value for enum./g)
|
|
||||||
.toArray()
|
|
||||||
.map((x) => x[1])
|
|
||||||
.forEach((x) => mastoApiNotificationTypes.delete(x))
|
|
||||||
return fetchNotifications({ store, args, older })
|
|
||||||
} else {
|
|
||||||
throw new Error(`${response.status} ${response.statusText}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const notifications = response.data
|
const notifications = response.data
|
||||||
update({ store, notifications, older })
|
update({ store, notifications, older })
|
||||||
return notifications
|
return notifications
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
if (
|
||||||
|
error.statusCode === 400 &&
|
||||||
|
error.statusText.includes('Invalid value for enum')
|
||||||
|
) {
|
||||||
|
error.statusText
|
||||||
|
.matchAll(/(\w+) - Invalid value for enum./g)
|
||||||
|
.toArray()
|
||||||
|
.map((x) => x[1])
|
||||||
|
.forEach((x) => mastoApiNotificationTypes.delete(x))
|
||||||
|
return fetchNotifications({ store, args, older })
|
||||||
|
}
|
||||||
|
|
||||||
useInterfaceStore().pushGlobalNotice({
|
useInterfaceStore().pushGlobalNotice({
|
||||||
level: 'error',
|
level: 'error',
|
||||||
messageKey: 'notifications.error',
|
messageKey: 'notifications.error',
|
||||||
|
|
|
||||||
|
|
@ -36,24 +36,16 @@ const postStatus = ({
|
||||||
poll,
|
poll,
|
||||||
preview,
|
preview,
|
||||||
idempotencyKey,
|
idempotencyKey,
|
||||||
|
}).then(({ data }) => {
|
||||||
|
if (!preview) store.dispatch('addNewStatuses', {
|
||||||
|
statuses: [data],
|
||||||
|
timeline: 'friends',
|
||||||
|
showImmediately: true,
|
||||||
|
noIdUpdate: true, // To prevent missing notices on next pull.
|
||||||
|
})
|
||||||
|
|
||||||
|
return data
|
||||||
})
|
})
|
||||||
.then(({ data }) => {
|
|
||||||
if (preview) return data
|
|
||||||
|
|
||||||
store.dispatch('addNewStatuses', {
|
|
||||||
statuses: [data],
|
|
||||||
timeline: 'friends',
|
|
||||||
showImmediately: true,
|
|
||||||
noIdUpdate: true, // To prevent missing notices on next pull.
|
|
||||||
})
|
|
||||||
|
|
||||||
return data
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
return {
|
|
||||||
error: err.message,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const editStatus = ({
|
const editStatus = ({
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,11 @@ const fetchAndUpdate = ({
|
||||||
timeline = 'friends',
|
timeline = 'friends',
|
||||||
older = false,
|
older = false,
|
||||||
showImmediately = false,
|
showImmediately = false,
|
||||||
userId = false,
|
userId,
|
||||||
listId = false,
|
listId,
|
||||||
statusId = false,
|
statusId,
|
||||||
bookmarkFolderId = false,
|
bookmarkFolderId,
|
||||||
tag = false,
|
tag,
|
||||||
maxId,
|
maxId,
|
||||||
sinceId,
|
sinceId,
|
||||||
}) => {
|
}) => {
|
||||||
|
|
@ -52,7 +52,8 @@ const fetchAndUpdate = ({
|
||||||
const loggedIn = !!rootState.users.currentUser
|
const loggedIn = !!rootState.users.currentUser
|
||||||
|
|
||||||
if (older) {
|
if (older) {
|
||||||
args.maxId = maxId || timelineData.minId
|
// When minId = 0 we need to fetch without maxId param
|
||||||
|
args.maxId = maxId || timelineData.minId || null
|
||||||
} else {
|
} else {
|
||||||
if (sinceId === undefined) {
|
if (sinceId === undefined) {
|
||||||
args.sinceId = timelineData.maxId
|
args.sinceId = timelineData.maxId
|
||||||
|
|
@ -78,14 +79,6 @@ const fetchAndUpdate = ({
|
||||||
|
|
||||||
return fetchTimeline(args)
|
return fetchTimeline(args)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.errors) {
|
|
||||||
if (timeline === 'favorites') {
|
|
||||||
useInstanceCapabilitiesStore().pleromaPublicFavouritesAvailable = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
throw new Error(`${response.status} ${response.statusText}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const { data: statuses, pagination } = response
|
const { data: statuses, pagination } = response
|
||||||
if (
|
if (
|
||||||
!older &&
|
!older &&
|
||||||
|
|
@ -107,6 +100,10 @@ const fetchAndUpdate = ({
|
||||||
return { statuses, pagination }
|
return { statuses, pagination }
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
if (error.statusCode === 403 && timeline === 'favorites') {
|
||||||
|
useInstanceCapabilitiesStore().pleromaPublicFavouritesAvailable = false
|
||||||
|
return
|
||||||
|
}
|
||||||
useInterfaceStore().pushGlobalNotice({
|
useInterfaceStore().pushGlobalNotice({
|
||||||
level: 'error',
|
level: 'error',
|
||||||
messageKey: 'timeline.error',
|
messageKey: 'timeline.error',
|
||||||
|
|
|
||||||
|
|
@ -601,7 +601,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
}).then(({ data }) => data)
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
deleteEmojiPack({ name }) {
|
deleteEmojiPack({ name }) {
|
||||||
return createEmojiPack({
|
return deleteEmojiPack({
|
||||||
name,
|
name,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then(({ data }) => data)
|
}).then(({ data }) => data)
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ export const useEmojiStore = defineStore('emoji', {
|
||||||
listEmojiPacks({
|
listEmojiPacks({
|
||||||
...params,
|
...params,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}),
|
}).then(({ data }) => data),
|
||||||
)
|
)
|
||||||
this.adminPacksLocalLoading = false
|
this.adminPacksLocalLoading = false
|
||||||
},
|
},
|
||||||
|
|
@ -210,10 +210,6 @@ export const useEmojiStore = defineStore('emoji', {
|
||||||
pageSize: 0,
|
pageSize: 0,
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.error !== undefined) {
|
|
||||||
return Promise.reject(data.error)
|
|
||||||
}
|
|
||||||
|
|
||||||
const promises = []
|
const promises = []
|
||||||
|
|
||||||
for (let i = 0; i < Math.ceil(data.count / pageSize); i++) {
|
for (let i = 0; i < Math.ceil(data.count / pageSize); i++) {
|
||||||
|
|
@ -223,10 +219,6 @@ export const useEmojiStore = defineStore('emoji', {
|
||||||
page: i,
|
page: i,
|
||||||
pageSize,
|
pageSize,
|
||||||
}).then((pageData) => {
|
}).then((pageData) => {
|
||||||
if (pageData.error !== undefined) {
|
|
||||||
return Promise.reject(pageData.error)
|
|
||||||
}
|
|
||||||
|
|
||||||
return pageData.packs
|
return pageData.packs
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -211,9 +211,10 @@ export const useInstanceStore = defineStore('instance', {
|
||||||
},
|
},
|
||||||
async getKnownDomains() {
|
async getKnownDomains() {
|
||||||
try {
|
try {
|
||||||
this.knownDomains = await fetchKnownDomains({
|
const { data } = await fetchKnownDomains({
|
||||||
credentials: window.vuex.state.users.currentUser.credentials,
|
credentials: window.vuex.state.users.currentUser.credentials,
|
||||||
})
|
})
|
||||||
|
this.knownDomains = data
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("Can't load known domains\n", e)
|
console.warn("Can't load known domains\n", e)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ export const useListsStore = defineStore('lists', {
|
||||||
return await createList({
|
return await createList({
|
||||||
title,
|
title,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((list) => {
|
}).then(({ data: list }) => {
|
||||||
this.setList({ listId: list.id, title })
|
this.setList({ listId: list.id, title })
|
||||||
return list
|
return list
|
||||||
})
|
})
|
||||||
|
|
@ -63,13 +63,15 @@ export const useListsStore = defineStore('lists', {
|
||||||
return await getList({
|
return await getList({
|
||||||
listId,
|
listId,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((list) => this.setList({ listId: list.id, title: list.title }))
|
}).then(({ data: list }) =>
|
||||||
|
this.setList({ listId: list.id, title: list.title }),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
async fetchListAccounts({ listId }) {
|
async fetchListAccounts({ listId }) {
|
||||||
return await getListAccounts({
|
return await getListAccounts({
|
||||||
listId,
|
listId,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((accountIds) => {
|
}).then(({ data: accountIds }) => {
|
||||||
if (!this.allListsObject[listId]) {
|
if (!this.allListsObject[listId]) {
|
||||||
this.allListsObject[listId] = { accountIds: [] }
|
this.allListsObject[listId] = { accountIds: [] }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ export const useOAuthTokensStore = defineStore('oauthTokens', {
|
||||||
fetchTokens() {
|
fetchTokens() {
|
||||||
fetchOAuthTokens({
|
fetchOAuthTokens({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((tokens) => {
|
}).then(({ data: tokens }) => {
|
||||||
this.swapTokens(tokens)
|
this.swapTokens(tokens)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -20,8 +20,8 @@ export const useOAuthTokensStore = defineStore('oauthTokens', {
|
||||||
revokeOAuthToken({
|
revokeOAuthToken({
|
||||||
id,
|
id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((response) => {
|
}).then(({ status }) => {
|
||||||
if (response.status === 201) {
|
if (status === 201) {
|
||||||
this.swapTokens(this.tokens.filter((token) => token.id !== id))
|
this.swapTokens(this.tokens.filter((token) => token.id !== id))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ export const usePollsStore = defineStore('polls', {
|
||||||
fetchPoll({
|
fetchPoll({
|
||||||
pollId,
|
pollId,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((poll) => {
|
}).then(({ data: poll }) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.trackedPolls[pollId]) {
|
if (this.trackedPolls[pollId]) {
|
||||||
this.updateTrackedPoll(pollId)
|
this.updateTrackedPoll(pollId)
|
||||||
|
|
@ -60,7 +60,7 @@ export const usePollsStore = defineStore('polls', {
|
||||||
pollId,
|
pollId,
|
||||||
choices,
|
choices,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((poll) => {
|
}).then(({ data: poll }) => {
|
||||||
this.mergeOrAddPoll(poll)
|
this.mergeOrAddPoll(poll)
|
||||||
return poll
|
return poll
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -350,7 +350,7 @@ export const useUserHighlightStore = defineStore('user_highlight', {
|
||||||
updateProfileJSON({
|
updateProfileJSON({
|
||||||
params,
|
params,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((user) => {
|
}).then(({ data: user }) => {
|
||||||
this.initUserHighlight(user)
|
this.initUserHighlight(user)
|
||||||
this.dirty = false
|
this.dirty = false
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue