-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Slack notification not sent on page update #8841
Changes from 3 commits
1086452
1e03b8f
2cc7e7b
5c6c4f9
73840a5
c4510d9
1bf99bd
1ffb817
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -80,7 +80,7 @@ | |||
]; | ||||
|
||||
|
||||
async function postAction(req: UpdatePageRequest, res: ApiV3Response, updatedPage: PageDocument) { | ||||
async function postAction(req: UpdatePageRequest, res: ApiV3Response, updatedPage: PageDocument, previousRevision: IRevisionHasId | null) { | ||||
// Reflect the updates in ydoc | ||||
const origin = req.body.origin; | ||||
if (origin === Origin.View || origin === undefined) { | ||||
|
@@ -111,10 +111,10 @@ | |||
} | ||||
|
||||
// user notification | ||||
const { revisionId, isSlackEnabled, slackChannels } = req.body; | ||||
const { isSlackEnabled, slackChannels } = req.body; | ||||
if (isSlackEnabled) { | ||||
try { | ||||
const option = revisionId != null ? { previousRevision: revisionId } : undefined; | ||||
const option = previousRevision != null ? { previousRevision } : undefined; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. crowi.userNotificationService.fire() の第5引数には IRevisionHasId 相当の値のオブジェクトを渡すように改修 (v6踏襲) 参考growi/apps/app/src/server/routes/page.js Line 536 in 41c32d5
|
||||
const results = await crowi.userNotificationService.fire(updatedPage, req.user, slackChannels, 'update', option); | ||||
results.forEach((result) => { | ||||
if (result.status === 'rejected') { | ||||
|
@@ -159,6 +159,7 @@ | |||
} | ||||
|
||||
let updatedPage: PageDocument; | ||||
let previousRevision: IRevisionHasId | null; | ||||
try { | ||||
const { | ||||
grant, userRelatedGrantUserGroupIds, overwriteScopesOfDescendants, wip, | ||||
|
@@ -168,7 +169,7 @@ | |||
options.grant = grant; | ||||
options.userRelatedGrantUserGroupIds = userRelatedGrantUserGroupIds; | ||||
} | ||||
const previousRevision = await Revision.findById(revisionId); | ||||
previousRevision = await Revision.findById<IRevisionHasId>(revisionId); | ||||
|
||||
updatedPage = await crowi.pageService.updatePage(currentPage, body, previousRevision?.body ?? null, req.user, options); | ||||
} | ||||
catch (err) { | ||||
|
@@ -183,7 +184,7 @@ | |||
|
||||
res.apiv3(result, 201); | ||||
|
||||
postAction(req, res, updatedPage); | ||||
postAction(req, res, updatedPage, previousRevision); | ||||
}, | ||||
]; | ||||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,10 @@ const prepareAttachmentTextForCreate = function(page, siteUrl) { | |
}; | ||
|
||
const prepareAttachmentTextForUpdate = function(page, siteUrl, previousRevision) { | ||
if (previousRevision == null) { | ||
return; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 少しでも type safe に近づくように、jsdoc で previousRevision の型だけでも明示するようにしてください There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 追加しました |
||
|
||
const diff = require('diff'); | ||
let diffText = ''; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PUT /_api/v3/page
のリクエストボディに isSlackEnabled を含めるように改修