Merge pull request #1055 from nextcloud/import-generate-url

migrate away from depricated OC.generateUrl
pull/1069/head
Robin Appelman 2020-10-12 15:26:29 +00:00 zatwierdzone przez GitHub
commit b56732b343
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
16 zmienionych plików z 139 dodań i 40 usunięć

84
package-lock.json wygenerowano
Wyświetl plik

@ -3543,6 +3543,57 @@
"core-js": "^3.6.4" "core-js": "^3.6.4"
} }
}, },
"@nextcloud/moment": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@nextcloud/moment/-/moment-1.1.1.tgz",
"integrity": "sha512-lh7Xn9Ver12pLfE0rpjxE6x/ipscAV+7fw1u+7TJak1QR1T1UDRMZ9dA7z77W8mZH2C3yveTh/VEHZIflKBrng==",
"requires": {
"@nextcloud/l10n": "1.2.0",
"core-js": "3.6.4",
"jed": "^1.1.1",
"moment": "2.24.0",
"node-gettext": "^2.0.0"
},
"dependencies": {
"@nextcloud/l10n": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@nextcloud/l10n/-/l10n-1.2.0.tgz",
"integrity": "sha512-aPsVAewCYMNe2h0yse3Fj7LofvnvFPimojw24K47ip1+I1gawMIsQL+BYAnN8wzlcbsDTEc7I1FxtOh+8dHHIA==",
"requires": {
"core-js": "^3.6.4",
"node-gettext": "^3.0.0"
},
"dependencies": {
"node-gettext": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/node-gettext/-/node-gettext-3.0.0.tgz",
"integrity": "sha512-/VRYibXmVoN6tnSAY2JWhNRhWYJ8Cd844jrZU/DwLVoI4vBI6ceYbd8i42sYZ9uOgDH3S7vslIKOWV/ZrT2YBA==",
"requires": {
"lodash.get": "^4.4.2"
}
}
}
},
"core-js": {
"version": "3.6.4",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.4.tgz",
"integrity": "sha512-4paDGScNgZP2IXXilaffL9X7968RuvwlkK3xWtZRVqgd8SYNiVKRJvkFd1aqqEuPfN7E68ZHEp9hDj6lHj4Hyw=="
},
"moment": {
"version": "2.24.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg=="
},
"node-gettext": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/node-gettext/-/node-gettext-2.1.0.tgz",
"integrity": "sha512-vsHImHl+Py0vB7M2UXcFEJ5NJ3950gcja45YclBFtYxYeZiqdfQdcu+G9s4L7jpRFSh/J/7VoS3upR4JM1nS+g==",
"requires": {
"lodash.get": "^4.4.2"
}
}
}
},
"@nextcloud/router": { "@nextcloud/router": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/@nextcloud/router/-/router-1.2.0.tgz", "resolved": "https://registry.npmjs.org/@nextcloud/router/-/router-1.2.0.tgz",
@ -6963,6 +7014,7 @@
"has": "^1.0.3", "has": "^1.0.3",
"has-symbols": "^1.0.1", "has-symbols": "^1.0.1",
"is-callable": "^1.2.2", "is-callable": "^1.2.2",
"is-negative-zero": "^2.0.0",
"is-regex": "^1.1.1", "is-regex": "^1.1.1",
"object-inspect": "^1.8.0", "object-inspect": "^1.8.0",
"object-keys": "^1.1.1", "object-keys": "^1.1.1",
@ -6977,8 +7029,30 @@
"integrity": "sha512-VT/cxmx5yaoHSOTSyrCygIDFco+RsibY2NM0a4RdEeY/4KgqezwFtK1yr3U67xYhqJSlASm2pKhLVzPj2lr4bA==", "integrity": "sha512-VT/cxmx5yaoHSOTSyrCygIDFco+RsibY2NM0a4RdEeY/4KgqezwFtK1yr3U67xYhqJSlASm2pKhLVzPj2lr4bA==",
"requires": { "requires": {
"define-properties": "^1.1.3", "define-properties": "^1.1.3",
"es-abstract": "^1.18.0-next.0",
"has-symbols": "^1.0.1", "has-symbols": "^1.0.1",
"object-keys": "^1.1.1" "object-keys": "^1.1.1"
},
"dependencies": {
"es-abstract": {
"version": "1.18.0-next.1",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.1.tgz",
"integrity": "sha512-I4UGspA0wpZXWENrdA0uHbnhte683t3qT/1VFH9aX2dA5PPSf6QW5HHXf5HImaqPmjXaVeVk4RGWnaylmV7uAA==",
"requires": {
"es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-symbols": "^1.0.1",
"is-callable": "^1.2.2",
"is-negative-zero": "^2.0.0",
"is-regex": "^1.1.1",
"object-inspect": "^1.8.0",
"object-keys": "^1.1.1",
"object.assign": "^4.1.1",
"string.prototype.trimend": "^1.0.1",
"string.prototype.trimstart": "^1.0.1"
}
}
} }
} }
} }
@ -9235,6 +9309,11 @@
"is-path-inside": "^3.0.1" "is-path-inside": "^3.0.1"
} }
}, },
"is-negative-zero": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.0.tgz",
"integrity": "sha1-lVOxIbD6wohp2p7UWeIMdUN4hGE="
},
"is-number": { "is-number": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz",
@ -9542,6 +9621,11 @@
"plist": "^3.0.1" "plist": "^3.0.1"
} }
}, },
"jed": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/jed/-/jed-1.1.1.tgz",
"integrity": "sha1-elSbvZ/+FYWwzQoZHiAwVb7ldLQ="
},
"jest": { "jest": {
"version": "26.4.2", "version": "26.4.2",
"resolved": "https://registry.npmjs.org/jest/-/jest-26.4.2.tgz", "resolved": "https://registry.npmjs.org/jest/-/jest-26.4.2.tgz",

Wyświetl plik

@ -34,6 +34,7 @@
"@nextcloud/axios": "^1.4.0", "@nextcloud/axios": "^1.4.0",
"@nextcloud/initial-state": "^1.2.0", "@nextcloud/initial-state": "^1.2.0",
"@nextcloud/logger": "^1.1.2", "@nextcloud/logger": "^1.1.2",
"@nextcloud/moment": "^1.1.1",
"@nextcloud/router": "^1.2.0", "@nextcloud/router": "^1.2.0",
"@nextcloud/vue": "^2.7.0", "@nextcloud/vue": "^2.7.0",
"he": "^1.2.0", "he": "^1.2.0",

Wyświetl plik

@ -97,6 +97,7 @@ import axios from '@nextcloud/axios'
import Search from './components/Search.vue' import Search from './components/Search.vue'
import currentuserMixin from './mixins/currentUserMixin' import currentuserMixin from './mixins/currentUserMixin'
import { loadState } from '@nextcloud/initial-state' import { loadState } from '@nextcloud/initial-state'
import { generateUrl } from '@nextcloud/router'
export default { export default {
name: 'App', name: 'App',
@ -214,7 +215,7 @@ export default {
this.infoHidden = true this.infoHidden = true
}, },
setCloudAddress() { setCloudAddress() {
axios.post(OC.generateUrl('apps/social/api/v1/config/cloudAddress'), { cloudAddress: this.cloudAddress }).then((response) => { axios.post(generateUrl('apps/social/api/v1/config/cloudAddress'), { cloudAddress: this.cloudAddress }).then((response) => {
this.$store.commit('setServerDataEntry', 'setup', false) this.$store.commit('setServerDataEntry', 'setup', false)
this.$store.commit('setServerDataEntry', 'cloudAddress', this.cloudAddress) this.$store.commit('setServerDataEntry', 'cloudAddress', this.cloudAddress)
}) })

Wyświetl plik

@ -29,6 +29,7 @@
<script> <script>
import Avatar from '@nextcloud/vue/dist/Components/Avatar' import Avatar from '@nextcloud/vue/dist/Components/Avatar'
import { generateUrl } from '@nextcloud/router'
export default { export default {
name: 'ActorAvatar', name: 'ActorAvatar',
@ -46,7 +47,7 @@ export default {
}, },
computed: { computed: {
avatarUrl() { avatarUrl() {
return OC.generateUrl('/apps/social/api/v1/global/actor/avatar?id=' + this.item.attributedTo) return generateUrl('/apps/social/api/v1/global/actor/avatar?id=' + this.item.attributedTo)
} }
} }
} }

Wyświetl plik

@ -397,6 +397,7 @@ import CurrentUserMixin from './../mixins/currentUserMixin'
import FocusOnCreate from '../directives/focusOnCreate' import FocusOnCreate from '../directives/focusOnCreate'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import ActorAvatar from './ActorAvatar.vue' import ActorAvatar from './ActorAvatar.vue'
import { generateUrl } from '@nextcloud/router'
export default { export default {
name: 'Composer', name: 'Composer',
@ -453,7 +454,7 @@ export default {
key: user.preferredUsername, key: user.preferredUsername,
value: user.account, value: user.account,
url: user.url, url: user.url,
avatar: user.local ? OC.generateUrl(`/avatar/${user.preferredUsername}/32`) : OC.generateUrl(`apps/social/api/v1/global/actor/avatar?id=${user.id}`) avatar: user.local ? generateUrl(`/avatar/${user.preferredUsername}/32`) : generateUrl(`apps/social/api/v1/global/actor/avatar?id=${user.id}`)
}) })
} }
cb(users) cb(users)
@ -474,7 +475,7 @@ export default {
tag = item.original.value tag = item.original.value
} }
return '<span class="hashtag" contenteditable="false">' return '<span class="hashtag" contenteditable="false">'
+ '<a href="' + OC.generateUrl('/timeline/tags/' + tag) + '" target="_blank">#' + tag + '</a></span>' + '<a href="' + generateUrl('/timeline/tags/' + tag) + '" target="_blank">#' + tag + '</a></span>'
}, },
values: (text, cb) => { values: (text, cb) => {
let tags = [] let tags = []
@ -691,7 +692,7 @@ export default {
if (e.target.result.startsWith('data:image')) { if (e.target.result.startsWith('data:image')) {
img.src = e.target.result img.src = e.target.result
} else { } else {
img.src = OC.generateUrl('svg/core/filetypes/x-office-document?color=d8d8d8') img.src = generateUrl('svg/core/filetypes/x-office-document?color=d8d8d8')
} }
} }
@ -824,10 +825,10 @@ export default {
}, },
remoteSearchAccounts(text) { remoteSearchAccounts(text) {
return axios.get(OC.generateUrl('apps/social/api/v1/global/accounts/search?search=' + text)) return axios.get(generateUrl('apps/social/api/v1/global/accounts/search?search=' + text))
}, },
remoteSearchHashtags(text) { remoteSearchHashtags(text) {
return axios.get(OC.generateUrl('apps/social/api/v1/global/tags/search?search=' + text)) return axios.get(generateUrl('apps/social/api/v1/global/tags/search?search=' + text))
} }
} }
} }

