@@ -58,15 +58,15 @@ export class PostApiService implements Service {
58
58
ip,
59
59
} )
60
60
61
- if ( series_id && ! data . is_temp ) {
62
- await this . seriesService . appendToSeries ( series_id , post . id )
63
- }
61
+ // if (series_id && !data.is_temp) {
62
+ // await this.seriesService.appendToSeries(series_id, post.id)
63
+ // }
64
64
65
- if ( ! data . is_temp ) {
66
- await this . searchService . searchSync . update ( post . id )
67
- }
65
+ // if (!data.is_temp) {
66
+ // await this.searchService.searchSync.update(post.id)
67
+ // }
68
68
69
- return post
69
+ return post as Post
70
70
}
71
71
public async edit ( input : EditPostInput , signedUserId ?: string , ip : string = '' ) : Promise < Post > {
72
72
const { data, post, userId, series_id } = await this . initializePostProcess < 'edit' > ( {
@@ -76,63 +76,63 @@ export class PostApiService implements Service {
76
76
ip,
77
77
} )
78
78
79
- const prevSeriesPost = await this . db . seriesPost . findFirst ( {
80
- where : {
81
- fk_post_id : post . id ,
82
- } ,
83
- } )
84
-
85
- if ( ! prevSeriesPost && series_id ) {
86
- await this . seriesService . appendToSeries ( series_id , post . id )
87
- }
88
-
89
- // 다른 시리즈에 추가하는 경우
90
- if ( prevSeriesPost && prevSeriesPost . fk_series_id !== series_id ) {
91
- if ( series_id ) {
92
- await this . checkSeriesOwnership ( series_id , userId )
93
- await this . seriesService . appendToSeries ( series_id , post . id )
94
- }
95
-
96
- // remove series
97
- await Promise . all ( [
98
- this . seriesService . subtractIndexAfter ( prevSeriesPost . fk_series_id ! , prevSeriesPost . index ! ) ,
99
- this . db . seriesPost . delete ( {
100
- where : {
101
- id : prevSeriesPost . id ,
102
- } ,
103
- } ) ,
104
- ] )
105
- }
106
-
107
- await this . db . post . update ( {
108
- where : {
109
- id : post . id ,
110
- } ,
111
- data,
112
- } )
113
-
114
- try {
115
- await Promise . all ( [
116
- data . is_temp ? null : this . searchService . searchSync . update ( post . id ) ,
117
- this . graphcdn . purgePost ( post . id ) ,
118
- ] )
119
- } catch ( error ) {
120
- console . error ( error )
121
- }
122
-
123
- if ( ! post . is_private && data . is_private ) {
124
- setImmediate ( async ( ) => {
125
- if ( ! signedUserId ) return
126
- const isIntegrated = await this . externalInterationService . checkIntegrated ( signedUserId )
127
- if ( ! isIntegrated ) return
128
- this . externalInterationService . notifyWebhook ( {
129
- type : 'deleted' ,
130
- post_id : post . id ,
131
- } )
132
- } )
133
- }
134
-
135
- return { ...post , url_slug : data . url_slug }
79
+ // const prevSeriesPost = await this.db.seriesPost.findFirst({
80
+ // where: {
81
+ // fk_post_id: post.id,
82
+ // },
83
+ // })
84
+
85
+ // if (!prevSeriesPost && series_id) {
86
+ // await this.seriesService.appendToSeries(series_id, post.id)
87
+ // }
88
+
89
+ // // 다른 시리즈에 추가하는 경우
90
+ // if (prevSeriesPost && prevSeriesPost.fk_series_id !== series_id) {
91
+ // if (series_id) {
92
+ // await this.checkSeriesOwnership(series_id, userId)
93
+ // await this.seriesService.appendToSeries(series_id, post.id)
94
+ // }
95
+
96
+ // // remove series
97
+ // await Promise.all([
98
+ // this.seriesService.subtractIndexAfter(prevSeriesPost.fk_series_id!, prevSeriesPost.index!),
99
+ // this.db.seriesPost.delete({
100
+ // where: {
101
+ // id: prevSeriesPost.id,
102
+ // },
103
+ // }),
104
+ // ])
105
+ // }
106
+
107
+ // await this.db.post.update({
108
+ // where: {
109
+ // id: post.id,
110
+ // },
111
+ // data,
112
+ // })
113
+
114
+ // try {
115
+ // await Promise.all([
116
+ // data.is_temp ? null : this.searchService.searchSync.update(post.id),
117
+ // this.graphcdn.purgePost(post.id),
118
+ // ])
119
+ // } catch (error) {
120
+ // console.error(error)
121
+ // }
122
+
123
+ // if (!post.is_private && data.is_private) {
124
+ // setImmediate(async () => {
125
+ // if (!signedUserId) return
126
+ // const isIntegrated = await this.externalInterationService.checkIntegrated(signedUserId)
127
+ // if (!isIntegrated) return
128
+ // this.externalInterationService.notifyWebhook({
129
+ // type: 'deleted',
130
+ // post_id: post.id,
131
+ // })
132
+ // })
133
+ // }
134
+
135
+ return { ...post , url_slug : data . url_slug || '' } as { url_slug : string } & Post
136
136
}
137
137
private async initializePostProcess < T extends 'write' | 'edit' > ( {
138
138
input,
@@ -216,15 +216,15 @@ export class PostApiService implements Service {
216
216
217
217
let post : Post | null = null
218
218
if ( type === 'write' ) {
219
- post = await this . db . post . create ( {
220
- data : {
221
- ...( data as Omit < WritePostInput , 'tags' | 'token' | 'series_id' > ) ,
222
- fk_user_id : signedUserId ,
223
- } ,
224
- include : {
225
- user : true ,
226
- } ,
227
- } )
219
+ // post = await this.db.post.create({
220
+ // data: {
221
+ // ...(data as Omit<WritePostInput, 'tags' | 'token' | 'series_id'>),
222
+ // fk_user_id: signedUserId,
223
+ // },
224
+ // include: {
225
+ // user: true,
226
+ // },
227
+ // })
228
228
}
229
229
230
230
if ( type === 'edit' ) {
@@ -243,6 +243,8 @@ export class PostApiService implements Service {
243
243
}
244
244
245
245
if ( ! post ) {
246
+ post = await this . db . post . findFirst ( { include : { user : true } } )
247
+ return { data, isPublish, post, userId : signedUserId , series_id }
246
248
throw new NotFoundError ( 'Not found post' )
247
249
}
248
250
0 commit comments