Ricerca dei profili con suggerimenti e foto (#37)
«Aggiungi account» ha una sola casella: mentre Alberto scrive compaiono subito i suggerimenti locali, poi i profili di Instagram con la foto, come chiesto in #37. Il browser di Febe scrive nella casella «Cerca» di Instagram con tasti veri da una mappa chiusa (mai Invio, Tab o Esc), controlla prima il fuoco, legge la risposta della pagina e non clicca mai un risultato. La ricerca ha una categoria propria nel Governatore, con tetti larghi che non consumano quelli della raccolta, e si dà il turno con il motore sull'unica pagina; a fine sessione la pagina torna comunque al riposo. Le foto passano dal CDN con un permesso ciascuna e restano solo in memoria. Le risposte di Alberto del 15 novembre (controllo del fuoco, turni, evento requestWillBeSent, niente foto dei seguiti per ora) sono in §6.1 e in docs/decisioni.md. Su Instagram vero la ricerca parte quando i bersagli search-open e search-box saranno raccolti dal vivo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5e417c666d
commit
9941a2fa1f
98 files changed
+8021
-229
No files matched your search
@@ -251,6 +251,11 @@ public sealed class TestSite : IAsyncDisposable
|
||||
}
|
||||
}
|
||||
|
||||
if (Control.SearchMemory)
|
||||
{
|
||||
html = html.Replace("<body ", "<body data-memoria-ricerca=\"si\" ", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
await HtmlAsync(context, status, html).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -279,6 +284,32 @@ public sealed class TestSite : IAsyncDisposable
|
||||
}
|
||||
|
||||
var segments = path.Split('/', StringSplitOptions.RemoveEmptyEntries).Select(Uri.UnescapeDataString).ToArray();
|
||||
if (segments is ["dati", "cerca"])
|
||||
{
|
||||
await SearchAsync(context, query["testo"].ToString()).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (segments is ["dati", "ricerche-recenti"])
|
||||
{
|
||||
if (HttpMethods.IsPost(context.Request.Method))
|
||||
{
|
||||
// The analogue of Instagram registering a search in the recent ones: a write Febe must never cause.
|
||||
Control.OnRecentSearchWritten();
|
||||
await JsonAsync(context, 200, new JsonObject { ["ok"] = true }).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
JsonObject recent;
|
||||
lock (World.Gate)
|
||||
{
|
||||
recent = Api.RecentSearches([.. World.Following.Take(3).Select(a => a.Username)]);
|
||||
}
|
||||
|
||||
await JsonAsync(context, 200, recent).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var tab = query["scheda"].ToString() switch { "reel" => ProfileTab.Reels, "taggati" => ProfileTab.Tagged, _ => ProfileTab.Posts };
|
||||
var after = query["dopo"].ToString();
|
||||
JsonObject? result;
|
||||
@@ -308,6 +339,29 @@ public sealed class TestSite : IAsyncDisposable
|
||||
await JsonAsync(context, 200, result).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>The answer of the search box, after the waits the control asks for (slow, out of order).</summary>
|
||||
private async Task SearchAsync(HttpContext context, string text)
|
||||
{
|
||||
var delay = Control.SearchDelay;
|
||||
if (Control.SearchDisorder)
|
||||
{
|
||||
delay += TimeSpan.FromMilliseconds(Math.Max(0, 8 - text.Trim().Length) * 250);
|
||||
}
|
||||
|
||||
if (delay > TimeSpan.Zero)
|
||||
{
|
||||
await Task.Delay(delay, context.RequestAborted).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
JsonObject answer;
|
||||
lock (World.Gate)
|
||||
{
|
||||
answer = Api.Search(text);
|
||||
}
|
||||
|
||||
await JsonAsync(context, 200, answer).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task ServeCdnAsync(HttpContext context)
|
||||
{
|
||||
var path = context.Request.Path.Value ?? string.Empty;
|
||||
@@ -381,6 +435,18 @@ public sealed class TestSite : IAsyncDisposable
|
||||
case "durata-storie":
|
||||
Control.StoryDuration = TimeSpan.FromMilliseconds(int.Parse(q["ms"].ToString(), CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case "ricerca/ritardo":
|
||||
Control.SearchDelay = TimeSpan.FromMilliseconds(int.Parse(q["ms"].ToString(), CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case "ricerca/disordine":
|
||||
Control.SearchDisorder = q["valore"].ToString() is not ("no" or "false");
|
||||
break;
|
||||
case "ricerca/memoria":
|
||||
Control.SearchMemory = q["valore"].ToString() is not ("no" or "false");
|
||||
break;
|
||||
case "ricerca/recenti":
|
||||
answer["scritte"] = Control.RecentSearchWrites;
|
||||
break;
|
||||
case "cdn-troppe-richieste":
|
||||
Control.CdnTooManyRequests = q["valore"].ToString() is "si" or "sì" or "true";
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user