From b0c7cb88035b5ca723de2a5a08cd2840214d9b97 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 5 Mar 2018 08:44:37 +0900 Subject: [PATCH] wip --- src/api/endpoints/posts/create.ts | 13 ++++++ src/api/models/post.ts | 9 ++++ .../views/components/post-form-window.vue | 13 +++++- .../desktop/views/components/post-form.vue | 21 ++++++++- .../app/mobile/views/components/post-form.vue | 24 +++++++++-- src/web/docs/api/entities/post.yaml | 43 +++++++++++++++++++ 6 files changed, 117 insertions(+), 6 deletions(-) diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts index a9d52fd12..15cbc4845 100644 --- a/src/api/endpoints/posts/create.ts +++ b/src/api/endpoints/posts/create.ts @@ -39,6 +39,18 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { const [tags = [], tagsErr] = $(params.tags).optional.array('string').unique().eachQ(t => t.range(1, 32)).$; if (tagsErr) return rej('invalid tags'); + // Get 'geo' parameter + const [geo, geoErr] = $(params.geo).optional.nullable.strict.object() + .have('latitude', $().number().range(-180, 180)) + .have('longitude', $().number().range(-90, 90)) + .have('altitude', $().nullable.number()) + .have('accuracy', $().nullable.number()) + .have('altitudeAccuracy', $().nullable.number()) + .have('heading', $().nullable.number().range(0, 360)) + .have('speed', $().nullable.number()) + .$; + if (geoErr) return rej('invalid geo'); + // Get 'media_ids' parameter const [mediaIds, mediaIdsErr] = $(params.media_ids).optional.array('id').unique().range(1, 4).$; if (mediaIdsErr) return rej('invalid media_ids'); @@ -244,6 +256,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { user_id: user._id, app_id: app ? app._id : null, via_mobile: viaMobile, + geo, // 以下非正規化データ _reply: reply ? { user_id: reply.user_id } : undefined, diff --git a/src/api/models/post.ts b/src/api/models/post.ts index edb69e0c1..c37c8371c 100644 --- a/src/api/models/post.ts +++ b/src/api/models/post.ts @@ -32,6 +32,15 @@ export type IPost = { category: string; is_category_verified: boolean; via_mobile: boolean; + geo: { + latitude: number; + longitude: number; + altitude: number; + accuracy: number; + altitudeAccuracy: number; + heading: number; + speed: number; + }; }; /** diff --git a/src/web/app/desktop/views/components/post-form-window.vue b/src/web/app/desktop/views/components/post-form-window.vue index 4427f5982..31a07a890 100644 --- a/src/web/app/desktop/views/components/post-form-window.vue +++ b/src/web/app/desktop/views/components/post-form-window.vue @@ -1,6 +1,7 @@ @@ -24,7 +26,8 @@ export default Vue.extend({ data() { return { uploadings: [], - media: [] + media: [], + geo: null }; }, mounted() { @@ -39,6 +42,9 @@ export default Vue.extend({ onChangeMedia(media) { this.media = media; }, + onGeoAttached(geo) { + this.geo = geo; + }, onPosted() { (this.$refs.window as any).close(); } @@ -47,6 +53,9 @@ export default Vue.extend({