diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-03-05 08:44:37 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-03-05 08:44:37 +0900 |
| commit | b0c7cb88035b5ca723de2a5a08cd2840214d9b97 (patch) | |
| tree | e17702b4c64a4860ed3e3e17cee92c21a8040c9c /src/api | |
| parent | #1183 (diff) | |
| download | sharkey-b0c7cb88035b5ca723de2a5a08cd2840214d9b97.tar.gz sharkey-b0c7cb88035b5ca723de2a5a08cd2840214d9b97.tar.bz2 sharkey-b0c7cb88035b5ca723de2a5a08cd2840214d9b97.zip | |
wip
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/endpoints/posts/create.ts | 13 | ||||
| -rw-r--r-- | src/api/models/post.ts | 9 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts index a9d52fd128..15cbc4845c 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 edb69e0c15..c37c8371c0 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; + }; }; /** |