Wyświetl plik

@ -65,7 +65,7 @@ function transformText(createElement, text) {
to: { to: {
name: 'profile', name: 'profile',
params: { account: match[2].substr(1) } params: { account: match[2].substr(1) }
}, }
} }
}, },
[match[3]] [match[3]]

Wyświetl plik

@ -1,7 +1,7 @@
<template> <template>
<masonry> <masonry>
<div v-for="(item, index) in attachments" :key="index"> <div v-for="(item, index) in attachments" :key="index">
<img :src="OC.generateUrl('/apps/social/document/get/resized?id=' + item.id)" @click="showModal(index)"> <img :src="generateUrl('/apps/social/document/get/resized?id=' + item.id)" @click="showModal(index)">
</div> </div>
<modal v-show="modal" :has-previous="current > 0" :has-next="current < (attachments.length - 1)" <modal v-show="modal" :has-previous="current > 0" :has-next="current < (attachments.length - 1)"
size="full" @close="closeModal" @previous="showPrevious" size="full" @close="closeModal" @previous="showPrevious"
@ -16,6 +16,7 @@
<script> <script>
import Modal from '@nextcloud/vue/dist/Components/Modal' import Modal from '@nextcloud/vue/dist/Components/Modal'
import { generateUrl } from '@nextcloud/router'
export default { export default {
name: 'PostAttachment', name: 'PostAttachment',
@ -55,7 +56,7 @@ export default {
canvas.height = height canvas.height = height
ctx.drawImage(img, 0, 0, width, height) ctx.drawImage(img, 0, 0, width, height)
} }
img.src = OC.generateUrl('/apps/social/document/get?id=' + this.attachments[this.current].id) img.src = generateUrl('/apps/social/document/get?id=' + this.attachments[this.current].id)
}, },
showModal(idx) { showModal(idx) {
this.current = idx this.current = idx

Wyświetl plik

@ -101,6 +101,7 @@ import serverData from '../mixins/serverData'
import currentUser from '../mixins/currentUserMixin' import currentUser from '../mixins/currentUserMixin'
import follow from '../mixins/follow' import follow from '../mixins/follow'
import FollowButton from './FollowButton.vue' import FollowButton from './FollowButton.vue'
import { generateUrl } from '@nextcloud/router'
export default { export default {
name: 'ProfileInfo', name: 'ProfileInfo',
@ -145,12 +146,12 @@ export default {
return (field) => this.accountInfo.details.count ? this.accountInfo.details.count[field] : '' return (field) => this.accountInfo.details.count ? this.accountInfo.details.count[field] : ''
}, },
avatarUrl() { avatarUrl() {
return OC.generateUrl('/apps/social/api/v1/global/actor/avatar?id=' + this.accountInfo.id) return generateUrl('/apps/social/api/v1/global/actor/avatar?id=' + this.accountInfo.id)
} }
}, },
methods: { methods: {
followRemote() { followRemote() {
window.open(OC.generateUrl('/apps/social/api/v1/ostatus/followRemote/' + encodeURI(this.localUid)), 'followRemote', 'width=433,height=600toolbar=no,menubar=no,scrollbars=yes,resizable=yes') window.open(generateUrl('/apps/social/api/v1/ostatus/followRemote/' + encodeURI(this.localUid)), 'followRemote', 'width=433,height=600toolbar=no,menubar=no,scrollbars=yes,resizable=yes')
} }
} }
} }

