fix: post and scheduled post
This commit is contained in:
parent
866dd832bb
commit
84cbd84bdc
1 changed files with 11 additions and 10 deletions
|
@ -394,18 +394,18 @@ export class NoteHelpers {
|
||||||
? await getNote(request.quote_id, user)
|
? await getNote(request.quote_id, user)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const delay = Math.max(
|
const now = new Date();
|
||||||
0,
|
|
||||||
(request.scheduled_at?.getTime() ?? Date.now()) - Date.now(),
|
let delay: number | null =
|
||||||
);
|
(request.scheduled_at?.getTime() ?? now.getTime()) - now.getTime();
|
||||||
|
if (delay <= 0) delay = null;
|
||||||
|
|
||||||
const visibility =
|
const visibility =
|
||||||
request.visibility ?? UserHelpers.getDefaultNoteVisibility(ctx);
|
request.visibility ?? UserHelpers.getDefaultNoteVisibility(ctx);
|
||||||
|
|
||||||
const now = new Date();
|
|
||||||
|
|
||||||
const data = await awaitAll({
|
const data = await awaitAll({
|
||||||
createdAt: now,
|
createdAt: now,
|
||||||
|
scheduledAt: request.scheduled_at ?? null,
|
||||||
files: files,
|
files: files,
|
||||||
poll: request.poll
|
poll: request.poll
|
||||||
? {
|
? {
|
||||||
|
@ -425,9 +425,9 @@ export class NoteHelpers {
|
||||||
renote: renote,
|
renote: renote,
|
||||||
cw: request.spoiler_text,
|
cw: request.spoiler_text,
|
||||||
lang: request.language,
|
lang: request.language,
|
||||||
visibility: delay ? "specified" : visibility,
|
visibility: delay != null ? "specified" : visibility,
|
||||||
visibleUsers: Promise.resolve(visibility).then((p) =>
|
visibleUsers: Promise.resolve(visibility).then((p) =>
|
||||||
delay
|
delay != null
|
||||||
? []
|
? []
|
||||||
: p === "specified"
|
: p === "specified"
|
||||||
? this.extractMentions(request.text ?? "", ctx)
|
? this.extractMentions(request.text ?? "", ctx)
|
||||||
|
@ -439,7 +439,8 @@ export class NoteHelpers {
|
||||||
user,
|
user,
|
||||||
{
|
{
|
||||||
createdAt: now,
|
createdAt: now,
|
||||||
scheduledAt: delay != null ? new Date(data.scheduledAt!) : null,
|
scheduledAt:
|
||||||
|
data.scheduledAt != null ? new Date(data.scheduledAt) : null,
|
||||||
files: data.files,
|
files: data.files,
|
||||||
poll:
|
poll:
|
||||||
data.poll != null
|
data.poll != null
|
||||||
|
@ -468,7 +469,7 @@ export class NoteHelpers {
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
delay
|
delay != null
|
||||||
? async (note) => {
|
? async (note) => {
|
||||||
createScheduledNoteJob(
|
createScheduledNoteJob(
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue