Skip to content

Commit

Permalink
fix: fix cancel article scheduling causes the lost of original proper…
Browse files Browse the repository at this point in the history
…ties - EXO-75716 - Meeds-io/meeds#2639 (#335)

Prior to this change, when cancel a scheduled article with properties
and continue as draft, the new created draft doesn't conserve the
original article properties because a wrong passed param in the
properties object which doesn't indicate that the properties are belong
to a draft.
This PR fixes the issue by forcing to set the right needed param in the
properties object when create a draft that comes from unschedule action
  • Loading branch information
hakermi authored Dec 6, 2024
1 parent 099bfc8 commit 1623cf7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,9 @@ public News scheduleNews(News news, Identity currentIdentity, String newsObjectT
public News unScheduleNews(News news, String pageOwnerId, String articleCreator) throws Exception {
News existingNews = getNewsArticleById(news.getId());
if (existingNews != null) {
if (news.getProperties() != null) {
news.getProperties().setDraft(true);
}
news = createDraftArticleForNewPage(news, pageOwnerId, articleCreator, System.currentTimeMillis());
deleteArticle(existingNews, articleCreator);
return buildDraftArticle(news.getId(), articleCreator);
Expand Down Expand Up @@ -2166,4 +2169,3 @@ private void updateArticlePermissions(List<Space> spaces, News article, List<Str
NewsUtils.broadcastEvent(NewsUtils.UPDATE_CONTENT_PERMISSIONS, this, updateContentPermissionEventListenerData);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,8 @@ public void testUnScheduleNews() throws Exception {
News newsArticle = mock(News.class);
when(newsArticle.getId()).thenReturn("1");
when(newsArticle.getBody()).thenReturn("body");

when(newsArticle.getProperties()).thenReturn(new NotePageProperties());

DraftPage draftPage = mock(DraftPage.class);
when(draftPage.getUpdatedDate()).thenReturn(new Date());
when(draftPage.getCreatedDate()).thenReturn(new Date());
Expand Down

0 comments on commit 1623cf7

Please sign in to comment.