NEETzsche,
@NEETzsche@iddqd.social avatar

So, I wrote the first thing for Balormo's backend tonight. I wanted to do dice rolls, or really RNG (random number generation) broadly, and in this case I wrote the simplest form of it in the TTRPG space: rolling XdY, take the sum.

I did not write an FE for this yet. That's because I want to discuss the way I designed it. Now would be the time to refactor things or change around how it's structured. This is backend proof of concept phase.

For the time being, you can use curl to try it out once you have an account on dev.iddqd.social:

curl -X POST "https://dev.iddqd.social/api/v1/statuses" 
    -H "Authorization: Bearer REDACTED" 
    -H "Content-Type: multipart/form-data" 
    -F "status=Rolling CON for AD&D 2e style" 
    -F "source=Pleroma FE" 
    -F "visibility=public" 
    -F "content_type=text/plain" 
    -F "balormo[rng][system]=dice_sum" 
    -F "balormo[rng][denomination]=6" 
    -F "balormo[rng][quantity]=3"

You can find my commit for it here: https://gitgud.io/thestranjer/balormo/-/commit/483800ea9c2e5f913ecc5f1523625c9ad535917d

Unfortunately, Soapbox and Pleroma seem to drop the balormo object in federation. However, quite fortunately, it delivers the Object URL, which does retain that information:

{
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    "https://dev.iddqd.social/schemas/litepub-0.1.jsonld",
    {"@language": "und"}
  ],
  "actor": "https://dev.iddqd.social/users/NEETzsche",
  "attachment": [],
  "attributedTo": "https://dev.iddqd.social/users/NEETzsche",
  "balormo": {
    "rng": {
      "denomination": 6,
      "quantity": 3,
      "results": [1,1,6],
      "sum": 8,
      "system": "dice_sum"
    }
  },
  "cc": ["https://dev.iddqd.social/users/NEETzsche/followers"],
  "content": "Rolling CON for AD&amp;D 2e style<br/><i>Rolling 3d6, taking the sum.</i><br/><b>Results:</b> 1, 1, 6<br/><b>Sum:</b> 8",
  "context": "https://dev.iddqd.social/contexts/c2ceeca0-5369-41b9-8be7-2d0a647a7907",
  "conversation": "https://dev.iddqd.social/contexts/c2ceeca0-5369-41b9-8be7-2d0a647a7907",
  "id": "https://dev.iddqd.social/objects/48f97fc0-5a63-406f-8822-3ea4493713d9",
  "published": "2024-05-10T09:13:21.883623Z",
  "sensitive": null,
  "source": {
    "content": "Rolling CON for AD&D 2e style",
    "mediaType": "text/plain"
  },
  "summary": "",
  "tag": [],"to": ["https://www.w3.org/ns/activitystreams#Public"],
  "type": "Note"
}

The way I wrote this is you just add more fields to the /api/v1/statuses endpoint and give it extra fields. In this case, the system field can be changed and the pattern matching will pick up on the right one and then generate dice rolls etc in the right fashion. For example, I might write a Shadowrun dice roller that rolls d6s given only a pool value and re-rolls 6s until you don't get anymore.

The reason to bake this into the protocol is so that you can manage the data better and change the way it's displayed in the future. The appended roll text to the status will be put in a <div> with a class on it that's invisible for the FE.

Thoughts on how to improve this before I move on to the FE?

@sun @p @jeffcliff @rees @crunklord420 @caekislove @mint @LukeAlmighty @lain

lain,
@lain@lain.com avatar

@NEETzsche @rees @crunklord420 @NEETzsche @p @LukeAlmighty @caekislove @mint @jeffcliff @sun i'm out of te loop on this one, what's this supposed to be for? where does the name come from?

mint,
@mint@ryona.agency avatar

@NEETzsche @rees @crunklord420 @NEETzsche @p @LukeAlmighty @caekislove @lain @jeffcliff @sun >Unfortunately, Soapbox and Pleroma seem to drop the balormo object in federation
Yeah, Pleroma strips all unknown fields from received objects. Having a separate field for arbitrary data that could be extended with anything to frontend's discretion sounds like a good idea to me, though I'd question local experts ( @feld, @i) about possible security implications.

munir,
@munir@fedi.munir.tokyo avatar

@mint @feld @rees @crunklord420 @i @NEETzsche @p @LukeAlmighty @caekislove @NEETzsche @lain @jeffcliff @sun > Having a separate field for arbitrary data that could be extended with anything to frontend's discretion sounds like a good idea to me

its not mint, its a good security hole :02_learn:

mint,
@mint@ryona.agency avatar

@munir @feld @rees @crunklord420 @i @NEETzsche @p @LukeAlmighty @caekislove @NEETzsche @lain @jeffcliff @sun It doesn't touch any other fields, so as long as it has a limit for amount and size of its own fields, I think it should be fine.

munir,
@munir@fedi.munir.tokyo avatar

@mint @feld @rees @crunklord420 @i @NEETzsche @p @LukeAlmighty @caekislove @NEETzsche @lain @jeffcliff @sun yeah but what if a frontend tries to evaluate it the wrong way? im no cybersec god but it sounds like a gateway for an exploit, almost like eval() in python iykwim

i,
@i@declin.eu avatar

@munir @feld @rees @crunklord420 @NEETzsche @p @LukeAlmighty @caekislove @NEETzsche @lain @mint @jeffcliff @sun we've already had XSS multiple times in pleroma-fe from fields being scrubbed in some versions and not in others, making people ship their own sanitizers

mint,
@mint@ryona.agency avatar
p,
@p@fsebugoutzone.org avatar

@munir @mint @LukeAlmighty @NEETzsche @caekislove @crunklord420 @feld @i @jeffcliff @lain @rees @sun Well, it's not that, but if it were to eventually start to mean something somewhere, that would matter. It's not likely that anything starts trying to pay attention to "balormo", same reason you don't expect Mastodon to start bothering with the "pleroma" field: if it stops being just Pleroma, then you move it out of the "pleroma" field.

sun,
@sun@shitposter.world avatar

@p @feld @rees @crunklord420 @i @munir @LukeAlmighty @caekislove @NEETzsche @lain @mint @jeffcliff what if gargron just started using that field in mastodon for something else like he did with the subject field

feld,
@feld@bikeshed.party avatar
eris,
@eris@layer02.net avatar
feld,
@feld@bikeshed.party avatar
  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • ngwrru68w68
  • DreamBathrooms
  • modclub
  • GTA5RPClips
  • InstantRegret
  • magazineikmin
  • Youngstown
  • thenastyranch
  • rosin
  • slotface
  • mdbf
  • khanakhh
  • kavyap
  • anitta
  • tester
  • normalnudes
  • Leos
  • cisconetworking
  • osvaldo12
  • everett
  • Durango
  • tacticalgear
  • provamag3
  • megavids
  • ethstaker
  • cubers
  • JUstTest
  • lostlight
  • All magazines