Call initSDK outside of the post function

Created on 11 August 2025, 6 days ago

Problem/Motivation

Currently the post function calls initSdk, which is not very efficient, since technically you should be able to call initSdk and then call post as many times as you want. This was done this way initially because it seemed like ECA action plugins do not support dependency injection, but it may be possible to do this without dependency injection even though it feels bad. Anyway, it would be nice if initSDK was not called directly in the doPost method, as a start.

πŸ“Œ Task
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States MegaKeegMan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @MegaKeegMan
  • πŸ‡ΊπŸ‡ΈUnited States MegaKeegMan

    I started an issue fork, starting by attempting a refactor of the ECA plugin into multiple with different concerns. The idea was that there could be an action that prepares the mastodon post manager for posting, and then a separate one that was actually responsible for posting. Unfortunately, I have not yet been able to find a way to make the same instance of a service available across plugins in the same model. I wanted to do this so that someone could prepare the post manager once, and then post as many times as they wanted.

    I don't necessarily want to continue on this at the moment, and may just continue separating out the functionality from doPost, and putting too much into the execute of the Toot action class. If ever we want ECA to be able to post multiple posts, then we should probably instead focus on queuing up posts and then having a single action that processes the queue and can post several posts at a time, or something along those lines, especially if I get confirmation that preparing a service in one plugin instance, there is no way to keep it available for another plugin instance.

  • πŸ‡ΊπŸ‡ΈUnited States MegaKeegMan

    Such a queuing functionality should probably be a separate feature request. Also noteworthy that https://www.drupal.org/project/social_post_controller β†’ does actually manage such a queue for posting to social media, but does so via code, and not with any integration with ECA. I think it does make sense to have queuing here, but it should probably be noted that Social Post Controller should probably not be used on a site that is managing queues via an ECA, assuming that such plugins are created.

  • πŸ‡ΊπŸ‡ΈUnited States MegaKeegMan

    Upon learning that I should not need to store the service instance in order to keep it available, I made one more attempt at that pattern. Unfortunately it did not work. My previous comment is probably the path forward here.

Production build 0.71.5 2024