Skip to content

Commit 318a8c2

Browse files
committed
chore: remove publishScheduledPost job and related logic
1 parent 51f9ab4 commit 318a8c2

File tree

5 files changed

+4
-158
lines changed

5 files changed

+4
-158
lines changed

api/paidAction/lib/item.js

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { USER_ID } from '@/lib/constants'
2-
import { deleteReminders, getDeleteAt, getRemindAt, getScheduleAt } from '@/lib/item'
2+
import { deleteReminders, getDeleteAt, getRemindAt } from '@/lib/item'
33
import { parseInternalLinks } from '@/lib/url'
44

55
export async function getMentions ({ text }, { me, tx }) {
@@ -46,19 +46,15 @@ export const getItemMentions = async ({ text }, { me, tx }) => {
4646
}
4747

4848
export async function performBotBehavior ({ text, id }, { me, tx }) {
49-
// delete any existing deleteItem, reminder, or publishScheduledPost jobs for this item
5049
const userId = me?.id || USER_ID.anon
5150
id = Number(id)
51+
5252
await tx.$queryRaw`
5353
DELETE FROM pgboss.job
54-
WHERE (name = 'deleteItem' OR name = 'publishScheduledPost')
54+
WHERE name = 'deleteItem'
5555
AND data->>'id' = ${id}::TEXT
5656
AND state <> 'completed'`
57-
await tx.$queryRaw`
58-
DELETE FROM pgboss.job
59-
WHERE name = 'publishScheduledPost'
60-
AND data->>'itemId' = ${id}::TEXT
61-
AND state <> 'completed'`
57+
6258
await deleteReminders({ id, userId, models: tx })
6359

6460
if (text) {
@@ -90,29 +86,5 @@ export async function performBotBehavior ({ text, id }, { me, tx }) {
9086
}
9187
})
9288
}
93-
94-
const scheduleAt = getScheduleAt(text)
95-
if (scheduleAt) {
96-
// For new items, scheduling info is set during creation
97-
// For updates, we need to update the item
98-
const existingItem = await tx.item.findUnique({ where: { id: Number(id) } })
99-
if (existingItem && !existingItem.scheduledAt) {
100-
await tx.item.update({
101-
where: { id: Number(id) },
102-
data: {
103-
scheduledAt: scheduleAt
104-
}
105-
})
106-
}
107-
108-
// Schedule the job to publish the post
109-
await tx.$queryRaw`
110-
INSERT INTO pgboss.job (name, data, startafter, keepuntil)
111-
VALUES (
112-
'publishScheduledPost',
113-
jsonb_build_object('itemId', ${id}::INTEGER),
114-
${scheduleAt}::TIMESTAMP WITH TIME ZONE,
115-
${scheduleAt}::TIMESTAMP WITH TIME ZONE + interval '1 minute')`
116-
}
11789
}
11890
}

api/resolvers/item.js

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,54 +1095,6 @@ export default {
10951095

10961096
return result
10971097
},
1098-
publishScheduledPostNow: async (parent, { id }, { me, models }) => {
1099-
if (!me) {
1100-
throw new GqlAuthenticationError()
1101-
}
1102-
1103-
const item = await models.item.findUnique({
1104-
where: { id: Number(id) }
1105-
})
1106-
1107-
if (!item) {
1108-
throw new GqlInputError('item not found')
1109-
}
1110-
1111-
if (Number(item.userId) !== Number(me.id)) {
1112-
throw new GqlInputError('item does not belong to you')
1113-
}
1114-
1115-
if (!item.scheduledAt) {
1116-
throw new GqlInputError('item is not scheduled')
1117-
}
1118-
1119-
// Cancel the scheduled job
1120-
await models.$queryRaw`
1121-
DELETE FROM pgboss.job
1122-
WHERE name = 'publishScheduledPost'
1123-
AND data->>'itemId' = ${item.id}::TEXT
1124-
AND state <> 'completed'`
1125-
1126-
const publishTime = new Date()
1127-
1128-
// Publish immediately - keep original createdAt and scheduledAt
1129-
const updatedItem = await models.item.update({
1130-
where: { id: Number(id) },
1131-
data: {
1132-
updatedAt: publishTime
1133-
}
1134-
})
1135-
1136-
// Refresh cached views
1137-
await models.$executeRaw`REFRESH MATERIALIZED VIEW CONCURRENTLY hot_score_view`
1138-
1139-
// Queue side effects
1140-
await models.$executeRaw`
1141-
INSERT INTO pgboss.job (name, data, startafter)
1142-
VALUES ('schedulePostSideEffects', jsonb_build_object('itemId', ${item.id}::INTEGER), now())`
1143-
1144-
return updatedItem
1145-
}
11461098
},
11471099
ItemAct: {
11481100
invoice: async (itemAct, args, { models }) => {

api/typeDefs/item.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export default gql`
6464
act(id: ID!, sats: Int, act: String, hasSendWallet: Boolean): ItemActPaidAction!
6565
pollVote(id: ID!): PollVotePaidAction!
6666
toggleOutlaw(id: ID!): Item!
67-
publishScheduledPostNow(id: ID!): Item!
6867
}
6968
7069
type PollVoteResult {

worker/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import { expireBoost } from './expireBoost'
3838
import { payingActionConfirmed, payingActionFailed } from './payingAction'
3939
import { autoDropBolt11s } from './autoDropBolt11'
4040
import { postToSocial } from './socialPoster'
41-
import { publishScheduledPost, schedulePostSideEffects } from './publishScheduledPosts'
4241

4342
// WebSocket polyfill
4443
import ws from 'isomorphic-ws'
@@ -145,8 +144,6 @@ async function work () {
145144
await boss.work('reminder', jobWrapper(remindUser))
146145
await boss.work('thisDay', jobWrapper(thisDay))
147146
await boss.work('socialPoster', jobWrapper(postToSocial))
148-
await boss.work('publishScheduledPost', jobWrapper(publishScheduledPost))
149-
await boss.work('schedulePostSideEffects', jobWrapper(schedulePostSideEffects))
150147
await boss.work('checkWallet', jobWrapper(checkWallet))
151148

152149
console.log('working jobs')

worker/publishScheduledPosts.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)