commit 53469cfb86b05905dd8bb219db400e31be3f0169 from: Oliver Lowe date: Fri Feb 02 10:24:26 2024 UTC lemmy: decode published, updated times Now that the Lemmy API returns nice timestamps, it's all done automatically by Go's JSON package. commit - 8a94cb46def4cf380b0068e905438d72826ee6d8 commit + 53469cfb86b05905dd8bb219db400e31be3f0169 blob - 5f624e673cafb2eeb02f2b9476a9d2ce5e86231d blob + b7aabd94beb820d8430bd35e075d0fdeb38a7a90 --- decode_test.go +++ decode_test.go @@ -16,10 +16,10 @@ func TestPost(t *testing.T) { t.Fatal(err) } t.Log(post.ID) - if creator.ID != 2 { + if creator.ID != 151025 { t.Errorf("check creator ID: want %d, got %d", 2, creator.ID) } - if creator.String() != "TheAnonymouseJoker@lemmy.ml" { + if creator.String() != "otl@lemmy.sdf.org" { t.Errorf("creator username: want %s, got %s", "TheAnonymouseJoker@lemmy.ml", creator.String()) } } blob - f3ed6a3ebdfe703816ef494d354abc7a233d715a blob + f30ed30b332e1105f93591f3ae88cc4fc3ba7626 --- lemmy.go +++ lemmy.go @@ -15,8 +15,8 @@ type Community struct { FName string `json:"name"` Title string `json:"title"` Local bool - ActorID string `json:"actor_id"` - Published time.Time `json:"TODO"` + ActorID string `json:"actor_id"` + Published time.Time } func (c *Community) Name() string { return c.String() } @@ -41,8 +41,8 @@ type Post struct { Body string CreatorID int `json:"creator_id"` URL string - Published time.Time `json:"TODO"` - // Updated time.Time + Published time.Time + Updated time.Time } func (p *Post) Name() string { return strconv.Itoa(p.ID) } @@ -64,7 +64,7 @@ type Comment struct { References []int Content string CreatorID int `json:"creator_id"` - // Published time.Time + Published time.Time } func (c *Comment) Name() string { return strconv.Itoa(c.ID) } blob - 49517a363daef5b71884f9a0cf7f88346e8408d4 blob + 65acbc29767e59191370017966bd57273b48dfcf --- testdata/post.json +++ testdata/post.json @@ -1,70 +1,65 @@ { "post_view": { "post": { - "id": 4986856, - "name": "Please DM before self promoting a blog or website or product, otherwise it is subject to removal. Repeated or serious offenders may face the music.", - "creator_id": 2, - "community_id": 65, + "id": 1363000, + "name": "mpost", + "body": "Hello, world!", + "creator_id": 151025, + "community_id": 3, "removed": false, - "locked": true, - "published": "2023-10-02T12:27:13.123925", + "locked": false, + "published": "2023-08-23T07:22:39.559420Z", "deleted": false, "nsfw": false, - "ap_id": "https://lemmy.ml/post/5883569", + "ap_id": "https://lemmy.sdf.org/post/2583193", "local": false, - "language_id": 37, - "featured_community": true, + "language_id": 0, + "featured_community": false, "featured_local": false }, "creator": { - "id": 2, - "name": "TheAnonymouseJoker", - "avatar": "https://lemmy.ml/pictrs/image/8fd70139-4603-4fb7-8f16-d78f43790c1f.jpeg", + "id": 151025, + "name": "otl", + "display_name": "Oliver Lowe", + "avatar": "https://lemmy.sdf.org/pictrs/image/eea12c44-dc27-4e44-979e-0b206e90bcc4.png", "banned": false, - "published": "2020-06-07T12:34:31.646688", - "updated": "2022-06-17T08:27:41.447164", - "actor_id": "https://lemmy.ml/u/TheAnonymouseJoker", + "published": "2023-06-13T15:00:36.897955Z", + "actor_id": "https://lemmy.sdf.org/u/otl", + "bio": "[About me](http://www.olowe.co/about.html)", "local": false, + "banner": "https://lemmy.sdf.org/pictrs/image/2bfb82b5-a078-4411-bbf2-87c0df899041.png", "deleted": false, - "admin": false, "bot_account": false, - "instance_id": 2 + "instance_id": 57 }, "community": { - "id": 65, - "name": "privacy", - "title": "Privacy", - "description": "# A place to discuss privacy and freedom in the digital world.\n\nPrivacy has become a very important issue in modern society, with companies and governments constantly abusing their power, more and more people are waking up to the importance of digital privacy. \n\nIn this community everyone is welcome to post links and discuss topics related to privacy.\n\n### Some Rules\n\n \n - Posting a link to a website containing tracking isn't great, if contents of the website are behind a paywall maybe copy them into the post\n - Don't promote proprietary software\n - Try to keep things on topic\n - If you have a question, please try searching for previous discussions, maybe it has already been answered\n - Reposts are fine, but should have at least a couple of weeks in between so that the post can reach a new audience\n - Be nice :)\n\n### Related communities\n\n- [Lemmy.ml libre_culture](https://lemmy.ml/c/libre_culture)\n- [Lemmy.ml privatelife](https://lemmy.ml/c/privatelife)\n- [Lemmy.ml DeGoogle](https://lemmy.ml/c/degoogle)\n- [Lemmy.ca privacy](https://lemmy.ca/c/privacy)\n\n### Chat rooms\n\n- [Matrix/Element]Dead\n\n- [Discord](https://discord.gg/8xfrVjvngh)\n\nmuch thanks to @gary_host_laptop for the logo design :)", + "id": 3, + "name": "localtesting", + "title": "Testing", + "description": "A local community for testing lemmy on the aussie.zone instance.", "removed": false, - "published": "2019-11-15T23:50:53.712299", - "updated": "2023-07-21T19:06:26.177465", + "published": "2023-06-08T07:05:23.856002Z", + "updated": "2023-06-18T15:28:59.347113Z", "deleted": false, "nsfw": false, - "actor_id": "https://lemmy.ml/c/privacy", - "local": false, - "icon": "https://lemmy.ml/pictrs/image/h1ChnLuBHr.png", - "banner": "https://lemmy.ml/pictrs/image/DBjcqOW9ds.png", + "actor_id": "https://aussie.zone/c/localtesting", + "local": true, + "icon": "https://aussie.zone/pictrs/image/9775c10c-b40c-4481-a935-223a71953634.jpeg", "hidden": false, "posting_restricted_to_mods": false, - "instance_id": 2 + "instance_id": 1 }, "creator_banned_from_community": false, + "creator_is_moderator": false, + "creator_is_admin": false, "counts": { - "id": 609626, - "post_id": 4986856, + "post_id": 1363000, "comments": 0, - "score": 64, - "upvotes": 73, - "downvotes": 9, - "published": "2023-10-02T12:27:13.123925", - "newest_comment_time_necro": "2023-10-02T12:27:13.123925", - "newest_comment_time": "2023-10-02T12:27:13.123925", - "featured_community": true, - "featured_local": false, - "hot_rank": 0, - "hot_rank_active": 0, - "community_id": 65, - "creator_id": 2 + "score": 3, + "upvotes": 3, + "downvotes": 0, + "published": "2023-08-23T07:22:39.559420Z", + "newest_comment_time": "2023-08-23T07:22:39.559420Z" }, "subscribed": "NotSubscribed", "saved": false, @@ -74,213 +69,101 @@ }, "community_view": { "community": { - "id": 65, - "name": "privacy", - "title": "Privacy", - "description": "# A place to discuss privacy and freedom in the digital world.\n\nPrivacy has become a very important issue in modern society, with companies and governments constantly abusing their power, more and more people are waking up to the importance of digital privacy. \n\nIn this community everyone is welcome to post links and discuss topics related to privacy.\n\n### Some Rules\n\n \n - Posting a link to a website containing tracking isn't great, if contents of the website are behind a paywall maybe copy them into the post\n - Don't promote proprietary software\n - Try to keep things on topic\n - If you have a question, please try searching for previous discussions, maybe it has already been answered\n - Reposts are fine, but should have at least a couple of weeks in between so that the post can reach a new audience\n - Be nice :)\n\n### Related communities\n\n- [Lemmy.ml libre_culture](https://lemmy.ml/c/libre_culture)\n- [Lemmy.ml privatelife](https://lemmy.ml/c/privatelife)\n- [Lemmy.ml DeGoogle](https://lemmy.ml/c/degoogle)\n- [Lemmy.ca privacy](https://lemmy.ca/c/privacy)\n\n### Chat rooms\n\n- [Matrix/Element]Dead\n\n- [Discord](https://discord.gg/8xfrVjvngh)\n\nmuch thanks to @gary_host_laptop for the logo design :)", + "id": 3, + "name": "localtesting", + "title": "Testing", + "description": "A local community for testing lemmy on the aussie.zone instance.", "removed": false, - "published": "2019-11-15T23:50:53.712299", - "updated": "2023-07-21T19:06:26.177465", + "published": "2023-06-08T07:05:23.856002Z", + "updated": "2023-06-18T15:28:59.347113Z", "deleted": false, "nsfw": false, - "actor_id": "https://lemmy.ml/c/privacy", - "local": false, - "icon": "https://lemmy.ml/pictrs/image/h1ChnLuBHr.png", - "banner": "https://lemmy.ml/pictrs/image/DBjcqOW9ds.png", + "actor_id": "https://aussie.zone/c/localtesting", + "local": true, + "icon": "https://aussie.zone/pictrs/image/9775c10c-b40c-4481-a935-223a71953634.jpeg", "hidden": false, "posting_restricted_to_mods": false, - "instance_id": 2 + "instance_id": 1 }, "subscribed": "NotSubscribed", "blocked": false, "counts": { - "id": 46, - "community_id": 65, - "subscribers": 277, - "posts": 1149, - "comments": 26900, - "published": "2019-11-15T23:50:53.712299", - "users_active_day": 147, - "users_active_week": 671, - "users_active_month": 2450, - "users_active_half_year": 7408, - "hot_rank": 0 + "community_id": 3, + "subscribers": 94, + "posts": 69, + "comments": 129, + "published": "2023-06-08T07:05:23.856002Z", + "users_active_day": 4, + "users_active_week": 4, + "users_active_month": 13, + "users_active_half_year": 54 } }, "moderators": [ { "community": { - "id": 65, - "name": "privacy", - "title": "Privacy", - "description": "# A place to discuss privacy and freedom in the digital world.\n\nPrivacy has become a very important issue in modern society, with companies and governments constantly abusing their power, more and more people are waking up to the importance of digital privacy. \n\nIn this community everyone is welcome to post links and discuss topics related to privacy.\n\n### Some Rules\n\n \n - Posting a link to a website containing tracking isn't great, if contents of the website are behind a paywall maybe copy them into the post\n - Don't promote proprietary software\n - Try to keep things on topic\n - If you have a question, please try searching for previous discussions, maybe it has already been answered\n - Reposts are fine, but should have at least a couple of weeks in between so that the post can reach a new audience\n - Be nice :)\n\n### Related communities\n\n- [Lemmy.ml libre_culture](https://lemmy.ml/c/libre_culture)\n- [Lemmy.ml privatelife](https://lemmy.ml/c/privatelife)\n- [Lemmy.ml DeGoogle](https://lemmy.ml/c/degoogle)\n- [Lemmy.ca privacy](https://lemmy.ca/c/privacy)\n\n### Chat rooms\n\n- [Matrix/Element]Dead\n\n- [Discord](https://discord.gg/8xfrVjvngh)\n\nmuch thanks to @gary_host_laptop for the logo design :)", + "id": 3, + "name": "localtesting", + "title": "Testing", + "description": "A local community for testing lemmy on the aussie.zone instance.", "removed": false, - "published": "2019-11-15T23:50:53.712299", - "updated": "2023-07-21T19:06:26.177465", + "published": "2023-06-08T07:05:23.856002Z", + "updated": "2023-06-18T15:28:59.347113Z", "deleted": false, "nsfw": false, - "actor_id": "https://lemmy.ml/c/privacy", - "local": false, - "icon": "https://lemmy.ml/pictrs/image/h1ChnLuBHr.png", - "banner": "https://lemmy.ml/pictrs/image/DBjcqOW9ds.png", + "actor_id": "https://aussie.zone/c/localtesting", + "local": true, + "icon": "https://aussie.zone/pictrs/image/9775c10c-b40c-4481-a935-223a71953634.jpeg", "hidden": false, "posting_restricted_to_mods": false, - "instance_id": 2 + "instance_id": 1 }, "moderator": { - "id": 83, - "name": "k_o_t", - "avatar": "https://lemmy.ml/pictrs/image/992c7275-dd2a-4fa3-aace-6819e72995fb.png", - "banned": false, - "published": "2019-12-29T11:51:05.628232", - "updated": "2022-01-13T15:18:29.470615", - "actor_id": "https://lemmy.ml/u/k_o_t", - "local": false, - "deleted": false, - "matrix_user_id": "@brokoli:matrix.org", - "admin": false, - "bot_account": false, - "instance_id": 2 - } - }, - { - "community": { - "id": 65, - "name": "privacy", - "title": "Privacy", - "description": "# A place to discuss privacy and freedom in the digital world.\n\nPrivacy has become a very important issue in modern society, with companies and governments constantly abusing their power, more and more people are waking up to the importance of digital privacy. \n\nIn this community everyone is welcome to post links and discuss topics related to privacy.\n\n### Some Rules\n\n \n - Posting a link to a website containing tracking isn't great, if contents of the website are behind a paywall maybe copy them into the post\n - Don't promote proprietary software\n - Try to keep things on topic\n - If you have a question, please try searching for previous discussions, maybe it has already been answered\n - Reposts are fine, but should have at least a couple of weeks in between so that the post can reach a new audience\n - Be nice :)\n\n### Related communities\n\n- [Lemmy.ml libre_culture](https://lemmy.ml/c/libre_culture)\n- [Lemmy.ml privatelife](https://lemmy.ml/c/privatelife)\n- [Lemmy.ml DeGoogle](https://lemmy.ml/c/degoogle)\n- [Lemmy.ca privacy](https://lemmy.ca/c/privacy)\n\n### Chat rooms\n\n- [Matrix/Element]Dead\n\n- [Discord](https://discord.gg/8xfrVjvngh)\n\nmuch thanks to @gary_host_laptop for the logo design :)", - "removed": false, - "published": "2019-11-15T23:50:53.712299", - "updated": "2023-07-21T19:06:26.177465", - "deleted": false, - "nsfw": false, - "actor_id": "https://lemmy.ml/c/privacy", - "local": false, - "icon": "https://lemmy.ml/pictrs/image/h1ChnLuBHr.png", - "banner": "https://lemmy.ml/pictrs/image/DBjcqOW9ds.png", - "hidden": false, - "posting_restricted_to_mods": false, - "instance_id": 2 - }, - "moderator": { - "id": 805, - "name": "tmpod", - "display_name": "Tmpod", - "avatar": "https://lemmy.pt/pictrs/image/gIPQUt3mxw.png", - "banned": false, - "published": "2021-09-10T19:37:20.367073", - "updated": "2022-08-04T16:23:06.747838", - "actor_id": "https://lemmy.pt/u/tmpod", - "bio": "Estudante de Engenharia Inform\u00e1tica apaixonado pela \u00e1rea; algures em Portugal.\n\nAdministrador da inst\u00e2ncia lemmy.pt.\n\n---\n\nComputer Science student, passionate about the field; somewhere in Portugal.\n\nlemmy.pt instance administrator.\n\n---\n\nhttps://tmpod.dev", - "local": false, - "banner": "https://lemmy.pt/pictrs/image/iLIlqIIuaW.jpg", - "deleted": false, - "matrix_user_id": "@tmpod:matrix.org", - "admin": false, - "bot_account": false, - "instance_id": 69 - } - }, - { - "community": { - "id": 65, - "name": "privacy", - "title": "Privacy", - "description": "# A place to discuss privacy and freedom in the digital world.\n\nPrivacy has become a very important issue in modern society, with companies and governments constantly abusing their power, more and more people are waking up to the importance of digital privacy. \n\nIn this community everyone is welcome to post links and discuss topics related to privacy.\n\n### Some Rules\n\n \n - Posting a link to a website containing tracking isn't great, if contents of the website are behind a paywall maybe copy them into the post\n - Don't promote proprietary software\n - Try to keep things on topic\n - If you have a question, please try searching for previous discussions, maybe it has already been answered\n - Reposts are fine, but should have at least a couple of weeks in between so that the post can reach a new audience\n - Be nice :)\n\n### Related communities\n\n- [Lemmy.ml libre_culture](https://lemmy.ml/c/libre_culture)\n- [Lemmy.ml privatelife](https://lemmy.ml/c/privatelife)\n- [Lemmy.ml DeGoogle](https://lemmy.ml/c/degoogle)\n- [Lemmy.ca privacy](https://lemmy.ca/c/privacy)\n\n### Chat rooms\n\n- [Matrix/Element]Dead\n\n- [Discord](https://discord.gg/8xfrVjvngh)\n\nmuch thanks to @gary_host_laptop for the logo design :)", - "removed": false, - "published": "2019-11-15T23:50:53.712299", - "updated": "2023-07-21T19:06:26.177465", - "deleted": false, - "nsfw": false, - "actor_id": "https://lemmy.ml/c/privacy", - "local": false, - "icon": "https://lemmy.ml/pictrs/image/h1ChnLuBHr.png", - "banner": "https://lemmy.ml/pictrs/image/DBjcqOW9ds.png", - "hidden": false, - "posting_restricted_to_mods": false, - "instance_id": 2 - }, - "moderator": { "id": 2, - "name": "TheAnonymouseJoker", - "avatar": "https://lemmy.ml/pictrs/image/8fd70139-4603-4fb7-8f16-d78f43790c1f.jpeg", + "name": "admin", + "avatar": "https://aussie.zone/pictrs/image/95fc3553-a929-4143-a370-605db92fe4ae.jpeg", "banned": false, - "published": "2020-06-07T12:34:31.646688", - "updated": "2022-06-17T08:27:41.447164", - "actor_id": "https://lemmy.ml/u/TheAnonymouseJoker", - "local": false, + "published": "2023-06-08T06:56:38.842362Z", + "actor_id": "https://aussie.zone/u/admin", + "bio": "Benevolent dictator", + "local": true, "deleted": false, - "admin": false, "bot_account": false, - "instance_id": 2 + "instance_id": 1 } }, { "community": { - "id": 65, - "name": "privacy", - "title": "Privacy", - "description": "# A place to discuss privacy and freedom in the digital world.\n\nPrivacy has become a very important issue in modern society, with companies and governments constantly abusing their power, more and more people are waking up to the importance of digital privacy. \n\nIn this community everyone is welcome to post links and discuss topics related to privacy.\n\n### Some Rules\n\n \n - Posting a link to a website containing tracking isn't great, if contents of the website are behind a paywall maybe copy them into the post\n - Don't promote proprietary software\n - Try to keep things on topic\n - If you have a question, please try searching for previous discussions, maybe it has already been answered\n - Reposts are fine, but should have at least a couple of weeks in between so that the post can reach a new audience\n - Be nice :)\n\n### Related communities\n\n- [Lemmy.ml libre_culture](https://lemmy.ml/c/libre_culture)\n- [Lemmy.ml privatelife](https://lemmy.ml/c/privatelife)\n- [Lemmy.ml DeGoogle](https://lemmy.ml/c/degoogle)\n- [Lemmy.ca privacy](https://lemmy.ca/c/privacy)\n\n### Chat rooms\n\n- [Matrix/Element]Dead\n\n- [Discord](https://discord.gg/8xfrVjvngh)\n\nmuch thanks to @gary_host_laptop for the logo design :)", + "id": 3, + "name": "localtesting", + "title": "Testing", + "description": "A local community for testing lemmy on the aussie.zone instance.", "removed": false, - "published": "2019-11-15T23:50:53.712299", - "updated": "2023-07-21T19:06:26.177465", + "published": "2023-06-08T07:05:23.856002Z", + "updated": "2023-06-18T15:28:59.347113Z", "deleted": false, "nsfw": false, - "actor_id": "https://lemmy.ml/c/privacy", - "local": false, - "icon": "https://lemmy.ml/pictrs/image/h1ChnLuBHr.png", - "banner": "https://lemmy.ml/pictrs/image/DBjcqOW9ds.png", + "actor_id": "https://aussie.zone/c/localtesting", + "local": true, + "icon": "https://aussie.zone/pictrs/image/9775c10c-b40c-4481-a935-223a71953634.jpeg", "hidden": false, "posting_restricted_to_mods": false, - "instance_id": 2 + "instance_id": 1 }, "moderator": { - "id": 4651, - "name": "Yayannick", - "avatar": "https://lemmy.ml/pictrs/image/99671f4f-dc19-437d-9f91-18a17e3e07ef.png", + "id": 3, + "name": "lodion", + "display_name": "Lodion \ud83c\udde6\ud83c\uddfa", + "avatar": "https://aussie.zone/pictrs/image/2644a4fe-cce3-4126-b80b-40e6369976d1.jpeg", "banned": false, - "published": "2021-12-10T08:12:33.393328", - "updated": "2023-01-27T14:20:11.869598", - "actor_id": "https://lemmy.ml/u/Yayannick", - "bio": "The last man on Earth hears a knock on the door.", - "local": false, + "published": "2023-06-08T06:59:14.987834Z", + "actor_id": "https://aussie.zone/u/lodion", + "bio": "I also have backup accounts on these instances: \nhttps://beehaw.org/u/lodion \nhttps://sh.itjust.works/u/lodion \nhttps://lemmy.world/u/lodion \nhttps://lemm.ee/u/lodion \nhttps://reddthat.com/u/lodion", + "local": true, "deleted": false, - "admin": false, "bot_account": false, - "instance_id": 2 + "instance_id": 1 } - }, - { - "community": { - "id": 65, - "name": "privacy", - "title": "Privacy", - "description": "# A place to discuss privacy and freedom in the digital world.\n\nPrivacy has become a very important issue in modern society, with companies and governments constantly abusing their power, more and more people are waking up to the importance of digital privacy. \n\nIn this community everyone is welcome to post links and discuss topics related to privacy.\n\n### Some Rules\n\n \n - Posting a link to a website containing tracking isn't great, if contents of the website are behind a paywall maybe copy them into the post\n - Don't promote proprietary software\n - Try to keep things on topic\n - If you have a question, please try searching for previous discussions, maybe it has already been answered\n - Reposts are fine, but should have at least a couple of weeks in between so that the post can reach a new audience\n - Be nice :)\n\n### Related communities\n\n- [Lemmy.ml libre_culture](https://lemmy.ml/c/libre_culture)\n- [Lemmy.ml privatelife](https://lemmy.ml/c/privatelife)\n- [Lemmy.ml DeGoogle](https://lemmy.ml/c/degoogle)\n- [Lemmy.ca privacy](https://lemmy.ca/c/privacy)\n\n### Chat rooms\n\n- [Matrix/Element]Dead\n\n- [Discord](https://discord.gg/8xfrVjvngh)\n\nmuch thanks to @gary_host_laptop for the logo design :)", - "removed": false, - "published": "2019-11-15T23:50:53.712299", - "updated": "2023-07-21T19:06:26.177465", - "deleted": false, - "nsfw": false, - "actor_id": "https://lemmy.ml/c/privacy", - "local": false, - "icon": "https://lemmy.ml/pictrs/image/h1ChnLuBHr.png", - "banner": "https://lemmy.ml/pictrs/image/DBjcqOW9ds.png", - "hidden": false, - "posting_restricted_to_mods": false, - "instance_id": 2 - }, - "moderator": { - "id": 3061, - "name": "ranok", - "banned": false, - "published": "2023-06-01T12:58:56.504051", - "actor_id": "https://sopuli.xyz/u/ranok", - "local": false, - "deleted": false, - "admin": false, - "bot_account": false, - "instance_id": 11 - } } ], "cross_posts": []