Lemmy App Development

746 readers
1 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 2 years ago
MODERATORS
26
 
 

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%3Bmax_depth=999&amp%3Blimit=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?

27
 
 

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"?

28
 
 

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.

29
1
submitted 2 years ago* (last edited 2 years ago) by [email protected] 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.

30
2
submitted 2 years ago* (last edited 2 years ago) by [email protected] to c/[email protected]
 
 

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

31
 
 

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.

32
 
 

It now supports 0.18.3 and contrary to previous releases it supports unauthenticated requests where it makes sense.

https://github.com/RikudouSage/LemmyApi/

33
 
 

Someone was asking about it in support, so I was curious to try it. The Rust code has HideCommunity, I even tried to bypass the JavaScript client and do a direct API call.

Does anyone see the function call to send a HideCommunity object?

Where it might be disabled in the Rust code? I know it goes all the way into the database and is on SELECT statements.

Thank you

34
 
 

For lemmy server testing and performance baseline measurement, I think it would be cool to have every API call exercised.

Anyone willing to create and share some JavaScript client code? Normally these are run with Jest via NodeJS - but we can make it an extra step to integrate into Jest. I'm just thinking someone doing front-end app work can do a well organized hit on every API surface.

You can skip the creation of a user if you want, that code is already in the testing

Probably ideal to organize moderator vs non-moderator.

Something like: edit profile with every option one at a time, create a community, edit it, create posts, edit, delete, undelete, reply, etc. Imagine you were doing interactive tests of a major upgrade and wanted to hit every feature and button.

Right now most of that testing is done in independent scripts, such as a user test: https://github.com/LemmyNet/lemmy/blob/main/api_tests/src/user.spec.ts

And you can see it only tests editing a profile is working, not that actual features change their behavior. Although I've started to add that for back-end behaviors like showing read/unread posts on the list. Front-end devs are the ones who know what end-users do and the fringe cases to look out for. Thank you.

35
 
 

You will want to change your Cargo.toml to point to the Lemmy Github repository + either a specific tag or branch for the version you want to target.

See the examples here: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-dependencies-from-git-repositories

36
 
 

I'm getting a "user_already_exists" error from /user/save_user_settings no matter what settings I try to change. The JWT is valid, and this is happening on multiple instances the same (programming.dev, lemm.ee, etc.) Anyone have any ideas why I'd be getting this? Here's my payload:

{
  show_bot_accounts: true,
  auth: token
}

Edit: This issue describes a bug where this happens when the avatar field is not included. Just tested it and that's the same problem I'm running into. I fixed it temporarily by passing the current avatar url.

37
 
 

Is .moderators supposed to be on GetCommunity() result? I can't seem to find it in lemmy_server api_tests context. All I'm getting is languages and community_view

EDIT: Wait, so there is a "CommunityResponse" and a "GetCommunityResponse", object? What call do I use to Get a GetCommunityResponse object?

https://github.com/LemmyNet/lemmy-js-client/blob/2aa12c04a312ae4ae235f6d97c86a61f58c67494/src/types/GetCommunityResponse.ts#L7

38
 
 

I'm not 100% sure if this is the right community for my question. Should that be the case, I want to apologize.

Alternative to mega-threads: Could this feature be implemented by a Lemmy instance?

Basically, my idea is to allow community mods to quarantine posts into groups called super-threads. These super-threads would show up in the community appearing like regular post. But when you open such a super-thread, you would see an overview over all the posts quarantined to this super-thread. It would look similar to a community. Quarantined posts could still be found by a search but they wouldn't show up in the community overview or the general feed. Only the super-threads themselves would show up there. That way, mods could stop a single topic from overwhelming a community by quarantining all related posts to one super-thread. Thereby, super-threads could replace existing mega-threads while maintaining the forum-like form of Lemmy.

39
 
 

Is there anywhere that lemmy's various types of internal links are documented? like !community links @user links, links of the form https://lemmy.com/c/[email protected]. i have also seen links that just have "/c/[email protected]"... at the moment i'm only developing rendering code for them as i happen upon them, which is ad-hoc

40
 
 

cross-posted from: https://lemm.ee/post/1358038

Hi everyone! I'm happy to announce that my iOS Lemmy app "Avelon" is finally ready for beta testing! I've been working tirelessly on the app lately and I think it is turning into a quite solid experience now. I'm very excited to hear what you think and gather more feedback before I move towards an App Store release.

My focus for Avelon has been to polish the base functionality as much as possible to ensure that the day-to-day browsing feels as good as possible. I've also done things a bit differently to make it easier for new people to try out the Fediverse. Rather than requiring new users to look through a complicated list of instances the first time, the app automatically shuffles a list of preset instances so you don't need to think about it until later when you register. This will hopefully also reduce the load on individual servers.

Features

Avelon already supports quite a few cool features:

  • Posts and feeds
    • Clean UI to explore all your feeds
    • A pretty nice comment view
    • Support for images, GIFs, videos, youtube
    • See community feeds and sidebars
    • Quick search communities and subscriptions
  • Login to your account
    • Reply to posts/comments (with markdown highlighter!)
    • View and edit your old comments
    • Upvote comments and posts
    • View/manage your followed communities
  • Design & customization
    • Dark and light mode with customizable accent color
    • Compact posts, large posts and gallery view
    • Footer/header bars automatically hide for a cleaner experience
    • Change behavior such as tap to collapse, default sorting etc.
    • Long press actions for a less cluttered interface

