diff --git a/appinfo/routes.php b/appinfo/routes.php
index b845fa82..3ef5ea91 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -81,10 +81,16 @@ return [
['name' => 'Api#savedSearches', 'url' => '/api/saved_searches/list.json', 'verb' => 'GET'],
['name' => 'Api#timelines', 'url' => '/api/v1/timelines/{timeline}/', 'verb' => 'GET'],
['name' => 'Api#notifications', 'url' => '/api/v1/notifications', 'verb' => 'GET'],
+
['name' => 'MediaApi#uploadMedia', 'url' => '/api/v1/media', 'verb' => 'POST'],
['name' => 'MediaApi#updateMedia', 'url' => '/api/v1/media/{id}', 'verb' => 'PUT'],
['name' => 'MediaApi#deleteMedia', 'url' => '/api/v1/media/{id}', 'verb' => 'DELETE'],
- ['name' => 'MediaApi#getMedia', 'url' => '/media/{shortcode}.{extension}', 'verb' => 'GET'],
+
+ ['name' => 'StatusApi#publishStatus', 'url' => '/api/v1/statuses', 'verb' => 'POST'],
+ ['name' => 'StatusApi#getStatus', 'url' => '/api/v1/statuses/{id}', 'verb' => 'GET'],
+ ['name' => 'StatusApi#deleteStatus', 'url' => '/api/v1/statuses/{id}', 'verb' => 'DELETE'],
+ ['name' => 'StatusApi#contextStatus', 'url' => '/api/v1/statuses/{id}/context', 'verb' => 'GET'],
+ ['name' => 'StatusApi#reblogedBy', 'url' => '/api/v1/statuses/{id}/reblogged_by', 'verb' => 'GET'],
// Api for local front-end
// TODO: front-end should be using the new ApiController
diff --git a/src/App.vue b/src/App.vue
index b9f4a5b3..377c7af6 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -118,7 +118,7 @@ export default {
AppContent,
AppNavigation,
AppNavigationItem,
- Search,
+ Search
},
mixins: [currentuserMixin],
data: function() {
diff --git a/src/components/Composer/Composer.vue b/src/components/Composer/Composer.vue
index 543c95d9..31121762 100644
--- a/src/components/Composer/Composer.vue
+++ b/src/components/Composer/Composer.vue
@@ -25,12 +25,12 @@
+ class="hidden-visually"
+ @change="handleFileChange($event)">
@@ -62,13 +62,13 @@
@tribute-replaced="updatePostFromTribute" />
-
+
-
-
-
@@ -65,8 +65,8 @@
+ icon="icon-delete"
+ @click="remove()">
{{ t('social', 'Delete') }}
@@ -105,7 +105,7 @@ export default {
Repeat,
Reply,
Heart,
- HeartOutline,
+ HeartOutline
},
mixins: [currentUser],
props: {
diff --git a/src/settings-personal.js b/src/settings-personal.js
index 2359e242..07722c65 100644
--- a/src/settings-personal.js
+++ b/src/settings-personal.js
@@ -22,5 +22,5 @@ Vue.prototype.OCA = OCA
/* eslint-disable-next-line no-new */
new Vue({
- render: h => h(App),
+ render: h => h(App)
}).$mount('#settings-personal')
diff --git a/src/store/composer.js b/src/store/composer.js
new file mode 100644
index 00000000..62e9b75b
--- /dev/null
+++ b/src/store/composer.js
@@ -0,0 +1,79 @@
+// SPDX-FileCopyrightText: 2022 Carl Schwan
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+const state = {
+ attachements: [],
+ status: '',
+ sensitive: false
+}
+
+const mutations = {
+ addAttachement(state, { id, description, url, preview_url }) {
+ state.attachements.push({ id, description, url, preview_url })
+ },
+ updateAttachement(state, { id, description, url, preview_url }) {
+ const index = state.attachements.findIndex(item => {
+ return id === item.id
+ })
+ state.attachements.splice(index, 1, { id, description, url, preview_url })
+ },
+ deleteAttachement(state, { id }) {
+ const index = state.attachements.findIndex(item => {
+ return id === item.id
+ })
+ state.attachements.splice(index, 1)
+ },
+ clearAttachements(state) {
+ state.attachements.splice(0)
+ },
+ updateSensitive(sensitive, status) {
+ state.sensitive = sensitive
+ }
+}
+
+const actions = {
+ async uploadAttachement(context, formData) {
+ const res = await axios.post(generateUrl('apps/social/api/v1/media'), formData, {
+ headers: {
+ 'Content-Type': 'multipart/form-data'
+ }
+ })
+ context.commit('addAttachement', {
+ id: res.data.id,
+ description: res.data.description,
+ url: res.data.url,
+ preview_url: res.data.preview_url
+ })
+ },
+ async updateAttachement(context, { id, description }) {
+ const res = await axios.put(generateUrl('apps/social/api/v1/media/' + id), {
+ description
+ })
+ context.commit('updateAttachement', {
+ id: res.data.id,
+ description: res.data.description,
+ url: res.data.url,
+ preview_url: res.data.preview_url
+ })
+ },
+ async deleteAttachement(context, { id }) {
+ const res = await axios.delete(generateUrl('apps/social/api/v1/media/' + id))
+ context.commit('deleteAttachement', {
+ id: res.data.id
+ })
+ },
+ async postStatus({ commit, state }, text) {
+ const data = {
+ status: text,
+ media_ids: state.attachements.map(attachement => attachement.id),
+ sensitive: state.sensitive
+ }
+ try {
+ const response = await axios.post(generateUrl('apps/social/api/v1/statuses'), data)
+ } catch (error) {
+ OC.Notification.showTemporary('Failed to create a post')
+ Logger.error('Failed to create a post', { 'error': error.response })
+ }
+ commit('clearAttachements')
+ }
+}
diff --git a/src/store/index.js b/src/store/index.js
index 4076bff7..34bd54e2 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -26,6 +26,7 @@ import Vuex from 'vuex'
import timeline from './timeline'
import account from './account'
import settings from './settings'
+import composer from './composer'
Vue.use(Vuex)
@@ -35,7 +36,8 @@ export default new Vuex.Store({
modules: {
timeline,
account,
- settings
+ settings,
+ composer
},
strict: debug
})
diff --git a/src/store/timeline.js b/src/store/timeline.js
index 9f8c0d49..741fc2a4 100644
--- a/src/store/timeline.js
+++ b/src/store/timeline.js
@@ -55,7 +55,7 @@ const state = {
composerDisplayStatus: false,
draft: {
attachements: []
- },
+ }
}
const mutations = {
addToTimeline(state, data) {
@@ -115,21 +115,24 @@ const mutations = {
Vue.set(state.timeline[parentAnnounce.id].cache[parentAnnounce.object].object.action.values, 'boosted', false)
}
},
- addAttachement(state, {id, description, url, preview_url}) {
- state.draft.attachements.push({id, description, url, preview_url})
+ addAttachement(state, { id, description, url, preview_url }) {
+ state.draft.attachements.push({ id, description, url, preview_url })
},
- updateAttachement(state, {id, description, url, preview_url}) {
+ updateAttachement(state, { id, description, url, preview_url }) {
const index = state.draft.attachements.findIndex(item => {
return id === item.id
})
- state.draft.attachements.splice(index, 1, {id, description, url, preview_url})
+ state.draft.attachements.splice(index, 1, { id, description, url, preview_url })
},
- deleteAttachement(state, {id}) {
+ deleteAttachement(state, { id }) {
const index = state.draft.attachements.findIndex(item => {
return id === item.id
})
state.draft.attachements.splice(index, 1)
},
+ clearAttachements(state) {
+ state.draft.attachements.splice(0)
+ }
}
const getters = {
getComposerDisplayStatus(state) {
@@ -166,43 +169,44 @@ const actions = {
const res = await axios.post(generateUrl('apps/social/api/v1/media'), formData, {
headers: {
'Content-Type': 'multipart/form-data'
- },
+ }
})
context.commit('addAttachement', {
id: res.data.id,
description: res.data.description,
url: res.data.url,
- preview_url: res.data.preview_url,
+ preview_url: res.data.preview_url
})
},
- async updateAttachement(context, {id, description}) {
+ async updateAttachement(context, { id, description }) {
const res = await axios.put(generateUrl('apps/social/api/v1/media/' + id), {
- description,
+ description
})
context.commit('updateAttachement', {
id: res.data.id,
description: res.data.description,
url: res.data.url,
- preview_url: res.data.preview_url,
+ preview_url: res.data.preview_url
})
},
- async deleteAttachement(context, {id}) {
+ async deleteAttachement(context, { id }) {
const res = await axios.delete(generateUrl('apps/social/api/v1/media/' + id))
context.commit('deleteAttachement', {
- id: res.data.id,
+ id: res.data.id
})
},
- post(context, post) {
- return new Promise((resolve, reject) => {
- axios.post(generateUrl('apps/social/api/v1/post'), { data: post }).then((response) => {
- Logger.info('Post created with token ' + response.data.result.token)
- resolve(response)
- }).catch((error) => {
- OC.Notification.showTemporary('Failed to create a post')
- Logger.error('Failed to create a post', { 'error': error.response })
- reject(error)
- })
- })
+ async postStatus({ commit, state }, text) {
+ const data = {
+ status: text,
+ media_ids: state.draft.attachements.map(attachement => attachement.id)
+ }
+ try {
+ const response = axios.post(generateUrl('apps/social/api/v1/statuses'), data)
+ } catch (error) {
+ OC.Notification.showTemporary('Failed to create a post')
+ Logger.error('Failed to create a post', { 'error': error.response })
+ }
+ commit('clearAttachements')
},
postDelete(context, post) {
return axios.delete(generateUrl(`apps/social/api/v1/post?id=${post.id}`)).then((response) => {
diff --git a/src/views/SettingsPersonal.vue b/src/views/SettingsPersonal.vue
index fea163ea..07209a93 100644
--- a/src/views/SettingsPersonal.vue
+++ b/src/views/SettingsPersonal.vue
@@ -51,7 +51,7 @@ export default {
name: 'SetupUser',
components: {
CheckboxRadioSwitch,
- SettingsSection,
+ SettingsSection
},
data() {
return {