mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
Merge pull request #68 from RubenPX/timezone-fixer
Send post using client timestamp
This commit is contained in:
commit
66b3dcce9b
@ -38,6 +38,7 @@ export default (props) => {
|
||||
const cleanPostData = () => {
|
||||
setPostData({
|
||||
message: "",
|
||||
date: new Date(),
|
||||
additions: []
|
||||
})
|
||||
}
|
||||
|
@ -54,12 +54,13 @@ export default class PostsController extends Controller {
|
||||
"/post": {
|
||||
middlewares: ["withAuthentication"],
|
||||
fn: Schematized({
|
||||
required: ["message"],
|
||||
select: ["message", "additions", "type", "data"],
|
||||
required: ["message", "date"],
|
||||
select: ["message", "additions", "type", "data", "date"],
|
||||
}, async (req, res) => {
|
||||
const post = await CreatePost({
|
||||
user_id: req.user.id,
|
||||
message: req.selection.message,
|
||||
date: req.selection.date,
|
||||
additions: req.selection.additions,
|
||||
type: req.selection.type,
|
||||
data: req.selection.data,
|
||||
|
@ -1,18 +1,14 @@
|
||||
import { Post } from "../../../models"
|
||||
import getPostData from "./getPostData"
|
||||
import momentTimezone from "moment-timezone"
|
||||
|
||||
export default async (payload) => {
|
||||
const { user_id, message, additions, type, data } = payload
|
||||
|
||||
const current_timezone = momentTimezone.tz.guess()
|
||||
const created_at = momentTimezone.tz(Date.now(), current_timezone).format()
|
||||
const { user_id, message, additions, type, data, date } = payload
|
||||
|
||||
const post = new Post({
|
||||
user_id: typeof user_id === "object" ? user_id.toString() : user_id,
|
||||
message: String(message).toString(),
|
||||
additions: additions ?? [],
|
||||
created_at: created_at,
|
||||
created_at: date,
|
||||
type: type,
|
||||
data: data,
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user