Lemmy App Development

693 readers
18 users here now

A place for Lemmy builders to chat about building apps, clients, tools and bots for the Lemmy platform.

On-Topic:

Off-Topic:

founded 1 year ago
MODERATORS
1
 
 

cross-posted from: https://lemmy.world/post/3252643

lemmy.readme.io uploaded some great API documentation to get started making your own Lemmy client.

Proved very useful in making my iOS client Lunar

2
 
 

I'm using lemmy-js-client for app development. I want to render comments in the nested form (like normal people do).

The problem is, the lemmy backend spits out comment lists in a fashion that is unfriendly for nested rendering. Why? It outputs comments whose paths are like follows (for example):

0.1.2.3.4

0.1.2.1

0.1.2.3.4.5

0.1.3.1.5

0.1

Let's say the limit that I've set here is 10. Many a times, the parent comments of the comments in the page are out of the page.

For example, let's say I asked lemmy for comments for a given post. It gives me an output like above. There are many children comments here on page 1 (like 0.1.2.1, 0.1.2.3.4 and so on). Their parent (0.1.2) is NOT on this page. It is on the page that follows.

Hence, I would need to do client side bs to get the correct parent comments.

What is your approach for doing the above?

This is what I have settled for now unfortunately. I fetch all the comments under a post and then convert them in my nested form. This means, that my app doesn't paginate. This thus results in really slow loading times for posts with more comments. The more comments a post has, the slower they will load. This sucks.

I tried other ways, mind you. While implementing pagination, I simply removed orphan comments when on a given page. If the user decided to go to page 2 (simply by scrolling), suddenly, these orphan comments would not be orphans anymore due to them finding their parent comments. This in turn, fucked with my ui completely (which was obvious), thus making the list randomly scroll like crazy. This was a really shitty experience for the user.

Sooooo what have you guys done? How have you handled the situation?

3
 
 

I'm trying to follow the instructions at https://blog.joinmastodon.org/2018/06/how-to-implement-a-basic-activitypub-server/

I get the error message: {"error":"Unable to fetch key JSON at https://<domain>/actor"}

The actor file is located at: /var/www/<subdomain>/actor

that contains:

{
    "@context": [
        "https://www.w3.org/ns/activitystreams",
        "https://w3id.org/security/v1"
    ],

    "id": "https://<domain>/actor",
    "type": "Person",
    "preferredUsername": "alice",
    "inbox": "https://<domain>/inbox",

    "publicKey": {
        "id": "https://<domain>/actor#main-key",
        "owner": "https://<domain>/actor",
        "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnioC3W5cHbHLo+ln4QPm\n6EX1Ypvs5h+h47b5RwhF+2N84dSHXURUuA6a33+IlVqiO/3gGxIX+4MJuSDAxGZM\nWFDbuqDnHft2zWorKmIqyDzSSB/oMSqOVL8QV1KYWsCyhw9v2l5U6EIw2Z7u3Fc9\nW19dumK0ieL7CPME2dJGV5quBoa2AGg0D36XCp8hAWMXGUnlEcaqjyePJg9/quZn\no3W/+h5ujoUQG73SIUaJdsK16Q0E7o5N7JP7pqqE8p8pEXtpwXJJYE9y9ItTqvRS\na29xymyboCI6jSK+VTgjz1tj6W+EGQsPfka6t8Gq82NL00VxBEYb/eiEFuOSy4RL\ndwIDAQAB\n-----END PUBLIC KEY-----"
    }
}

I haven't been able to find out what that error means. Is it unable to find the actor file? Maybe I should change /actor to /actor/ and put the file inside that? If so, what should the filename be? Is it some problem with the public key inside the JSON? Is it mad about the newlines?

4
 
 

I’ve updated @[email protected] to remember the whole tree of comments when replying to you, so it can do follow-up responses. You still have to mention it on every message, though. Example in the comments.

5
13
submitted 4 months ago* (last edited 4 months ago) by [email protected] to c/[email protected]
 
 

