refactor (backend): remove redundancy
This commit is contained in:
parent
5daeaf1de2
commit
02380eff4d
1 changed files with 6 additions and 7 deletions
|
@ -233,7 +233,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
|
|
||||||
// Check blocking
|
// Check blocking
|
||||||
if (renote.userId !== user.id) {
|
if (renote.userId !== user.id) {
|
||||||
const isBlocked = await Blockings.exist({
|
const isBlocked = await Blockings.exists({
|
||||||
where: {
|
where: {
|
||||||
blockerId: renote.userId,
|
blockerId: renote.userId,
|
||||||
blockeeId: user.id,
|
blockeeId: user.id,
|
||||||
|
@ -260,7 +260,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
|
|
||||||
// Check blocking
|
// Check blocking
|
||||||
if (reply.userId !== user.id) {
|
if (reply.userId !== user.id) {
|
||||||
const isBlocked = await Blockings.exist({
|
const isBlocked = await Blockings.exists({
|
||||||
where: {
|
where: {
|
||||||
blockerId: reply.userId,
|
blockerId: reply.userId,
|
||||||
blockeeId: user.id,
|
blockeeId: user.id,
|
||||||
|
@ -280,14 +280,13 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
if (
|
if (
|
||||||
ps.poll.expiresAt &&
|
ps.poll.expiresAt &&
|
||||||
ps.scheduledAt &&
|
ps.scheduledAt &&
|
||||||
ps.poll.expiresAt < Number(new Date(ps.scheduledAt))
|
ps.poll.expiresAt < ps.scheduledAt
|
||||||
) {
|
) {
|
||||||
throw new ApiError(meta.errors.cannotCreateAlreadyExpiredPoll);
|
throw new ApiError(meta.errors.cannotCreateAlreadyExpiredPoll);
|
||||||
}
|
}
|
||||||
} else if (typeof ps.poll.expiredAfter === "number") {
|
} else if (typeof ps.poll.expiredAfter === "number") {
|
||||||
if (ps.scheduledAt) {
|
if (ps.scheduledAt != null) {
|
||||||
ps.poll.expiresAt =
|
ps.poll.expiresAt = ps.scheduledAt + ps.poll.expiredAfter;
|
||||||
Number(new Date(ps.scheduledAt)) + ps.poll.expiredAfter;
|
|
||||||
} else {
|
} else {
|
||||||
ps.poll.expiresAt = Date.now() + ps.poll.expiredAfter;
|
ps.poll.expiresAt = Date.now() + ps.poll.expiredAfter;
|
||||||
}
|
}
|
||||||
|
@ -305,7 +304,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
|
|
||||||
let delay: number | null = null;
|
let delay: number | null = null;
|
||||||
if (ps.scheduledAt) {
|
if (ps.scheduledAt) {
|
||||||
delay = Number(ps.scheduledAt) - Number(new Date());
|
delay = ps.scheduledAt - Date.now();
|
||||||
if (delay < 0) {
|
if (delay < 0) {
|
||||||
delay = null;
|
delay = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue