Skip to content

Commit 7e92bd6

Browse files
committed
small fixes in example-forum 1.12.3
1 parent d72be2d commit 7e92bd6

File tree

1 file changed

+9
-9
lines changed
  • packages/example-forum/lib/modules/posts

1 file changed

+9
-9
lines changed

packages/example-forum/lib/modules/posts/schema.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ const schema = {
5757
canUpdate: ['admins'],
5858
input: 'datetime',
5959
group: formGroups.admin,
60-
onCreate: ({document: post, currentUser}) => {
60+
onCreate: ({newDocument: post, currentUser}) => {
6161
// Set the post's postedAt if it's going to be approved
6262
if (!post.postedAt && getCollection('Posts').getDefaultStatus(currentUser) === getCollection('Posts').config.STATUS_APPROVED) {
6363
return new Date();
6464
}
6565
},
66-
onUpdate: ({data, post}) => {
66+
onUpdate: ({data, document: post}) => {
6767
// Set the post's postedAt if it's going to be approved
6868
if (!post.postedAt && data.status === getCollection('Posts').config.STATUS_APPROVED) {
6969
return new Date();
@@ -111,7 +111,7 @@ const schema = {
111111
type: String,
112112
optional: true,
113113
canRead: ['guests'],
114-
onCreate: ({post}) => {
114+
onCreate: ({newDocument: post}) => {
115115
return Utils.slugify(post.title);
116116
},
117117
onUpdate: ({data}) => {
@@ -140,7 +140,7 @@ const schema = {
140140
type: String,
141141
optional: true,
142142
canRead: ['guests'],
143-
onCreate: ({post}) => {
143+
onCreate: ({newDocument: post}) => {
144144
if (post.body) {
145145
return Utils.sanitize(marked(post.body));
146146
}
@@ -159,7 +159,7 @@ const schema = {
159159
optional: true,
160160
canRead: ['guests'],
161161
searchable: true,
162-
onCreate: ({post}) => {
162+
onCreate: ({newDocument: post}) => {
163163
if (post.body) {
164164
// excerpt length is configurable via the settings (30 words by default, ~255 characters)
165165
const excerptLength = getSetting('forum.postExcerptLength', 30);
@@ -209,7 +209,7 @@ const schema = {
209209
canCreate: ['admins'],
210210
canUpdate: ['admins'],
211211
input: 'select',
212-
onCreate: ({document, currentUser}) => {
212+
onCreate: ({newDocument: document, currentUser}) => {
213213
if (!document.status) {
214214
return getCollection('Posts').getDefaultStatus(currentUser);
215215
}
@@ -230,15 +230,15 @@ const schema = {
230230
type: Boolean,
231231
optional: true,
232232
canRead: ['guests'],
233-
onCreate: ({post}) => {
233+
onCreate: ({newDocument: post}) => {
234234
// Set the post's isFuture to true if necessary
235235
if (post.postedAt) {
236236
const postTime = new Date(post.postedAt).getTime();
237237
const currentTime = new Date().getTime() + 1000;
238238
return postTime > currentTime; // round up to the second
239239
}
240240
},
241-
onUpdate: ({data, post}) => {
241+
onUpdate: ({data, document: post}) => {
242242
// Set the post's isFuture to true if necessary
243243
if (data.postedAt) {
244244
const postTime = new Date(data.postedAt).getTime();
@@ -265,7 +265,7 @@ const schema = {
265265
canUpdate: ['admins'],
266266
input: 'checkbox',
267267
group: formGroups.admin,
268-
onCreate: ({post}) => {
268+
onCreate: ({newDocument: post}) => {
269269
if(!post.sticky) {
270270
return false;
271271
}

0 commit comments

Comments
 (0)