< img src="https://images.idgesg.net/images/article/2018/07/light_string_in_a_jar_at_sunset_lightbulbs_ideas_innovation_brainstorming_by_yeshi_kangrang_cc0_via_unsplash_1200x800-100765077-large.jpg?auto=webp&quality=85,70"alt=""> In Lists and people on Mastodon I showed how I included a list column to the following tab of the Mastodon browser I’m constructing. That was a step in the direction of easier and more powerful list management. It enables me to see whether the people I follow are designated to lists, and to consider who must be on a list(or perhaps on a different list ). Today, as I began to utilize that brand-new affordance in earnest, I found a brand-new challenge. In order to appoint somebody to a list, or alter a list assignment, I clicked the link in the account_url column to open that person ‘s profile in the Mastodon web app. That was fine for accounts on my home server, mastodon.social. An account URL like Shelley Powers’https://mastodon.social/@burningbird!.?.! brings meto Shelley’s profile on my house server where the list manager is available.But if I’m following someone somewhere else, like Ward Cunningham at https://mastodon.radio/@k9ox!.?.!, the account URL brings me to Ward’s profile on that server where the list supervisor isn’t readily available. In order to appoint Ward to a list I needed to record his account URL, paste it into the search box in my home server’s web app, and then click the resulting link: https://mastodon.social/@[email protected]!.?.!.That got old genuine fast, so I adjusted the following tab to display the latter flavor of URL which I’ll call an instance-qualified URL.Steampipe offers a couple of ways to make that adjustment. As a user of the dashboard, you can use Postgres’regular expression operates to do the change in the SQL inquiry that drives the view. However you ‘d rather not need to. It’s much better if the plugin does that for you, so the SQL can simply refer to a column called instance_qualified_url. I picked the latter approach. As the author of a Steampipe plugin you wish to make life as easy as possible for users of the plugin. When you’re the author of both the plugin and the dashboard, as I remain in this case, you can take pleasure in a good virtuous cycle. As the control panel progresses you discover methods to improve the plugin, which causes more use of the dashboard, which recommends more chances to improve the plugin. I have been considerably taking pleasure in the coevolution of these 2 parts! Including a brand-new column to a Steampipe table To make the modification, I extended the structure that defines the columns of the tables mapped from Mastodon’s Account API. A Steampipe plugin defines columns utilizing a list of structs like this …, p>
URL for the account.”,, …, That
struct says: “When the name of a high-level field in the API action is URL, tell Steampipe to make a database column with that name and with the Postgres type text.” You can also change worths in API responses to manufacture brand-new columns that don’t appear in API actions. Here’s the struct I added for this case …, Name:”instance_qualified_account_url “, Type: proto.ColumnType _ STRING, Description:”Account URL<, ... That a person states:" Send the API response to the change function instanceQualifiedAccountUrl, and utilize its outcome as the worth of the column.Here's the function.func instanceQualifiedAccountUrl(ctx context.Context, input * transform.TransformData )(interface , error )url:=input.Value.(* mastodon.Status). Account.URL qualifiedUrl:=qualifiedUrl(ctx, url)return qualifiedUrl, nil It delegates the genuine work to another function. func qualifiedUrl(ctx context.Context, url string)string @%s@%s", homeServer, server, individual)plugin.Logger(ctx). Debug ("instanceQualifiedUrl","qualifiedUrl ", qualifiedUrl)schemelessHomeServer: =strings.ReplaceAll (homeServer,"https: Why? 2 various sets of column meanings need the same transformation. instanceQualifiedAccountUrl deals with actions from the Account API. However account URLs likewise appear in the Status API that drives timeline views. Those use a different change function, instanceQualifiedStatusUrl, to do the same transformation for a different API response.From account URLs to status URLs The instanceQualifiedAccountUrl column solved the initial issue. I had the ability to eliminate my plugin-author hat, put on my dashboard-author hat, and refer to account URLs as instance-qualified URLs in all the tabs that show them. Any such link now results in a profile that I view through the lens of mastodon.social which allows me to utilize the web app's list supervisor straight, without the troublesome copy/paste/search procedure.My happy dance
didn’t last long, though. Newly sensitized to that copy/paste/search friction, I recognized it was still occurring when I attempt to reply to products that appear in a timeline view. Here is a recent example: https://techpolicy.social/@mnot/109610641523489182!.?.!.That’s the URL showed in the dashboard. When I click it I arrive at Mark’s server and can see the item, however if I attempt to reply I’m confronted with the dreaded copy/paste/search operation. No issue! I’ll use a comparable transform! Not so quickly. I can form an URL like https://mastodon.social/@[email protected]/109610641523489182!.?.! however it doesn’t go anywhere.If I do the copy/paste/search operation, I arrive on a similar-but-different URL: https://mastodon.social/@[email protected]/109610641692667630!.?.!. It has the very same structure however a different toot ID. This URL is also the one that appears in the web app’s house timeline, which is why I can reply directly from that view.I run out my depth here so I’ll just end with an appeal for help. It makes sense that a home server will appoint its own
ID to a product brought from a foreign server, and that the web app will utilize that ID. However I’m not seeing a way to aquire that id straight from the API. I think it’s possible to acquire it by method of search, but doing that
for every product in a timeline will quickly exhaust the tight spending plan for API requests (just 300 every five minutes). So, Lazy Mastodon, am I simply stuck here or is there a method to transform foreign status URLs into instance-relative status URLs?Update: Solved!After chatting with Jari Pennanen I reconsidered and understood the required ID was offered in the API response after all, I just wasn’t utilizing it(facepalm). And in truth there are 2 tastes of the ID– one for originaltoots, another for boosts. Columns for both cases are included here and the tweak to make the control panel use them here. Here is the result. IDG Thanks for being my rubber duck, Jari! The instance-qualified toot and reblog URLs make this dashboard enormously more useful.See also: Wish for the fediverse Construct a Mastodon control panel with Steampipe Browsing the fediverse A Bloomberg terminal for Mastodon Produce your own Mastodon UX Lists and people on Mastodon tooters likewise tweet Instance-qualified Mastodon URLs Copyright © 2023 IDG Communications, Inc. Source