..and probably some other things I can't remember just now.

Screenshots

Check these out!

Screenshot 1

Screenshot 2

Screenshot 3

Screenshot 4

Join the beta

The beta is available on testflight through this link (limited to 1000 testers for now):

Join Avelon Beta on Testflight

The app is supported on all iPhones with iOS 16 and higher (worked ok on my old iPhone X!). I'd love to hear what you think about the overall user experience, design, functionality, stability as well as any bugs or issues you might find. A few important features are still missing, most notably adding new posts. I'd love to hear what additions you are most interested in me looking at first:

  • Creating posts
  • Viewing users comments/posts
  • Saving posts/comments
  • Report/mod tools
  • Multiple accounts
  • Themes/more customization
  • Improved image/video viewer
  • Anything else?

Thank you & future plans

First, I'd like to thank Christian Selig (the developer of the Apollo app) for creating a really amazing app that I've been using every day for the last several years. As you can tell, Avelon is definitely inspired by Apollo (though I think I've put my own personal spin on the design and functionality!).

If people enjoy Avelon I'd like to spend more of my free time working on it and improving the app over time. In the spirit of transparency, I'd like to mention that I might do some kind of "pro" version at some point later on to support the project. All the base functionality people need will of course be free, but pro features could be additional "nice-to-have" features like themes or advanced tools etc. I'm not planning to do anything paid just yet though, just wanted to mention it. Right now my focus is to provide a great experience and to help build the Lemmy platform into something even better.

Finally I'd like to thank the Lemmy developers as well as everyone using the platform. Everyone contributing is making this platform the amazing place it is turning into. I personally haven't browsed the site-that-should-not-be-named since the API shut down - I decided to spend all that time on developing this app instead. And I'm really excited to see what Lemmy becomes over the years.

Sigve Røkenes

/evgiz

41
42
 
 

Hey, I'm thinking about creating a web-based (PWA) app for subscribing to Lemmy RSS feeds, mainly for notifications.

I've noticed that I strongly prefer to be notified of changes in my inbox or in my subscribed communities and I'm using a simple RSS reader now, but it doesn't really cut it for Lemmy.

Would anyone be interested in using such app? I'll greatly appreciate feedback :)

43
 
 

I hope this is obvious, but I wanted to get it out there because of how important it is.

If your client allows user-entered Lemmy instances, ALWAYS verify that the instance is a valid Lemmy instance before sending credentials over. Otherwise, the user may have entered a url to an unknown server or site, and you will be sending their login credentials to a server that may be logging and storing the request or even intentionally trying to capture these credentials.

Instead, call getSite at the very least, or use a public list of verified servers before making the login request.

I would not be surprised if down the road malicious sites with similar domains to popular instances will be created to get login details of users who mis-typed their instance domain. It’s partially our responsibility to make sure our users are safe, so let’s keep this discussion going as we learn new ways to handle security concerns!

44
1
Regex for lemmy spoilers (programming.dev)
submitted 2 years ago* (last edited 2 years ago) by [email protected] to c/[email protected]
 
 

Through trial and errors, I've created regex for lemmy spoilers:

/:::\sspoiler\s+(?<title>.+)\n(?<body>[\s\S]+?)\n:::/g

link to regex101.com with explanation

45
 
 

I've read through the docs, but it doesn't tell me how to get a token. This should be obvious, I know... Sorry...

46
1
submitted 2 years ago* (last edited 2 years ago) by [email protected] to c/[email protected]
 
 

Does anyone know how to get the trending communities? Or do you have to calculate that yourself?

I've studied the API docs like my life depends on it but I can't find it anywhere.

47
 
 

I made a script based on plemmy and LemmyHttp API to be able to backup the list of registered communities and user profile (for now, that's just the biography). It output in human-readable format on console and have an option to output in a json file. The next step will be to provide also a script to restore such json backup to another lemmy instance or user.

I decided to do this small development following the sudden disappearance of vlemmy.net instance which resulted in the lost of all my subscribed communities.

48
1
submitted 2 years ago* (last edited 2 years ago) by [email protected] to c/[email protected]
 
 

Since the docs are horrible I think making a megathread here with Q&As and best practices for endpoints would be nice. Would've certainly helped me when I started out.

What do you guys think?

49
 
 

cross-posted from: https://lemm.ee/post/973445

Hello, do you know about a script or app or so that can backup data from a Lemmy instance as an end-user? At least the list of subscribed communities, settings, profile (bio) should be nice. I've been on VLemmy and lost one full evening trying to figure out what my subscription were (well not completely lost my time I also discovered new communities), but I want to avoid that in the future. If this doesn't exist yet I may develop it but I'm pretty sure I'm not alone and someone did it already...

50
 
 

Or is it documented? with mastodon, i set up clients to always load URLs in my app if they resembled masto-compatible URLS. I'm unsure how to go about this with lemmy. the lemmy-js-client "documentation" makes no mention of webfinger at all, though the lemmy repos have PRs fixing it.

view more: ‹ prev next ›