4.5.1 Setting-up POSSE to Mastodon

This subsection will describe the process of adding POSSE to an Org Export-generated site, using indie-org.sh as an example. It will focus on Mastodon.

The first step is to sign-up at brid.gy. There are extensive docs at https://brid.gy/about. When you land on the home page, you’ll be asked to click on a tile representing the account to which you want to enable POSSE. On clicking “Mastodon”, you’ll be asked whether you want to post to a Mastodon account or connect to the fediverse. Select the former. You’ll next be asked for the address of your Mastodon instance, where you’ll have to sign-in. Once you’ve authenticated there, you’ll be asked for the address of your site– that’s it.

As an aside, brid.gy works via See Webmentions, both for accepting POSSE requests and for backfeeding responses to your POSSE’d content, so you’ll need Webmention support, first.

indie-org integrates POSSE support into Org Mode, first by defining a new keyword, #+POSSE. When authoring one’s document, one expresses a desire for POSSE by setting it like so:

#+TITLE: My Post
#+AUTHOR: me
#+POSSE: mastodon flickr
...

During the See Publication Process, indie-org will note the POSSE requests & record them in the publication state for future reference (Cf. indie-org-posse-requests).

indie-org also handles sending the requests and recording the responses in indie-org-send-posse-request. The response can be recorded with the publication state in indie-org-record-sent-posse. Given an indie-org-posse-requests instance and and instance of indie-org-posse-responses, the outstanding requests (i.e. the POSSE requests that still need to be sent) may be found with indie-org-posse-required.

So equipped, we can give ourselves another function:

(defun iosh/send-posse-requests (prod)
  "Send POSSE requests post-publication.
PROD shall be t to select production & nil to select staging."
  (message "Sending POSSE requests (if any)...")
  (indie-org-enable)
  (let* ((env (if prod :prod :local))
         (all-pub-states
          (if (file-exists-p publication-state-file)
              (indie-org-state-read publication-state-file)))
         (publication-state
          (or (plist-get all-pub-states env)
              (indie-org-state-v2-make-publication-state)))
         (requests
          (or (indie-org-state-v2-posse-requests publication-state)
              (indie-org-posse-make-requests)))
         (responses
          (or (indie-org-state-v2-posse-responses publication-state)
              (indie-org-posse-make-responses)))
         (to-send
          (indie-org-posse-required requests responses)))
    ;; `to-send' will be a list of cons cells, each of whose car is a
    ;; page key & whose cdr is a list of POSSE symbols.
    (while to-send
      (let* ((page-key (caar to-send))
             (source
              (concat
               "https://indie-org.sh/"
               page-key))
             (symbols (cdar to-send)))
        (while symbols
          (if prod
              (let ((rsp (indie-org-send-posse-request source (car symbols))))
                (indie-org-record-sent-posse page-key rsp responses))
            (message "Will send POSSE request: %s :=> %s" source (car symbols)))
          (setq symbols (cdr symbols))))
      (setq to-send (cdr to-send)))
    (setf (indie-org-state-v2-posse-responses publication-state) responses)
    (plist-put all-pub-states env publication-state)
    (indie-org-state-write all-pub-states publication-state-file))
    (message "Sending POSSE requests (if any)...done."))