Wyświetl plik

@ -81,6 +81,7 @@
import UserEntry from './UserEntry.vue' import UserEntry from './UserEntry.vue'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import Trend from 'vuetrend' import Trend from 'vuetrend'
import { generateUrl } from '@nextcloud/router'
export default { export default {
name: 'Search', name: 'Search',
@ -153,14 +154,14 @@ export default {
}, },
accountSearch(term) { accountSearch(term) {
this.loading = true this.loading = true
return axios.get(OC.generateUrl('apps/social/api/v1/global/accounts/search?search=' + term)) return axios.get(generateUrl('apps/social/api/v1/global/accounts/search?search=' + term))
}, },
searchQuery(term) { searchQuery(term) {
this.loading = true this.loading = true
return axios.get(OC.generateUrl('apps/social/api/v1/search?search=' + term)) return axios.get(generateUrl('apps/social/api/v1/search?search=' + term))
}, },
remoteSearch(term) { remoteSearch(term) {
return axios.get(OC.generateUrl('apps/social/api/v1/global/account/info?account=' + term)) return axios.get(generateUrl('apps/social/api/v1/global/account/info?account=' + term))
} }
} }
} }

Wyświetl plik

@ -65,6 +65,8 @@ import popoverMenu from './../mixins/popoverMenu'
import currentUser from './../mixins/currentUserMixin' import currentUser from './../mixins/currentUserMixin'
import PostAttachment from './PostAttachment.vue' import PostAttachment from './PostAttachment.vue'
import MessageContent from './MessageContent' import MessageContent from './MessageContent'
import moment from '@nextcloud/moment'
import { generateUrl } from '@nextcloud/router'
pluginMention(linkify) pluginMention(linkify)
@ -103,7 +105,7 @@ export default {
return actions return actions
}, },
relativeTimestamp() { relativeTimestamp() {
return OC.Util.relativeModifiedDate(this.item.published) return moment(this.item.published).fromNow()
}, },
timestamp() { timestamp() {
return Date.parse(this.item.published) return Date.parse(this.item.published)
@ -119,7 +121,7 @@ export default {
return JSON.parse(this.item.source) return JSON.parse(this.item.source)
}, },
avatarUrl() { avatarUrl() {
return OC.generateUrl('/apps/social/api/v1/global/actor/avatar?id=' + this.item.attributedTo) return generateUrl('/apps/social/api/v1/global/actor/avatar?id=' + this.item.attributedTo)
}, },
hasAttachments() { hasAttachments() {
return (typeof this.item.attachment !== 'undefined') return (typeof this.item.attachment !== 'undefined')

Wyświetl plik

@ -59,6 +59,7 @@ import Avatar from '@nextcloud/vue/dist/Components/Avatar'
import follow from '../mixins/follow' import follow from '../mixins/follow'
import currentUser from '../mixins/currentUserMixin' import currentUser from '../mixins/currentUserMixin'
import FollowButton from './FollowButton.vue' import FollowButton from './FollowButton.vue'
import { generateUrl } from '@nextcloud/router'
export default { export default {
name: 'UserEntry', name: 'UserEntry',
@ -86,7 +87,7 @@ export default {
return this.item.id return this.item.id
}, },
avatarUrl() { avatarUrl() {
return OC.generateUrl('/apps/social/api/v1/global/actor/avatar?id=' + this.id) return generateUrl('/apps/social/api/v1/global/actor/avatar?id=' + this.id)
} }
} }
} }

