Skip to content

Commit 08e1e4d

Browse files
Ensure that fetched Comments include the renderedBody in HTML instead of ADF only
1 parent 1a69ecd commit 08e1e4d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/WorkItemMigrator/JiraExport/JiraItem.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,14 @@ private static void HandleAttachmentChange(JiraChangeItem item, List<RevisionAct
220220

221221
private static List<JiraRevision> BuildCommentRevisions(JiraItem jiraItem, IJiraProvider jiraProvider)
222222
{
223-
var renderedFields = jiraItem.RemoteIssue.SelectToken("$.renderedFields.comment.comments");
224223
var comments = jiraProvider.GetCommentsByItemKey(jiraItem.Key);
225224
return comments.Select((c, i) =>
226225
{
227-
var rc = renderedFields.SelectToken($"$.[{i}].body");
228-
return BuildCommentRevision(c, rc, jiraItem);
226+
return BuildCommentRevision(c, c.RenderedBody, jiraItem);
229227
}).ToList();
230228
}
231229

232-
private static JiraRevision BuildCommentRevision(Comment c, JToken rc, JiraItem jiraItem)
230+
private static JiraRevision BuildCommentRevision(Comment c, string rc, JiraItem jiraItem)
233231
{
234232
var author = "NoAuthorDefined";
235233
if (c.AuthorUser is null)
@@ -252,7 +250,7 @@ private static JiraRevision BuildCommentRevision(Comment c, JToken rc, JiraItem
252250
{
253251
Author = author,
254252
Time = c.CreatedDate.Value,
255-
Fields = new Dictionary<string, object>() { { "comment", c.Body }, { "comment$Rendered", rc.Value<string>() } },
253+
Fields = new Dictionary<string, object>() { { "comment", c.Body }, { "comment$Rendered", rc } },
256254
AttachmentActions = new List<RevisionAction<JiraAttachment>>(),
257255
LinkActions = new List<RevisionAction<JiraLink>>()
258256
};

src/WorkItemMigrator/JiraExport/JiraProvider.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ public IssueLinkType GetLinkType(string linkTypeString, string targetItemKey, ou
111111

112112
public IEnumerable<Comment> GetCommentsByItemKey(string itemKey)
113113
{
114-
return _jiraServiceWrapper.Issues.GetCommentsAsync(itemKey).Result;
114+
var options = new CommentQueryOptions();
115+
options.Expand.Add("renderedBody");
116+
return _jiraServiceWrapper.Issues.GetCommentsAsync(itemKey, options).Result;
115117
}
116118

117119
public CustomField GetCustomField(string fieldName)

0 commit comments

Comments
 (0)