Skip to content

Commit fe7293c

Browse files
committed
populate ref fields
1 parent 2057013 commit fe7293c

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

TechStacks.ServiceInterface/PostServices.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,20 @@ public async Task<CreatePostResponse> Post(ImportNewsPost request)
5757
Content = request.Summary,
5858
TechnologyIds = techIds.ToArray(),
5959
PointsModifier = request.Points > 0 ? request.Points : 1,
60+
RefId = request.Id,
6061
};
62+
if (!string.IsNullOrEmpty(request.CommentsUrl))
63+
{
64+
post.RefSource = request.CommentsUrl.Contains("news.ycombinator.com")
65+
? "HN"
66+
: request.CommentsUrl.Contains("reddit.com")
67+
? "Reddit"
68+
: null;
69+
if (post.RefSource != null)
70+
{
71+
post.RefUrn = $"urn:{post.RefSource.ToLower()}:post:{request.Id}";
72+
}
73+
}
6174

6275
if (request.Sentiment != null)
6376
{

TechStacks.ServiceModel/Posts.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public class CreatePost : IReturn<CreatePostResponse>, IPost
7171
public string Meta { get; set; }
7272

7373
public long? RefId { get; set; }
74-
public string RefSource { get; set; }
75-
public string RefUrn { get; set; }
74+
public string? RefSource { get; set; }
75+
public string? RefUrn { get; set; }
7676

7777
[IgnoreDataMember]
7878
public int? PointsModifier { get; set; }

0 commit comments

Comments
 (0)