![lemmydev](https://lemm.ee/pictrs/image/ad382851-629e-45d2-9ba9-b5b4cf317fa5.jpeg?format=webp&thumbnail=48)
Lemmy App Development
- What's your approach on rendering nested comments?
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?
- Understanding an error message
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?
- The Mistral AI bot here on Lemmy now remembers context
I’ve updated @Mistral@lemmings.world 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.
- Lemmy API Swagger documentation
There's now a swagger documentation for the Lemmy API.
See also https://mv-gh.github.io/lemmy_openapi_spec/
- how do you construct a user overview while respecting sort?
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
- How do you get the url or id of the same post on a different instance?
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?
- How do you guys deal with notifications
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:
- Bring back websockets only for notifications by directly changing lemmy server side code.
- Find where the email notification code is at, and simply implement expo notifications there.
Whaddya think?
- ensure child comments are displayed in post view?
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?
- Instance Assistant v1.2.6 is out - Redirect user profile pagesgithub.com Release Instance Assistant v1.2.6 · cynber/lemmy-instance-assistant
added ability to redirect user profile pages
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: > - Firefox Add-on > - Chrome Extension > - Edge Add-on (waiting as of 2023-10-09) > - GitHub > > --- > > ::: spoiler ❓ 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 :)
- Lemmy Schedule - app for scheduling posts and getting notified of new posts
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 !schedule@lemmings.world community.
P.S. It's open source and can be self-hosted using docker!
- schedule a post and post it to multiple communities
- Is there a guide to hosting on a raspberry pi yet?
I’d love to host my own Lemmy server but I’m just a script kiddie
- Release notes for lemmy-js-client?
Where are you all finding details on what features are included in each version of lemmy-js-client?
- Some stats of my AutoTLDR bot
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.
- Trying to understand /comment/list
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 byNew
, I receive only 10 comments, if I try to specifypage
, orlimit
, I get an error{"error":"couldnt_get_comments"}
.If I don't specify
page
orlimit
, and set an arbitrary number formax_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&page=1&sort=New
- Understanding the semantics of child_count in the comments API
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&max_depth=999&limit=999' | jq '.comments[] | { path: .comment.path, id: .comment.id, content: .comment.content, child_count: .counts.child_count }'
json { "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? - Do you guys really pay 100$/y to build Apps for IOS?
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"?
- Where can I get the amount of direct descendants of a comment?
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.
- AppStore Review Guidelines for NSFW content
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.
- I created an AutoTLDR botgithub.com GitHub - RikudouSage/LemmyAutoTldrBot
Contribute to RikudouSage/LemmyAutoTldrBot development by creating an account on GitHub.
You can find it here. Source code in the link.
- Community Link Fixer updated
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.
- I updated the PHP api client to work with 0.18.3github.com GitHub - RikudouSage/LemmyApi
Contribute to RikudouSage/LemmyApi development by creating an account on GitHub.
It now supports 0.18.3 and contrary to previous releases it supports unauthenticated requests where it makes sense.
https://github.com/RikudouSage/LemmyApi/
- JavaScript API client, HideCommunity - disabled?
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
- Lemmy API testing code to exercise every feature/call
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.
- FYI for Rust Developers, lemmy_api_common is no longer published to crates.io (0.18.3 and above)github.com Dont publish releases to crates.io (fixes #3272) (#3664) · LemmyNet/lemmy@5cd4c6c
This is not needed anymore as from scratch installation now uses `git clone` instead of `cargo install`. https://github.com/LemmyNet/lemmy-docs/pull/241/files
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
- [SOLVED] Error "user_already_exists" from saveUserSettings
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.
- I"m confused where I can get list of moderators for a Community - CommunityModeratorView
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
- Alternative to mega-threads
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.
- documentation for lemmy link types?
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/community@otherinstance.net. i have also seen links that just have "/c/community@otherinstance.net"... at the moment i'm only developing rendering code for them as i happen upon them, which is ad-hoc
- Introducing Avelon for Lemmy - Join the open beta!
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!
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
- Posts and feeds
- Lemmy RSS reader - would anyone be interested?
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 :)
- Lemmy API Security Tip: Verify that the instance is a valid Lemmy instance first before sending your user’s login details
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!
- Regex for lemmy spoilers
Through trial and errors, I've created regex for lemmy spoilers:
/:::\sspoiler\s+(?<title>.+)\n(?<body>[\s\S]+?)\n:::/g
- How to I get an API token for lemmy.world?
I've read through the docs, but it doesn't tell me how to get a token. This should be obvious, I know... Sorry...
- How to get trending Communities
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.
- GitHub - fievel/lemmy_backup: A script to backup/restore from one lemmy instancegithub.com GitHub - fievel/lemmy_backup: A script to backup/restore from one lemmy instance
A script to backup/restore from one lemmy instance - GitHub - fievel/lemmy_backup: A script to backup/restore from one lemmy instance
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.
- [META] Megathread for API questions?
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?