Remove Permalink string alias
Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@ var expectedCommentSubmitOrEdit = &Comment{
|
|||||||
ID: "test2",
|
ID: "test2",
|
||||||
FullID: "t1_test2",
|
FullID: "t1_test2",
|
||||||
ParentID: "t1_test",
|
ParentID: "t1_test",
|
||||||
Permalink: "https://www.reddit.com/r/subreddit/comments/test1/some_thread/test2/",
|
Permalink: "/r/subreddit/comments/test1/some_thread/test2/",
|
||||||
|
|
||||||
Body: "test comment",
|
Body: "test comment",
|
||||||
Author: "reddit_username",
|
Author: "reddit_username",
|
||||||
|
|||||||
+4
-4
@@ -17,7 +17,7 @@ var expectedListingPosts = []*Post{
|
|||||||
Created: &Timestamp{time.Date(2020, 8, 2, 18, 23, 8, 0, time.UTC)},
|
Created: &Timestamp{time.Date(2020, 8, 2, 18, 23, 8, 0, time.UTC)},
|
||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
Permalink: "https://www.reddit.com/r/test/comments/i2gvg4/this_is_a_title/",
|
Permalink: "/r/test/comments/i2gvg4/this_is_a_title/",
|
||||||
URL: "https://www.reddit.com/r/test/comments/i2gvg4/this_is_a_title/",
|
URL: "https://www.reddit.com/r/test/comments/i2gvg4/this_is_a_title/",
|
||||||
|
|
||||||
Title: "This is a title",
|
Title: "This is a title",
|
||||||
@@ -47,7 +47,7 @@ var expectedListingComments = []*Comment{
|
|||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
ParentID: "t3_i2gvg4",
|
ParentID: "t3_i2gvg4",
|
||||||
Permalink: "https://www.reddit.com/r/test/comments/i2gvg4/this_is_a_title/g05v931/",
|
Permalink: "/r/test/comments/i2gvg4/this_is_a_title/g05v931/",
|
||||||
|
|
||||||
Body: "Test comment",
|
Body: "Test comment",
|
||||||
Author: "v_95",
|
Author: "v_95",
|
||||||
@@ -91,7 +91,7 @@ var expectedListingPosts2 = []*Post{
|
|||||||
Created: &Timestamp{time.Date(2020, 8, 2, 18, 23, 8, 0, time.UTC)},
|
Created: &Timestamp{time.Date(2020, 8, 2, 18, 23, 8, 0, time.UTC)},
|
||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
Permalink: "https://www.reddit.com/r/test/comments/i2gvg4/this_is_a_title/",
|
Permalink: "/r/test/comments/i2gvg4/this_is_a_title/",
|
||||||
URL: "https://www.reddit.com/r/test/comments/i2gvg4/this_is_a_title/",
|
URL: "https://www.reddit.com/r/test/comments/i2gvg4/this_is_a_title/",
|
||||||
|
|
||||||
Title: "This is a title",
|
Title: "This is a title",
|
||||||
@@ -117,7 +117,7 @@ var expectedListingPosts2 = []*Post{
|
|||||||
Created: &Timestamp{time.Date(2020, 8, 2, 18, 23, 37, 0, time.UTC)},
|
Created: &Timestamp{time.Date(2020, 8, 2, 18, 23, 37, 0, time.UTC)},
|
||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
Permalink: "https://www.reddit.com/r/test/comments/i2gvs1/this_is_a_title/",
|
Permalink: "/r/test/comments/i2gvs1/this_is_a_title/",
|
||||||
URL: "http://example.com",
|
URL: "http://example.com",
|
||||||
|
|
||||||
Title: "This is a title",
|
Title: "This is a title",
|
||||||
|
|||||||
+7
-7
@@ -17,7 +17,7 @@ var expectedPostAndComments = &PostAndComments{
|
|||||||
Created: &Timestamp{time.Date(2020, 7, 18, 10, 26, 7, 0, time.UTC)},
|
Created: &Timestamp{time.Date(2020, 7, 18, 10, 26, 7, 0, time.UTC)},
|
||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
Permalink: "https://www.reddit.com/r/test/comments/testpost/test/",
|
Permalink: "/r/test/comments/testpost/test/",
|
||||||
URL: "https://www.reddit.com/r/test/comments/testpost/test/",
|
URL: "https://www.reddit.com/r/test/comments/testpost/test/",
|
||||||
|
|
||||||
Title: "Test",
|
Title: "Test",
|
||||||
@@ -44,7 +44,7 @@ var expectedPostAndComments = &PostAndComments{
|
|||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
ParentID: "t3_testpost",
|
ParentID: "t3_testpost",
|
||||||
Permalink: "https://www.reddit.com/r/test/comments/testpost/test/testc1/",
|
Permalink: "/r/test/comments/testpost/test/testc1/",
|
||||||
|
|
||||||
Body: "Hi",
|
Body: "Hi",
|
||||||
Author: "testuser",
|
Author: "testuser",
|
||||||
@@ -71,7 +71,7 @@ var expectedPostAndComments = &PostAndComments{
|
|||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
ParentID: "t1_testc1",
|
ParentID: "t1_testc1",
|
||||||
Permalink: "https://www.reddit.com/r/test/comments/testpost/test/testc2/",
|
Permalink: "/r/test/comments/testpost/test/testc2/",
|
||||||
|
|
||||||
Body: "Hello",
|
Body: "Hello",
|
||||||
Author: "testuser",
|
Author: "testuser",
|
||||||
@@ -107,7 +107,7 @@ var expectedEditedPost = &Post{
|
|||||||
Created: &Timestamp{time.Date(2020, 7, 23, 1, 24, 55, 0, time.UTC)},
|
Created: &Timestamp{time.Date(2020, 7, 23, 1, 24, 55, 0, time.UTC)},
|
||||||
Edited: &Timestamp{time.Date(2020, 7, 23, 1, 42, 44, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(2020, 7, 23, 1, 42, 44, 0, time.UTC)},
|
||||||
|
|
||||||
Permalink: "https://www.reddit.com/r/test/comments/hw6l6a/test_title/",
|
Permalink: "/r/test/comments/hw6l6a/test_title/",
|
||||||
URL: "https://www.reddit.com/r/test/comments/hw6l6a/test_title/",
|
URL: "https://www.reddit.com/r/test/comments/hw6l6a/test_title/",
|
||||||
|
|
||||||
Title: "Test Title",
|
Title: "Test Title",
|
||||||
@@ -136,7 +136,7 @@ var expectedPost2 = &Post{
|
|||||||
Created: &Timestamp{time.Date(2020, 8, 2, 18, 23, 37, 0, time.UTC)},
|
Created: &Timestamp{time.Date(2020, 8, 2, 18, 23, 37, 0, time.UTC)},
|
||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
Permalink: "https://www.reddit.com/r/test/comments/i2gvs1/this_is_a_title/",
|
Permalink: "/r/test/comments/i2gvs1/this_is_a_title/",
|
||||||
URL: "http://example.com",
|
URL: "http://example.com",
|
||||||
|
|
||||||
Title: "This is a title",
|
Title: "This is a title",
|
||||||
@@ -163,7 +163,7 @@ var expectedPostDuplicates = &Posts{
|
|||||||
Created: &Timestamp{time.Date(2018, 5, 18, 9, 10, 18, 0, time.UTC)},
|
Created: &Timestamp{time.Date(2018, 5, 18, 9, 10, 18, 0, time.UTC)},
|
||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
Permalink: "https://www.reddit.com/r/test/comments/8kbs85/test/",
|
Permalink: "/r/test/comments/8kbs85/test/",
|
||||||
URL: "http://example.com",
|
URL: "http://example.com",
|
||||||
|
|
||||||
Title: "test",
|
Title: "test",
|
||||||
@@ -187,7 +187,7 @@ var expectedPostDuplicates = &Posts{
|
|||||||
Created: &Timestamp{time.Date(2011, 10, 16, 13, 26, 40, 0, time.UTC)},
|
Created: &Timestamp{time.Date(2011, 10, 16, 13, 26, 40, 0, time.UTC)},
|
||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
Permalink: "https://www.reddit.com/r/test/comments/le1tc/test_to_see_if_this_fixes_the_problem_of_my_likes/",
|
Permalink: "/r/test/comments/le1tc/test_to_see_if_this_fixes_the_problem_of_my_likes/",
|
||||||
URL: "http://www.example.com",
|
URL: "http://www.example.com",
|
||||||
|
|
||||||
Title: "Test to see if this fixes the problem of my \"likes\" from the last 7 months vanishing.",
|
Title: "Test to see if this fixes the problem of my \"likes\" from the last 7 months vanishing.",
|
||||||
|
|||||||
+4
-4
@@ -18,7 +18,7 @@ var expectedPosts = &Posts{
|
|||||||
Created: &Timestamp{time.Date(2019, 1, 16, 5, 57, 51, 0, time.UTC)},
|
Created: &Timestamp{time.Date(2019, 1, 16, 5, 57, 51, 0, time.UTC)},
|
||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
Permalink: "https://www.reddit.com/r/test/comments/agi5zf/test/",
|
Permalink: "/r/test/comments/agi5zf/test/",
|
||||||
URL: "https://www.reddit.com/r/test/comments/agi5zf/test/",
|
URL: "https://www.reddit.com/r/test/comments/agi5zf/test/",
|
||||||
|
|
||||||
Title: "test",
|
Title: "test",
|
||||||
@@ -44,7 +44,7 @@ var expectedPosts = &Posts{
|
|||||||
Created: &Timestamp{time.Date(2020, 7, 27, 0, 5, 10, 0, time.UTC)},
|
Created: &Timestamp{time.Date(2020, 7, 27, 0, 5, 10, 0, time.UTC)},
|
||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
Permalink: "https://www.reddit.com/r/test/comments/hyhquk/veggies/",
|
Permalink: "/r/test/comments/hyhquk/veggies/",
|
||||||
URL: "https://i.imgur.com/LrN2mPw.jpg",
|
URL: "https://i.imgur.com/LrN2mPw.jpg",
|
||||||
|
|
||||||
Title: "Veggies",
|
Title: "Veggies",
|
||||||
@@ -158,7 +158,7 @@ var expectedSearchPosts = &Posts{
|
|||||||
Created: &Timestamp{time.Date(2020, 7, 26, 18, 14, 24, 0, time.UTC)},
|
Created: &Timestamp{time.Date(2020, 7, 26, 18, 14, 24, 0, time.UTC)},
|
||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
Permalink: "https://www.reddit.com/r/WatchPeopleDieInside/comments/hybow9/pregnancy_test/",
|
Permalink: "/r/WatchPeopleDieInside/comments/hybow9/pregnancy_test/",
|
||||||
URL: "https://v.redd.it/ra4qnt8bt8d51",
|
URL: "https://v.redd.it/ra4qnt8bt8d51",
|
||||||
|
|
||||||
Title: "Pregnancy test",
|
Title: "Pregnancy test",
|
||||||
@@ -180,7 +180,7 @@ var expectedSearchPosts = &Posts{
|
|||||||
Created: &Timestamp{time.Date(2020, 7, 7, 15, 19, 42, 0, time.UTC)},
|
Created: &Timestamp{time.Date(2020, 7, 7, 15, 19, 42, 0, time.UTC)},
|
||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
Permalink: "https://www.reddit.com/r/worldnews/comments/hmwhd7/brazilian_president_jair_bolsonaro_tests_positive/",
|
Permalink: "/r/worldnews/comments/hmwhd7/brazilian_president_jair_bolsonaro_tests_positive/",
|
||||||
URL: "https://www.theguardian.com/world/2020/jul/07/jair-bolsonaro-coronavirus-positive-test-brazil-president",
|
URL: "https://www.theguardian.com/world/2020/jul/07/jair-bolsonaro-coronavirus-positive-test-brazil-president",
|
||||||
|
|
||||||
Title: "Brazilian president Jair Bolsonaro tests positive for coronavirus",
|
Title: "Brazilian president Jair Bolsonaro tests positive for coronavirus",
|
||||||
|
|||||||
@@ -19,21 +19,6 @@ const (
|
|||||||
kindModAction = "modaction"
|
kindModAction = "modaction"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Permalink is the link to a post or comment.
|
|
||||||
type Permalink string
|
|
||||||
|
|
||||||
// UnmarshalJSON implements the json.Unmarshaler interface.
|
|
||||||
func (p *Permalink) UnmarshalJSON(data []byte) error {
|
|
||||||
var v string
|
|
||||||
err := json.Unmarshal(data, &v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
v = "https://www.reddit.com" + v
|
|
||||||
*p = Permalink(v)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// thing is an entity on Reddit.
|
// thing is an entity on Reddit.
|
||||||
// Its kind reprsents what it is and what is stored in the Data field
|
// Its kind reprsents what it is and what is stored in the Data field
|
||||||
// e.g. t1 = comment, t2 = user, t3 = post, etc.
|
// e.g. t1 = comment, t2 = user, t3 = post, etc.
|
||||||
@@ -128,8 +113,8 @@ type Comment struct {
|
|||||||
Created *Timestamp `json:"created_utc,omitempty"`
|
Created *Timestamp `json:"created_utc,omitempty"`
|
||||||
Edited *Timestamp `json:"edited,omitempty"`
|
Edited *Timestamp `json:"edited,omitempty"`
|
||||||
|
|
||||||
ParentID string `json:"parent_id,omitempty"`
|
ParentID string `json:"parent_id,omitempty"`
|
||||||
Permalink Permalink `json:"permalink,omitempty"`
|
Permalink string `json:"permalink,omitempty"`
|
||||||
|
|
||||||
Body string `json:"body,omitempty"`
|
Body string `json:"body,omitempty"`
|
||||||
Author string `json:"author,omitempty"`
|
Author string `json:"author,omitempty"`
|
||||||
@@ -253,8 +238,8 @@ type Post struct {
|
|||||||
Created *Timestamp `json:"created_utc,omitempty"`
|
Created *Timestamp `json:"created_utc,omitempty"`
|
||||||
Edited *Timestamp `json:"edited,omitempty"`
|
Edited *Timestamp `json:"edited,omitempty"`
|
||||||
|
|
||||||
Permalink Permalink `json:"permalink,omitempty"`
|
Permalink string `json:"permalink,omitempty"`
|
||||||
URL string `json:"url,omitempty"`
|
URL string `json:"url,omitempty"`
|
||||||
|
|
||||||
Title string `json:"title,omitempty"`
|
Title string `json:"title,omitempty"`
|
||||||
Body string `json:"selftext,omitempty"`
|
Body string `json:"selftext,omitempty"`
|
||||||
|
|||||||
+2
-2
@@ -52,7 +52,7 @@ var expectedPost = &Post{
|
|||||||
Created: &Timestamp{time.Date(2020, 5, 3, 22, 46, 25, 0, time.UTC)},
|
Created: &Timestamp{time.Date(2020, 5, 3, 22, 46, 25, 0, time.UTC)},
|
||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
Permalink: "https://www.reddit.com/r/redditdev/comments/gczwql/get_userusernamegilded_does_it_return_other_users/",
|
Permalink: "/r/redditdev/comments/gczwql/get_userusernamegilded_does_it_return_other_users/",
|
||||||
URL: "https://www.reddit.com/r/redditdev/comments/gczwql/get_userusernamegilded_does_it_return_other_users/",
|
URL: "https://www.reddit.com/r/redditdev/comments/gczwql/get_userusernamegilded_does_it_return_other_users/",
|
||||||
|
|
||||||
Title: "GET /user/{username}/gilded: does it return other user's things you've gilded, or your things that have been gilded? Does it return both comments and posts?",
|
Title: "GET /user/{username}/gilded: does it return other user's things you've gilded, or your things that have been gilded? Does it return both comments and posts?",
|
||||||
@@ -81,7 +81,7 @@ var expectedComment = &Comment{
|
|||||||
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
Edited: &Timestamp{time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
|
||||||
|
|
||||||
ParentID: "t3_d7ejpn",
|
ParentID: "t3_d7ejpn",
|
||||||
Permalink: "https://www.reddit.com/r/apple/comments/d7ejpn/im_giving_away_an_iphone_11_pro_to_a_commenter_at/f0zsa37/",
|
Permalink: "/r/apple/comments/d7ejpn/im_giving_away_an_iphone_11_pro_to_a_commenter_at/f0zsa37/",
|
||||||
|
|
||||||
Body: "Thank you!",
|
Body: "Thank you!",
|
||||||
Author: "v_95",
|
Author: "v_95",
|
||||||
|
|||||||
Reference in New Issue
Block a user