There's now a swagger documentation for the Lemmy API.

See also https://mv-gh.github.io/lemmy_openapi_spec/

6
 
 

I just implemented a user overview of mixed posts and comments, but I'm unsure how to do so while respecting sort (hot, new, old, etc.). Currently I merge the user's comments and posts into a list, then sort them all by timestamp.

Because sorting is handled on the server, and merging posts/comments happens after, I can't see how I can't respect sort and still merge the two sets. Does anyone have any pointers?

I expect a similar issue would arise for the unified inbox view also (replies, mentions, and private messages), although in that case there's less need to sort by anything other than recency.

EDIT: here's the relevant ts code in the official lemmy ui. it sorts by date if sort is new, which i already do, then otherwise it just sorts by "score".

https://github.com/LemmyNet/lemmy-ui/blob/79ed5903354067636f5eb9686ff0a005117bc541/src/shared/components/person/person-details.tsx#L245

7
 
 

I recall someone mentioning a way to do it through an ActivityPub “resolve object” endpoint (or something like that) but I couldn’t find anything on it again. #1101 will solve this, but how are you guys handling this in the meantime?

8
 
 

So I'm developing a mobile client using React Native, where I'm utilizing Lemmy's messaging functionality as well. This makes it extremely crucial to have notification support (including push notifications).

How are you guys dealing with this problem? This is what I think an elegant solution could look like. We would need to achieve two things:

  1. Bring back websockets only for notifications by directly changing lemmy server side code.
  2. Find where the email notification code is at, and simply implement expo notifications there.

Whaddya think?

9
 
 

currently my client displays child comments/replies to a given comment based on a get-comments request and the sort arg. if a child comment is returned by such a request, it will be included as part of the tree, but otherwise not. it means the child is subject to sorting itself.

but what is needed is that if a parent comment is displayed/returned by request/sort arg, all its children should be also. that seems to me to be how the webUI works also.

any tips on how to ensure that?

10
 
 

cross-posted from: https://lemmy.ca/post/6770347

This is a very small update, but hopefully it's helpful! As I mentioned in the last update, I'm a little tied up with other commitments right now, so I haven't had a chance to implement the other features on the to-do list. This one was requested the other day, and it was simple to add since I could reuse a lot of existing code.


Links:


❓ What is Instance Assistant?

If you're new to Instance Assistant, it is a browser extension with a collection of tools and features to simplify your browsing experience on Lemmy and Kbin. It is available on Chrome, Firefox, and Edge; you can also install it from the releases page on GitHub.

For a full list of features, please see the GitHub homepage: https://github.com/cynber/lemmy-instance-assistant


⭐ What's new in v1.2.6?

  • Redirect user profile pages: When you want to message a user and click on their profile, you might end up on a foreign instance. To message them, you need to modify the URL or copy/paste. Instead, you will now find a little button to jump you to your home instance.


💛 Also

Thank you for all the suggestions and feedback! Like I said before, I'm really happy to see that people are using the extension and finding it useful. Please continue to make suggestions and contribute your expertise.

Cheers :)

11
 
 

My Lemmy Schedule app now includes the option to get notified of new posts in a specific community!

In case you haven't heard about the app before, here's what other things it can do:

  • schedule a post and post it to multiple communities
    • you can upload an image as well and choose between uploading to your Lemmy instance or to Imgur
  • create a recurring post that gets posted at a specific date and time (especially useful for daily/weekly/monthly/end-of-month threads)
  • schedule pinning and unpinning of posts (instance and community)
    • the pinning and unpinning can be specified as part of creating a post
  • the aforementioned notifications about unread posts from a specific community (useful for mods)
    • can be also set using a recurring schedule, so you can get the report daily/weekly/monthly etc.

To learn more, visit the [email protected] community.

P.S. It's open source and can be self-hosted using docker!

12
 
 

I’d love to host my own Lemmy server but I’m just a script kiddie

13
14
 
 

Where are you all finding details on what features are included in each version of lemmy-js-client?

15
 
 

