• mercano@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    An NNTP binding would be a bit more directly mappable, as Lemmy’s more analogous to Usenet than email. Each community would be a newsgroup. Still, NNTP and SMTP are pretty closely related, to the point that Outlook Express supported both email and Usenet. Subscribing, reading, posting, and commenting are pretty easy concepts to map, only up and downvoting are unsupported.

    • Skull giver@popplesburger.hilciferous.nl
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 year ago

      This is the result of a weekend teaching myself Go, using go-imap:

      I can actually receive DMs in Outlook Express now! That and listing posts in a community sorted by date are about all it does, but it works!

      I went with IMAP because IMAP has more open source server code. It doesn’t matter much, modern IMAP actually has native threading support for example. I’ve modeled Lemmy as every community being a mailbox under INBOX (with INBOX being reserved for DMs). My idea was to use the flags for upvoting/downvoting (you can add arbitrary flags to IMAP, although I seem to be the only person using them). Favorites are easy (just use the marking/star/flag/whatever feature).

      Subscriptions are already part of IMAP. I implemented them but I disabled them when Outlook Express tried to “reset to defaults” and almost unsubbed me from every community.

      Admin stuff is also possible, technically! Removing folders would be the same as purging them (rather than unsubbing), deleting emails would be like deleting posts. Add a CardDAV server and you may even do user management!

      I even came up with a scheme to do sorting (INBOX/topday/community@server.example). This is a horrible hack, but Gmail does something similar, duplicating messages across labels.

      The experience taught me a lot about IMAP and I hate the protocol now. What the hell is up with message IDs changing every time the client contacts the server?

      The problem with either protocol is that server-side sorting is barely implemented. Messages are cached by the client so things like scoring are impossible to implement right. Another issue is the lack of pagination, but I guess that can be solved by an arbitrary cut-off date or a limited amount of posts.

      I’d also need to think of a way to fetch all replies to make the email threads work. Right now it only lists posts, it doesn’t fetch comments yet.

      SMTP as an input mechanism shouldn’t even be that bad (as long as you make sure the reply button replies to a unique “email address” like post12345@server.example). My plan was to parse everything as Markdown (after extracting the text from HTML emails). Image attachments would be a bit harder, but I think they could work.

      I think I should re-do the entire thing using direct database access rather than using the Lemmy API, because right now refreshing all folders downloads all messages on the server which quickly kills the server/hits the request limit. Maybe I’ll eventually come back to this, but developing and debugging this is rather slow and painful.