inculi / Sue

A bot for iMessage (sue@robertism.com), Telegram (@ImSueBot), and Discord. Now in Elixir!
MIT License
28 stars 9 forks source link

Overhaul platform_id usage and Subaru.traverse() #45

Closed Manwholikespie closed 1 year ago

Manwholikespie commented 1 year ago

We previously were saving Accounts with metadata such as %Account{platform_id: {:discord, "discordid123"}} so that we could quickly resolve the sender of each message to their account. The problem with this, is that I intended to eventually allow people to share a Sue account across each of their platforms (imessage, telegram, discord, etc.) and have all their definitions and preferences sync. (This is also important for desu profiles)

I have made changes such that we instead use PlatformAccounts (with the same {:discord, "discordid123"} metadata being logged for resolution, yet we then do a traversal to the actual Sue Account edge.

I then noticed one of the tests was failing, where we allow a user to call upon their friends definitions that weren't made in that Chat. Doing this requires a traversal of:

  1. Find my chats.
  2. Find the users in these chats with me.
  3. Find the definitions made by these users.
  4. Filter these definitions to ones with a varname == what I'm searching for (ex: !megumin)

yet having this traverse be abstract enough such that I can use it for other things (like finding the Sue Account tied to a PlatformAccount). So now we have Subaru.traverse_v()

Current status: adding migrations so that y'all don't have to manually fix DB breakages when I update things