Wyświetl plik

@ -21,6 +21,7 @@
*/ */
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
class FollowException { class FollowException {
@ -39,7 +40,7 @@ export default {
methods: { methods: {
follow() { follow() {
this.followLoading = true this.followLoading = true
return axios.put(OC.generateUrl('/apps/social/api/v1/current/follow?account=' + this.item.account)).then((response) => { return axios.put(generateUrl('/apps/social/api/v1/current/follow?account=' + this.item.account)).then((response) => {
this.followLoading = false this.followLoading = false
if (response.data.status === -1) { if (response.data.status === -1) {
throw new FollowException() throw new FollowException()
@ -54,7 +55,7 @@ export default {
}, },
unfollow() { unfollow() {
this.followLoading = true this.followLoading = true
return axios.delete(OC.generateUrl('/apps/social/api/v1/current/follow?account=' + this.item.account)).then((response) => { return axios.delete(generateUrl('/apps/social/api/v1/current/follow?account=' + this.item.account)).then((response) => {
this.followLoading = false this.followLoading = false
if (response.data.status === -1) { if (response.data.status === -1) {
throw new UnfollowException() throw new UnfollowException()

Wyświetl plik

@ -23,6 +23,7 @@
*/ */
import Vue from 'vue' import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
import { generateUrl } from '@nextcloud/router'
// Dynamic loading // Dynamic loading
const Timeline = () => import('./views/Timeline.vue') const Timeline = () => import('./views/Timeline.vue')
@ -37,7 +38,7 @@ export default new Router({
mode: 'history', mode: 'history',
// if index.php is in the url AND we got this far, then it's working: // if index.php is in the url AND we got this far, then it's working:
// let's keep using index.php in the url // let's keep using index.php in the url
base: OC.generateUrl(''), base: generateUrl(''),
linkActiveClass: 'active', linkActiveClass: 'active',
routes: [ routes: [
{ {

Wyświetl plik

@ -22,6 +22,7 @@
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import Vue from 'vue' import Vue from 'vue'
import { generateUrl } from '@nextcloud/router'
const state = { const state = {
currentAccount: {}, currentAccount: {},
@ -108,7 +109,7 @@ const getters = {
const actions = { const actions = {
fetchAccountInfo(context, account) { fetchAccountInfo(context, account) {
return axios.get(OC.generateUrl(`apps/social/api/v1/global/account/info?account=${account}`)).then((response) => { return axios.get(generateUrl(`apps/social/api/v1/global/account/info?account=${account}`)).then((response) => {
context.commit('addAccount', { actorId: response.data.result.account.id, data: response.data.result.account }) context.commit('addAccount', { actorId: response.data.result.account.id, data: response.data.result.account })
return response.data.result.account return response.data.result.account
}).catch(() => { }).catch(() => {
@ -116,7 +117,7 @@ const actions = {
}) })
}, },
fetchPublicAccountInfo(context, uid) { fetchPublicAccountInfo(context, uid) {
return axios.get(OC.generateUrl(`apps/social/api/v1/account/${uid}/info`)).then((response) => { return axios.get(generateUrl(`apps/social/api/v1/account/${uid}/info`)).then((response) => {
context.commit('addAccount', { actorId: response.data.result.account.id, data: response.data.result.account }) context.commit('addAccount', { actorId: response.data.result.account.id, data: response.data.result.account })
return response.data.result.account return response.data.result.account
}).catch(() => { }).catch(() => {
@ -128,7 +129,7 @@ const actions = {
dispatch('fetchAccountInfo', account) dispatch('fetchAccountInfo', account)
}, },
followAccount(context, { currentAccount, accountToFollow }) { followAccount(context, { currentAccount, accountToFollow }) {
return axios.put(OC.generateUrl('/apps/social/api/v1/current/follow?account=' + accountToFollow)).then((response) => { return axios.put(generateUrl('/apps/social/api/v1/current/follow?account=' + accountToFollow)).then((response) => {
if (response.data.status === -1) { if (response.data.status === -1) {
return Promise.reject(response) return Promise.reject(response)
} }
@ -141,7 +142,7 @@ const actions = {
}, },
unfollowAccount(context, { currentAccount, accountToUnfollow }) { unfollowAccount(context, { currentAccount, accountToUnfollow }) {
return axios.delete(OC.generateUrl('/apps/social/api/v1/current/follow?account=' + accountToUnfollow)).then((response) => { return axios.delete(generateUrl('/apps/social/api/v1/current/follow?account=' + accountToUnfollow)).then((response) => {
if (response.data.status === -1) { if (response.data.status === -1) {
return Promise.reject(response) return Promise.reject(response)
} }
@ -157,7 +158,7 @@ const actions = {
// TODO: fetching followers/following information of remotes is currently not supported // TODO: fetching followers/following information of remotes is currently not supported
const parts = account.split('@') const parts = account.split('@')
const uid = (parts.length === 2 ? parts[0] : account) const uid = (parts.length === 2 ? parts[0] : account)
axios.get(OC.generateUrl(`apps/social/api/v1/account/${uid}/followers`)).then((response) => { axios.get(generateUrl(`apps/social/api/v1/account/${uid}/followers`)).then((response) => {
context.commit('addFollowers', { account, data: response.data.result }) context.commit('addFollowers', { account, data: response.data.result })
}) })
}, },
@ -165,7 +166,7 @@ const actions = {
// TODO: fetching followers/following information of remotes is currently not supported // TODO: fetching followers/following information of remotes is currently not supported
const parts = account.split('@') const parts = account.split('@')
const uid = (parts.length === 2 ? parts[0] : account) const uid = (parts.length === 2 ? parts[0] : account)
axios.get(OC.generateUrl(`apps/social/api/v1/account/${uid}/following`)).then((response) => { axios.get(generateUrl(`apps/social/api/v1/account/${uid}/following`)).then((response) => {
context.commit('addFollowing', { account, data: response.data.result }) context.commit('addFollowing', { account, data: response.data.result })
}) })
} }

Wyświetl plik

@ -24,6 +24,7 @@
import Logger from '../logger' import Logger from '../logger'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import Vue from 'vue' import Vue from 'vue'
import { generateUrl } from '@nextcloud/router'
const state = { const state = {
timeline: {}, timeline: {},
@ -118,7 +119,7 @@ const actions = {
}, },
post(context, post) { post(context, post) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.post(OC.generateUrl('apps/social/api/v1/post'), { data: post }).then((response) => { axios.post(generateUrl('apps/social/api/v1/post'), { data: post }).then((response) => {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('Post created with token ' + response.data.result.token) console.log('Post created with token ' + response.data.result.token)
resolve(response) resolve(response)
@ -130,7 +131,7 @@ const actions = {
}) })
}, },
postDelete(context, post) { postDelete(context, post) {
return axios.delete(OC.generateUrl(`apps/social/api/v1/post?id=${post.id}`)).then((response) => { return axios.delete(generateUrl(`apps/social/api/v1/post?id=${post.id}`)).then((response) => {
context.commit('removePost', post) context.commit('removePost', post)
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('Post deleted with token ' + response.data.result.token) console.log('Post deleted with token ' + response.data.result.token)
@ -141,7 +142,7 @@ const actions = {
}, },
postLike(context, { post, parentAnnounce }) { postLike(context, { post, parentAnnounce }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.post(OC.generateUrl(`apps/social/api/v1/post/like?postId=${post.id}`)).then((response) => { axios.post(generateUrl(`apps/social/api/v1/post/like?postId=${post.id}`)).then((response) => {
context.commit('likePost', { post, parentAnnounce }) context.commit('likePost', { post, parentAnnounce })
resolve(response) resolve(response)
}).catch((error) => { }).catch((error) => {
@ -152,7 +153,7 @@ const actions = {
}) })
}, },
postUnlike(context, { post, parentAnnounce }) { postUnlike(context, { post, parentAnnounce }) {
return axios.delete(OC.generateUrl(`apps/social/api/v1/post/like?postId=${post.id}`)).then((response) => { return axios.delete(generateUrl(`apps/social/api/v1/post/like?postId=${post.id}`)).then((response) => {
context.commit('unlikePost', { post, parentAnnounce }) context.commit('unlikePost', { post, parentAnnounce })
// Remove post from list if we are in the 'liked' timeline // Remove post from list if we are in the 'liked' timeline
if (state.type === 'liked') { if (state.type === 'liked') {
@ -165,7 +166,7 @@ const actions = {
}, },
postBoost(context, { post, parentAnnounce }) { postBoost(context, { post, parentAnnounce }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.post(OC.generateUrl(`apps/social/api/v1/post/boost?postId=${post.id}`)).then((response) => { axios.post(generateUrl(`apps/social/api/v1/post/boost?postId=${post.id}`)).then((response) => {
context.commit('boostPost', { post, parentAnnounce }) context.commit('boostPost', { post, parentAnnounce })
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('Post boosted with token ' + response.data.result.token) console.log('Post boosted with token ' + response.data.result.token)
@ -178,7 +179,7 @@ const actions = {
}) })
}, },
postUnBoost(context, { post, parentAnnounce }) { postUnBoost(context, { post, parentAnnounce }) {
return axios.delete(OC.generateUrl(`apps/social/api/v1/post/boost?postId=${post.id}`)).then((response) => { return axios.delete(generateUrl(`apps/social/api/v1/post/boost?postId=${post.id}`)).then((response) => {
context.commit('unboostPost', { post, parentAnnounce }) context.commit('unboostPost', { post, parentAnnounce })
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('Boost deleted with token ' + response.data.result.token) console.log('Boost deleted with token ' + response.data.result.token)
@ -199,13 +200,13 @@ const actions = {
// Compute URl to get the data // Compute URl to get the data
let url = '' let url = ''
if (state.type === 'account') { if (state.type === 'account') {
url = OC.generateUrl(`apps/social/api/v1/account/${state.account}/stream?limit=25&since=` + sinceTimestamp) url = generateUrl(`apps/social/api/v1/account/${state.account}/stream?limit=25&since=` + sinceTimestamp)
} else if (state.type === 'tags') { } else if (state.type === 'tags') {
url = OC.generateUrl(`apps/social/api/v1/stream/tag/${state.params.tag}?limit=25&since=` + sinceTimestamp) url = generateUrl(`apps/social/api/v1/stream/tag/${state.params.tag}?limit=25&since=` + sinceTimestamp)
} else if (state.type === 'single-post') { } else if (state.type === 'single-post') {
url = OC.generateUrl(`apps/social/local/v1/post/replies?id=${state.params.id}&limit=5&since=` + sinceTimestamp) url = generateUrl(`apps/social/local/v1/post/replies?id=${state.params.id}&limit=5&since=` + sinceTimestamp)
} else { } else {
url = OC.generateUrl(`apps/social/api/v1/stream/${state.type}?limit=25&since=` + sinceTimestamp) url = generateUrl(`apps/social/api/v1/stream/${state.type}?limit=25&since=` + sinceTimestamp)
} }
// Get the data and add them to the timeline // Get the data and add them to the timeline
@ -220,7 +221,7 @@ const actions = {
// Also load replies when displaying a single post timeline // Also load replies when displaying a single post timeline
if (state.type === 'single-post') { if (state.type === 'single-post') {
result.push(response.data) result.push(response.data)
// axios.get(OC.generateUrl(``)).then((response) => { // axios.get(generateUrl(``)).then((response) => {
// if (response.status !== -1) { // if (response.status !== -1) {
// result.concat(response.data.result) // result.concat(response.data.result)
// } // }

Wyświetl plik

@ -64,6 +64,7 @@ import Avatar from '@nextcloud/vue/dist/Components/Avatar'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import currentuserMixin from './../mixins/currentUserMixin' import currentuserMixin from './../mixins/currentUserMixin'
import { loadState } from '@nextcloud/initial-state' import { loadState } from '@nextcloud/initial-state'
import { generateUrl } from '@nextcloud/router'
export default { export default {
name: 'App', name: 'App',
@ -84,7 +85,7 @@ export default {
return this.serverData.account return this.serverData.account
}, },
avatarUrl() { avatarUrl() {
return OC.generateUrl('/apps/social/api/v1/global/actor/avatar?id=' + this.accountInfo.id) return generateUrl('/apps/social/api/v1/global/actor/avatar?id=' + this.accountInfo.id)
}, },
accountInfo: function() { accountInfo: function() {
return this.$store.getters.getAccount(this.serverData.account) return this.$store.getters.getAccount(this.serverData.account)
@ -124,7 +125,7 @@ export default {
}) })
}, },
followRemote() { followRemote() {
axios.get(OC.generateUrl(`/apps/social/api/v1/ostatus/link/${this.serverData.local}/` + encodeURI(this.remote))).then((a) => { axios.get(generateUrl(`/apps/social/api/v1/ostatus/link/${this.serverData.local}/` + encodeURI(this.remote))).then((a) => {
window.location = a.data.result.url window.location = a.data.result.url
}) })
}, },