I hope this is allowed, if not, I'll delete the post, I just wanted to share some stats of my bot because I'm quite excited about them.


 ---------- --------- ----------- ------------------------- ------------------------- ------------------------ 
  Comments   Upvotes   Downvotes   Negative comments count   Positive comments count   Neutral comments count  
 ---------- --------- ----------- ------------------------- ------------------------- ------------------------ 
  2769       13734     426         0                         2769                      0                       
 ---------- --------- ----------- ------------------------- ------------------------- ------------------------

Note that the bots default upvote is not considered for the stats. Positive comments are those where there's more upvotes than downvotes, neutral ones are those where downvotes and upvotes are the same and negative are when the comment has more downvotes than upvotes.

16
 
 

I've made an open source tool for scheduling posts to Lemmy, you can find it at https://schedule.lemmings.world. It can be used by users from any instance and it can be self-hosted if you wish so!

Changes since the last time I posted about it:

  • you can now login with 2FA enabled
  • you can schedule pin and unpin of posts in a community if you're the mod
  • you can schedule pin and unpin of posts in an instance if you're the admin
  • when creating a post, you can choose to pin it to the community (if you're a mod)
  • you can choose the language of your posts
  • an official support community has been created at [email protected]
  • you can post the same post into multiple communities easily, just select the communities and multiple scheduled posts will be created

Let me know what you think!

17
 
 

I'm starting lemmy-ui with:

LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy-alpha:8541 node dist/js/server.js

Running against the drone-lemmy instances created by lemmy_server's api-tests scripts. I'm running latest main checkout on both projects.

My browser gives me:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8536/api/v3/community/list?type_=Local&sort=TopMonth&limit=50&page=1. (Reason: CORS request did not succeed). Status code: (null).

api-tests scripts build dev mode, I thought CORS was turned off? I've played around with adding LEMMY_CORS_ORIGIN=* - but it doesn't help.

EDIT: reading this post closer, I see 8536 vs. 8541. If I manually refresh my browser against lemmy-ui on port 1234, it works... but I wonder where 8536 is getting picked up?

Thank you and I hope you are having a great weekend.

18
7
submitted 10 months ago* (last edited 10 months ago) by [email protected] to c/[email protected]
 
 

I'm in the process of developing a bot. My intention is to scan all comments regardless of depth in a given community up to a certain date, so it receives only the comments made since the last request. I want to play nice so I'm also trying to do it on the less amount of queries possible.

The community I'm testing this is fairly small, it has 40 comments total, but the problem is that when I request comments without specifying max_depth, and sort ordered by New, I receive only 10 comments, if I try to specify page, or limit, I get an error {"error":"couldnt_get_comments"}.

If I don't specify page or limit, and set an arbitrary number for max_depth, like 4, I get the 40 comments I'm expecting.

My question is: what's the correct way to request comments? My intention is doing something similar to an user pressing "Comments" on front of a community, like calling the community URL with params ?dataType=Comment&amp;page=1&amp;sort=New

19
4
App to schedule posts on Lemmy (schedule.lemmings.world)
submitted 10 months ago* (last edited 10 months ago) by [email protected] to c/[email protected]
 
 

I've made an app that makes it possible to schedule a post in Lemmy at an arbitrary time. It's available at https://schedule.lemmings.world and can be used by people from any instance.

Let me know what you think!

P.S. This post was made from the app!

Edit: And it's open source!

20
 
 

I have a question about the semantics of child_count in the comment list API endpoint. Sorry for being related to an earlier question but I haven't quite figured it out yet.

My assumption was that child_count would indicate the amount of total descendants of a comment, regardless of depth. But take this case for example:

$ curl 'https://lemmy.ml/api/v3/comment/list?parent_id=2157873&amp;max_depth=999&amp;limit=999' | jq '.comments[]
| { path: .comment.path, id: .comment.id, content: .comment.content, child_count: .counts.child_count }'
{
  "path": "0.2157873",
  "id": 2157873,
  "content": "Really cool! I'm excited to learn more about you and the project!\n\nWhat's the format? Should we submit questions beforehand, or will you process questions that arrive at the start time? I've never participated in an AMA  😅 ",
  "child_count": 9
}
{
  "path": "0.2157873.2158260",
  "id": 2158260,
  "content": "You just post questions as top-level replies to the stickied thread that day, and we'll be online to answer them.",
  "child_count": 6
}
{
  "path": "0.2157873.2158260.2158286",
  "id": 2158286,
  "content": "Cool. Thank you for doing this!",
  "child_count": 1
}
{
  "path": "0.2157873.2158260.2229041",
  "id": 2229041,
  "content": "Post doesn’t mention, where is the AMA? Here or in a different community?",
  "child_count": 3
}
{
  "path": "0.2157873.2158260.2158286.2158743",
  "id": 2158743,
  "content": "No probs!",
  "child_count": 0
}
{
  "path": "0.2157873.2158260.2229041.2231423",
  "id": 2231423,
  "content": "As the post mentions, it will be stickied to the top of lemmy.ml ",
  "child_count": 2
}
{
  "path": "0.2157873.2158260.2229041.2231423.2231737",
  "id": 2231737,
  "content": "Thanks for the details. May be I’m missing something, but I don’t see that detail in the post. ![](https://programming.dev/pictrs/image/82c90859-9cfb-4c00-80d8-7e96bfd96c1c.jpeg)",
  "child_count": 1
}
{
  "path": "0.2157873.2158260.2229041.2231423.2231737.2238347",
  "id": 2238347,
  "content": "Oops my bad, that was something I responded to in a comment.",
  "child_count": 0
}

I see that comment 2157873 has a child count of 9, with one direct descendant (2158260). The descendant has a child count of 6. I'd reason that comment 2157873 has 2 direct descendants that aren't visible in the API response yet, because it has one visible descendant having a child count of 6 (i.e. 9 - 1 - 6 = 2). My calculation seems incorrect because (a) I don't see a 'Load more' indicator for this part of the comment thread on https://lemmy.ml/post/2671212, and (b) every comment shown there also seems present in the API response.

Am I understanding the meaning of child_count correctly?

21
 
 

With every new App published on IOS I wonder again how the financing works. Just through donations, or do you "take one for the team"?

22
 
 

I'm creating an AGPL-licensed Lemmy web UI.

While working on the comment section I wondered: what's the best way to retrieve the total amount of direct descendants of a comment? I'm not talking about child_count as this appears to count descendants at any depth.

My use case is displaying a 'Load X more' button that for a given comment loads any direct descendants that are not yet being displayed.

23
2
submitted 10 months ago* (last edited 10 months ago) by CreatureSurvive to c/[email protected]
 
 

I’m in the process of submitting my Lemmy client (Arctic) to TestFlight, and I had some concerns about NSFW options in my app.

As per section 1.2 User-Generated Content it states that NSFW content needs to be disabled by default, and can only be enabled through the website.

Apps with user-generated content or services that end up being used primarily for pornographic content, Chatroulette-style experiences, objectification of real people (e.g. “hot-or-not” voting), making physical threats, or bullying do not belong on the App Store and may be removed without notice. If your app includes user-generated content from a web-based service, it may display incidental mature “NSFW” content, provided that the content is hidden by default and only displayed when the user turns it on via your website.

Does this mean that I am not aloud to include any options in my apps interface regarding NSFW content, eg: Blur / Hide NSFW Content, Even if the content is hidden by default?

Any pointers here would be useful. I do see that other Lemmy clients are including options within apps and have not had any issues so far, but the policy seems to indicate this is not allowed.

24
8
submitted 11 months ago* (last edited 11 months ago) by [email protected] to c/[email protected]
 
 

You can find it here. Source code in the link.

25
 
 

I've updated the bot and added the possibility of translating hardcoded links (like this one: https://lemmy.world/post/2355178 or this one: https://lemmy.world/comment/1863672) to posts/comments with links from your instance when you mention him. I'll show an example in comments.

view more: next ›