From 5eeec240691f95a306ce0ac2170508d18a6a73d2 Mon Sep 17 00:00:00 2001 From: Adam R Grey Date: Sat, 6 Jul 2024 16:00:18 -0400 Subject: [PATCH 1/7] slightly more generic Patch function for API untested. you know, since... offline ;) --- WebInterface/Views/Channels/Details.cshtml | 4 ++-- wwwroot/js/site.js | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/WebInterface/Views/Channels/Details.cshtml b/WebInterface/Views/Channels/Details.cshtml index ab338a8..e2e1054 100644 --- a/WebInterface/Views/Channels/Details.cshtml +++ b/WebInterface/Views/Channels/Details.cshtml @@ -23,7 +23,7 @@ Lewdness Filter Level - ⤵ inherited - @Enumerations.GetDescription(IfInheritedLewdnessFilterLevel) @foreach (Enumerations.LewdnessFilterLevel enumVal in Enum.GetValues(typeof(Enumerations.LewdnessFilterLevel))) @@ -53,7 +53,7 @@ Meanness Filter Level - ⤵ inherited - @Enumerations.GetDescription(IfInheritedMeannessFilterLevel) @foreach (Enumerations.MeannessFilterLevel enumVal in Enum.GetValues(typeof(Enumerations.MeannessFilterLevel))) diff --git a/wwwroot/js/site.js b/wwwroot/js/site.js index ec49115..8bc0b3a 100644 --- a/wwwroot/js/site.js +++ b/wwwroot/js/site.js @@ -7,7 +7,10 @@ function testfunct(caller){ console.log("[gibberish]"); console.log(caller); } -function patchModel(model) +//todo: figure out what the URL actually needs to be, rather than assuming you get a whole-ass server to yourself. +//you selfish fuck... What are you, fox? +//as it stands, you want something like /api/Channels/, trailing slash intentional +function patchModel(model, apiUrl) { //structure the model your (dang) self into a nice object console.log(model); @@ -16,15 +19,12 @@ function patchModel(model) var components = window.location.pathname.split('/'); if(components[2] !== "Details") { - console.log("wtf are you doing? " + components[2] + " is something other than Details") + console.log("wtf are you doing? " + components[2] + " is something other than Details"); + //add different endpoings here, if you like } var type=components[1]; var id=components[3]; - //todo: figure out what the URL actually needs to be, rather than assuming you get a whole-ass server to yourself. - //you selfish fuck. What are you, fox? - var apiUrl = "/api/Channels/" - console.log("dexter impression: I am now ready to post the following content:"); console.log(JSON.stringify(model)); fetch(apiUrl, { From 1d73fe0be805adb31750f363a2d2b1cb55f44516 Mon Sep 17 00:00:00 2001 From: Adam R Grey Date: Sun, 7 Jul 2024 13:08:41 -0400 Subject: [PATCH 2/7] they're accounts. Maybe I should rename it in the DB. --- WebInterface/Views/Channels/Details.cshtml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/WebInterface/Views/Channels/Details.cshtml b/WebInterface/Views/Channels/Details.cshtml index e2e1054..442089c 100644 --- a/WebInterface/Views/Channels/Details.cshtml +++ b/WebInterface/Views/Channels/Details.cshtml @@ -81,7 +81,7 @@ @(ThisChannel.SubChannels?.Count ?? 0) - Users + Accounts @(ThisChannel.Users?.Count ?? 0) @@ -109,5 +109,12 @@ console.log(channelNow); return channelNow; } + function getTree() { + var tree = @Html.Raw(ViewData["treeString"]); + console.log(tree); + return tree; + } + + $('#tree').bstreeview({ data: getTree() }); } \ No newline at end of file From 9648ea563be9424195dd9148d1a33cc6827cda1a Mon Sep 17 00:00:00 2001 From: Adam R Grey Date: Sun, 7 Jul 2024 14:22:10 -0400 Subject: [PATCH 3/7] compiles, needs db update --- Models/User.cs | 3 ++ WebInterface/Views/Users/Details.cshtml | 65 ++++++++++++++++++++----- wwwroot/js/site.js | 8 +-- 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/Models/User.cs b/Models/User.cs index 92437b4..f856fad 100644 --- a/Models/User.cs +++ b/Models/User.cs @@ -11,6 +11,9 @@ public class User public Guid Id { get; set; } public List Accounts { get; set; } + //if I ever get lots and lots of tags, or some automatic way to register a feature's arbitrary tags, then I can move this off. + public bool Tag_CanTwitchSummon { get; set; } + public string DisplayName { get diff --git a/WebInterface/Views/Users/Details.cshtml b/WebInterface/Views/Users/Details.cshtml index bbda543..8e0a786 100644 --- a/WebInterface/Views/Users/Details.cshtml +++ b/WebInterface/Views/Users/Details.cshtml @@ -1,21 +1,62 @@ @model User +@using System.Text @{ ViewData["Title"] = "User details"; } + + + + + + + + + + + + + + + +
Display Name@Model.DisplayName
Accounts +
+
Permission Tags +
+
-User @Model.DisplayName
-
-
+@section Scripts{ + + } - diff --git a/wwwroot/js/site.js b/wwwroot/js/site.js index 8bc0b3a..afe475b 100644 --- a/wwwroot/js/site.js +++ b/wwwroot/js/site.js @@ -2,10 +2,10 @@ // for details on configuring this project to bundle and minify static web assets. // Write your JavaScript code. - -function testfunct(caller){ - console.log("[gibberish]"); - console.log(caller); +function Account(displayName, accountId, protocol){ + this.displayName = displayName; + this.accountId = accountId; + this.protocol = protocol; } //todo: figure out what the URL actually needs to be, rather than assuming you get a whole-ass server to yourself. //you selfish fuck... What are you, fox? From e0c7bdb35f84387ce933e4452b8766ff72953548 Mon Sep 17 00:00:00 2001 From: Adam R Grey Date: Sun, 7 Jul 2024 15:27:48 -0400 Subject: [PATCH 4/7] user management UI --- Models/User.cs | 2 +- WebInterface/Controllers/UsersController.cs | 10 +++- WebInterface/Views/Users/Details.cshtml | 58 +++++++++++++++------ 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/Models/User.cs b/Models/User.cs index f856fad..bd0ed03 100644 --- a/Models/User.cs +++ b/Models/User.cs @@ -12,7 +12,7 @@ public class User public List Accounts { get; set; } //if I ever get lots and lots of tags, or some automatic way to register a feature's arbitrary tags, then I can move this off. - public bool Tag_CanTwitchSummon { get; set; } + //public bool Tag_CanTwitchSummon { get; set; } public string DisplayName { diff --git a/WebInterface/Controllers/UsersController.cs b/WebInterface/Controllers/UsersController.cs index 6847b78..ae37360 100644 --- a/WebInterface/Controllers/UsersController.cs +++ b/WebInterface/Controllers/UsersController.cs @@ -24,8 +24,16 @@ public class UsersController : Controller } public async Task Details(Guid id) { + var user = await _db.Users + .Include(u => u.Accounts) + .FirstAsync(u => u.Id == id); + var allTheChannels = await _db.Channels.ToListAsync(); + foreach(var acc in user.Accounts) + { + acc.SeenInChannel = allTheChannels.FirstOrDefault(c => c.Id == acc.SeenInChannel.Id); + } return _db.Users != null ? - View(await _db.Users.Include(u => u.Accounts).FirstAsync(u => u.Id == id)) : + View(user) : Problem("Entity set '_db.Users' is null."); } diff --git a/WebInterface/Views/Users/Details.cshtml b/WebInterface/Views/Users/Details.cshtml index 8e0a786..d127af4 100644 --- a/WebInterface/Views/Users/Details.cshtml +++ b/WebInterface/Views/Users/Details.cshtml @@ -1,4 +1,5 @@ @model User +@using Newtonsoft.Json @using System.Text @{ ViewData["Title"] = "User details"; @@ -6,39 +7,42 @@ - - + - -
Display Name@Model.DisplayName
Accounts
Permission Tags
- +placeholderlink @section Scripts{ } From 7c22ae1643fe90b08d58b9ac91da785eae8455fd Mon Sep 17 00:00:00 2001 From: Adam R Grey Date: Sat, 13 Jul 2024 17:56:19 -0400 Subject: [PATCH 5/7] found a magic number :(( --- ProtocolInterfaces/DiscordInterface/SlashCommandsHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProtocolInterfaces/DiscordInterface/SlashCommandsHelper.cs b/ProtocolInterfaces/DiscordInterface/SlashCommandsHelper.cs index 2f3ceda..95ad279 100644 --- a/ProtocolInterfaces/DiscordInterface/SlashCommandsHelper.cs +++ b/ProtocolInterfaces/DiscordInterface/SlashCommandsHelper.cs @@ -16,7 +16,7 @@ namespace vassago.DiscordInterface new CommandSetup(){ Id = "freedomunits", UpdatedAt = new DateTime(2023, 5, 21, 13, 3, 0), - guild = 825293851110801428, + guild = 825293851110801428, //TODO: demagic this magic number register = register_FreedomUnits } }; From 1b8a714a9620083e4b09d30bd7fa94a65c17a44b Mon Sep 17 00:00:00 2001 From: Adam R Grey Date: Sat, 13 Jul 2024 18:59:10 -0400 Subject: [PATCH 6/7] runs, performs features, doesn't crash --- Behavior/GeneralSnarkCloudNative.cs | 2 +- Behavior/GeneralSnarkMisspellDefinitely.cs | 2 +- Conversion/Converter.cs | 2 +- .../DiscordInterface/DiscordInterface.cs | 7 +++---- fail133653846161056785/error0.err | 15 +++++++++++++++ 5 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 fail133653846161056785/error0.err diff --git a/Behavior/GeneralSnarkCloudNative.cs b/Behavior/GeneralSnarkCloudNative.cs index 0eceb7b..90db765 100644 --- a/Behavior/GeneralSnarkCloudNative.cs +++ b/Behavior/GeneralSnarkCloudNative.cs @@ -22,7 +22,7 @@ public class GeneralSnarkCloudNative : Behavior if(Behaver.Instance.IsSelf(message.Author.Id)) return false; - if(message.Channel.EffectivePermissions.ReactionsPossible) + if(!message.Channel.EffectivePermissions.ReactionsPossible) return false; if((MeannessFilterLevel)message.Channel.EffectivePermissions.MeannessFilterLevel < MeannessFilterLevel.Medium) diff --git a/Behavior/GeneralSnarkMisspellDefinitely.cs b/Behavior/GeneralSnarkMisspellDefinitely.cs index 28425c2..0c32d6e 100644 --- a/Behavior/GeneralSnarkMisspellDefinitely.cs +++ b/Behavior/GeneralSnarkMisspellDefinitely.cs @@ -42,7 +42,7 @@ public class GeneralSnarkMisspellDefinitely : Behavior foreach(var k in snarkmap.Keys) { - if( Regex.IsMatch(message.Content, "\\b"+k+"\\b", RegexOptions.IgnoreCase)) + if( Regex.IsMatch(message.Content?.ToLower(), "\\b"+k+"\\b", RegexOptions.IgnoreCase)) return true; } return false; diff --git a/Conversion/Converter.cs b/Conversion/Converter.cs index b3b0ec3..e18d377 100644 --- a/Conversion/Converter.cs +++ b/Conversion/Converter.cs @@ -112,7 +112,7 @@ namespace vassago.Conversion accumulator = reverseConversion.Item4(accumulator); } } - if (normalizedDestUnit == currencyConf.Base || currencyConf.rates.Select(r => r.Key).Contains(normalizedDestUnit)) + if (currencyConf != null && (normalizedDestUnit == currencyConf.Base || currencyConf.rates.Select(r => r.Key).Contains(normalizedDestUnit))) { return $"{String.Format("approximately {0:0.00}", accumulator)} {normalizedDestUnit} as of {currencyConf.DateUpdated.ToLongDateString()}"; } diff --git a/ProtocolInterfaces/DiscordInterface/DiscordInterface.cs b/ProtocolInterfaces/DiscordInterface/DiscordInterface.cs index 38031ed..6234548 100644 --- a/ProtocolInterfaces/DiscordInterface/DiscordInterface.cs +++ b/ProtocolInterfaces/DiscordInterface/DiscordInterface.cs @@ -138,10 +138,9 @@ public class DiscordInterface var mentionOfMe = "<@" + client.CurrentUser.Id + ">"; m.MentionsMe = true; } - if (await Behaver.Instance.ActOn(m)) - { - m.ActedOn = true; - } + await Behaver.Instance.ActOn(m); + m.ActedOn = true; // for its own ruposess it might act on it later, but either way, fuck it, we checked. + _db.SaveChanges(); } diff --git a/fail133653846161056785/error0.err b/fail133653846161056785/error0.err new file mode 100644 index 0000000..6750c36 --- /dev/null +++ b/fail133653846161056785/error0.err @@ -0,0 +1,15 @@ +{ + "ClassName": "System.ComponentModel.Win32Exception", + "Message": "An error occurred trying to start process 'convert' with working directory '/home/adam/Desktop/vassago'. No such file or directory", + "Data": null, + "InnerException": null, + "HelpURL": null, + "StackTraceString": " at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)\n at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)\n at vassago.ExternalProcess.GoPlz(String commandPath, String commandArguments) in /home/adam/Desktop/vassago/externalProcess.cs:line 30", + "RemoteStackTraceString": null, + "RemoteStackIndex": 0, + "ExceptionMethod": null, + "HResult": -2147467259, + "Source": "System.Diagnostics.Process", + "WatsonBuckets": null, + "NativeErrorCode": 2 +} \ No newline at end of file From a7afcacee84c88298cd3d7c63f1bf34dd9828f54 Mon Sep 17 00:00:00 2001 From: adam Date: Thu, 26 Dec 2024 16:34:17 -0500 Subject: [PATCH 7/7] bitrot cleared, runs on dantalion --- devuitls.sh | 31 +++++++++++++++++++++++++++++++ vassago.csproj | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 devuitls.sh diff --git a/devuitls.sh b/devuitls.sh new file mode 100755 index 0000000..0445b36 --- /dev/null +++ b/devuitls.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +servicename="vassago" +pw_developmentdatabase="wnmhOttjA0wCiR9hVoG7jjrf90SxWvAV" +connnectionstr="Host=localhost;Database=${servicename}_dev;Username=${servicename};Password=${pw_developmentdatabase};IncludeErrorDetail=true;" + +case "$1" in + "initial") + sudo -u postgres psql -c "create database ${servicename}_dev;" + sudo -u postgres psql -c "create user $servicename with encrypted password '$pw_developmentdatabase';" + sudo -u postgres psql -c "grant all privileges on database ${servicename}_dev to $servicename;" + sudo -u postgres psql -d "${servicename}_dev" -c "GRANT ALL ON SCHEMA public TO $servicename" + + cp appsettings.sample.json appsettings.json + dotnet ef database update --connection "$connnectionstr" + ;; + + "add-migration") + dotnet ef migrations add "$2" + dotnet ef database update --connection "$connnectionstr" + ;; + + "dbupdate") + dotnet ef database update --connection "$connnectionstr" + ;; + + *) + echo "Unknown command '$1', try 'initial'" + ;; +esac + diff --git a/vassago.csproj b/vassago.csproj index f9392a8..dae7d44 100644 --- a/vassago.csproj +++ b/vassago.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 enable $(NoWarn);CA2254