* feat(feed): add followed-resident activity timeline and viewer reaction state * feat(feed): authenticated avatar identity, following timeline and reaction metadata * feat(feed): interactive same-origin OAuth PKCE web profile composer and timeline UI * feat(feed): upgrade Firestorm web profile to interactive same-origin PKCE UI * config(feed): inject registered public OAuth client and exact /feed callback * config(feed): expose optional public OAuth client ID for direct viewer posting * config(feed): expose optional public OAuth client ID for direct viewer posting * config(feed): expose optional public OAuth client ID for direct viewer posting * feat(feed): preserve own like state in following timeline * feat(feed): return scoped reaction state in personalized timeline * docs(api): document OAuth avatar identity and followed feed timeline endpoints * docs(feed): production-oriented public OAuth registration and interactive viewer rollout * ci(feed): verify OAuth PKCE, private profiles, timeline and real browser JS syntax * test(feed): exercise real MariaDB followed timeline and viewer reaction state * test(feed): import LINQ for followed timeline integration checks * ci(feed): gate interactive OAuth feed on privacy contracts and browser syntax * docs(feed): distinguish legacy read-only v1 from opt-in interactive webprofile v2 * feat(feed): idempotent first-party OAuth client bootstrap respecting admin disable * feat(feed): enable by default and bootstrap OAuth public client on ROBUST startup * config(feed): default enable web feed and automatic public OAuth provisioning * config(feed): default enable web feed and automatic public OAuth provisioning * config(feed): default enable web feed and automatic public OAuth provisioning * style(feed): redesign responsive Stadt NexVerse feed, composer, profile and stream cards * style(feed): Stadt NexVerse branded profile hero and cards, powered by OpenGenesisLINK footer * style(feed): modern interactive avatar cards, action buttons, responsive timelines * test(feed): align release contracts with safe auto-enabled feed default * test(feed): align release contracts with safe auto-enabled feed default * test(feed): align release contracts with safe auto-enabled feed default * test(feed): verify Stadt NexVerse branding, mobile fallback and CSP * ci(feed): gate modern NexVerse brand design and browser security * test(feed): check stream title in client layout rather than static server HTML * docs(feed): document default-enabled first-party web profile and safety gates * docs(feed): document default-enabled first-party web profile and safety gates * docs(feed): use automatic persistent OAuth client by default, manual override optional * test(feed): cover built-in OAuth public client bootstrap and safe operator opt-out * feat(feed): opt-in automatic event/classified activity settings and idempotent SQL receipts * fix(feed): purge activity consent and dedup records in atomic self/admin account deletion * feat(feed): validated and consent-gated auto posts for approved events/classifieds * feat(feed): publish verified discovery approval events for consent-gated auto posts * feat(feed): bind vetted discovery events to opt-in activity publisher * feat(feed): authenticated per-avatar opt-in controls for automatic activities * feat(feed): modern per-avatar opt-in switches for event and classified auto posts * db(feed): migration for opt-in auto-post consent and dedup receipts * test(feed): live MariaDB auto activity consent/dedup and account deletion * docs(api): add authenticated personal auto-activity preference endpoints * ci(feed): contract gate for consented auto posts and durable cleanup * test(feed): match default-on feed config and atomic activity-consent deletion * ci(feed): include privacy-gated automatic event and classified publication checks * docs(feed): opt-in auto event/classified posts, NexVerse branding and safe activation * fix(feed): accept MySQL TINYINT(1) boolean mapping in auto activity consent * docs(release): reflect default-on interactive NexVerse feed and opt-in auto activity schema * fix(feed): import OpenSim.Framework for avatar profile properties * fix(feed): avoid C# out-variable scope collisions in activity preferences route * docs(api): sync ChatGPT route index with profile feed OAuth and activity preferences * test(feed): account for retention sweep in personalized timeline route * test(feed): match multiline OAuth client lookup without false CI failure
217 lines
10 KiB
C#
217 lines
10 KiB
C#
// SPDX-License-Identifier: MPL-2.0
|
|
// Integration test: real MariaDB, real OglProfileFeedStore, concurrent writes
|
|
// and the SQL contract of account deletion; isolated synthetic local avatars.
|
|
using System;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using MySql.Data.MySqlClient;
|
|
using NexVerse.Server.Api;
|
|
using OpenMetaverse;
|
|
|
|
string connection = Environment.GetEnvironmentVariable("NEX_FEED_MARIADB");
|
|
if (string.IsNullOrWhiteSpace(connection))
|
|
throw new InvalidOperationException("NEX_FEED_MARIADB is required.");
|
|
|
|
using var bootstrap = new MySqlConnection(connection);
|
|
bootstrap.Open();
|
|
// CI only. Reuse the ephemeral test schema, but never replace a preexisting
|
|
// UserAccounts table belonging to another test suite.
|
|
bool createdSyntheticUsers = Convert.ToInt32(Scalar(bootstrap, null,
|
|
"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='UserAccounts'")) == 0;
|
|
Exec(bootstrap, null, @"CREATE TABLE IF NOT EXISTS `UserAccounts` (
|
|
`PrincipalID` CHAR(36) NOT NULL PRIMARY KEY
|
|
) ENGINE=InnoDB DEFAULT CHARSET=ascii");
|
|
|
|
UUID alice = UUID.Random();
|
|
UUID bob = UUID.Random();
|
|
Exec(bootstrap, null, "INSERT INTO `UserAccounts` (`PrincipalID`) VALUES (@id)",
|
|
("@id", alice.ToString()));
|
|
Exec(bootstrap, null, "INSERT INTO `UserAccounts` (`PrincipalID`) VALUES (@id)",
|
|
("@id", bob.ToString()));
|
|
|
|
OglProfileFeedStore store = new OglProfileFeedStore(connection, 180);
|
|
try
|
|
{
|
|
Check(store.CreatePost(alice, "Alice first", out UUID post),
|
|
"own post failed");
|
|
Check(store.AddComment(post, bob, "Bob comment", out _),
|
|
"comment failed");
|
|
UUID moderator = UUID.Random();
|
|
Check(store.AddComment(post, bob, "Moderation test", out UUID moderationComment),
|
|
"moderation fixture failed");
|
|
Check(!store.DeleteComment(alice, post, moderationComment, moderator),
|
|
"unprivileged visitor deleted another avatar's comment");
|
|
Check(store.DeleteComment(alice, post, moderationComment, moderator, true),
|
|
"explicitly authorized moderation failed");
|
|
Check(store.Like(post, bob, true), "like failed");
|
|
Check(store.Follow(alice, bob, true), "follow failed");
|
|
Check(store.IsFollowing(alice, bob), "follow state not visible");
|
|
Check(store.ListFollowingPosts(bob).Any(x =>
|
|
x.Owner == alice && x.Entry.Id == post.ToString()),
|
|
"follower timeline did not include public owner's post");
|
|
Check(store.ListLikedPostIds(alice, bob).Contains(post.ToString()),
|
|
"profile reaction state missing");
|
|
Check(store.ListLikedFollowingPostIds(bob).Contains(post.ToString()),
|
|
"timeline reaction state missing");
|
|
Check(store.ListPosts(alice).Count == 1, "own post not visible");
|
|
Check(store.ListPosts(alice)[0].Likes == 1 &&
|
|
store.ListPosts(alice)[0].Comments == 1 &&
|
|
store.Followers(alice) == 1, "interactions missing");
|
|
|
|
// Lock Bob's account in the delete transaction, then race a new post
|
|
// from another independent connection. Once deleted, the second writer
|
|
// cannot create a ghost row for the missing account.
|
|
using (var delete = new MySqlConnection(connection))
|
|
{
|
|
delete.Open();
|
|
using var tx = delete.BeginTransaction();
|
|
Check(Scalar(delete, tx, @"SELECT 1 FROM `UserAccounts`
|
|
WHERE `PrincipalID`=@id FOR UPDATE", ("@id", bob.ToString())) != null,
|
|
"Bob account missing");
|
|
|
|
var race = Task.Run(() => store.CreatePost(bob, "racing post", out _));
|
|
await Task.Delay(200);
|
|
PurgeAvatar(delete, tx, bob);
|
|
tx.Commit();
|
|
Check(!await race.WaitAsync(TimeSpan.FromSeconds(15)),
|
|
"deleted avatar was allowed to post");
|
|
}
|
|
|
|
Check(store.ListComments(post).Count == 0,
|
|
"deleted avatar comment survived");
|
|
Check(store.ListPosts(alice)[0].Likes == 0,
|
|
"deleted avatar like survived");
|
|
Check(store.Followers(alice) == 0,
|
|
"deleted avatar follow survived");
|
|
Check(!store.CreatePost(bob, "ghost", out _),
|
|
"deleted avatar wrote another post");
|
|
Check(!store.Follow(alice, bob, true),
|
|
"deleted avatar followed another resident");
|
|
|
|
// Retention is enforced by read even if the periodic sweep is delayed.
|
|
long expired = DateTimeOffset.UtcNow.ToUnixTimeSeconds() - 181L * 86400;
|
|
Exec(bootstrap, null,
|
|
"UPDATE ogl_profile_feed_posts SET created_at=@expired WHERE id=@id",
|
|
("@expired", expired), ("@id", post.ToString()));
|
|
Check(store.ListPosts(alice).Count == 0,
|
|
"old content exposed past retention");
|
|
store.PruneExpired();
|
|
Check(Scalar(bootstrap, null,
|
|
"SELECT COUNT(*) FROM ogl_profile_feed_posts WHERE id=@id",
|
|
("@id", post.ToString())).ToString() == "0",
|
|
"retention purge did not physically delete post");
|
|
|
|
// Current posts remain valid. Deleting their owner cascades correctly.
|
|
Check(store.CreatePost(alice, "Second post", out UUID second),
|
|
"second post failed");
|
|
|
|
// Auto activity is OFF until the local avatar explicitly opts in.
|
|
Check(!store.GetActivitySettings(alice).Events &&
|
|
!store.GetActivitySettings(alice).Classifieds,
|
|
"automatic public posts must default to disabled");
|
|
Guid eventId = Guid.NewGuid();
|
|
Guid classifiedId = Guid.NewGuid();
|
|
Check(!store.TryCreateActivityPost(alice, "event", eventId, "Event without consent"),
|
|
"an event was posted without avatar consent");
|
|
Check(store.SetActivitySettings(alice, true, false),
|
|
"unable to save per-avatar event consent");
|
|
Check(store.GetActivitySettings(alice).Events &&
|
|
!store.GetActivitySettings(alice).Classifieds,
|
|
"per-avatar auto activity preferences not persisted");
|
|
Check(store.TryCreateActivityPost(alice, "event", eventId, "Event after consent"),
|
|
"consented event was not posted");
|
|
Check(!store.TryCreateActivityPost(alice, "event", eventId, "Repeated delivery"),
|
|
"same approved event was posted twice");
|
|
Check(!store.TryCreateActivityPost(alice, "classified", classifiedId,
|
|
"Classified without consent"), "classified was posted without opt-in");
|
|
Check(store.SetActivitySettings(alice, true, true),
|
|
"unable to enable classified activity");
|
|
Check(store.TryCreateActivityPost(alice, "classified", classifiedId,
|
|
"New approved classified"), "consented classified was not posted");
|
|
using (var delete = new MySqlConnection(connection))
|
|
{
|
|
delete.Open();
|
|
using var tx = delete.BeginTransaction();
|
|
Check(Scalar(delete, tx, @"SELECT 1 FROM `UserAccounts`
|
|
WHERE `PrincipalID`=@id FOR UPDATE", ("@id", alice.ToString())) != null,
|
|
"Alice account missing");
|
|
PurgeAvatar(delete, tx, alice);
|
|
tx.Commit();
|
|
}
|
|
Check(!store.IsPostOwned(alice, second),
|
|
"deleted account's content survived");
|
|
Check(Scalar(bootstrap, null,
|
|
"SELECT COUNT(*) FROM ogl_profile_feed_activity_settings WHERE owner=@id",
|
|
("@id", alice.ToString())).ToString() == "0",
|
|
"deleted resident's auto consent survived");
|
|
Check(Scalar(bootstrap, null,
|
|
"SELECT COUNT(*) FROM ogl_profile_feed_activity_receipts WHERE owner=@id",
|
|
("@id", alice.ToString())).ToString() == "0",
|
|
"deleted resident's activity receipts survived");
|
|
Check(!store.CreatePost(alice, "ghost", out _),
|
|
"deleted owner could post");
|
|
Console.WriteLine("OGL Profile Feed MariaDB deletion, lock and retention: PASS");
|
|
}
|
|
finally
|
|
{
|
|
// Idempotent teardown for unexpected test failures on an ephemeral CI DB.
|
|
Exec(bootstrap, null, "DELETE FROM ogl_profile_feed_comments WHERE author IN (@a,@b)",
|
|
("@a", alice.ToString()), ("@b", bob.ToString()));
|
|
Exec(bootstrap, null, "DELETE FROM ogl_profile_feed_likes WHERE actor IN (@a,@b)",
|
|
("@a", alice.ToString()), ("@b", bob.ToString()));
|
|
Exec(bootstrap, null, "DELETE FROM ogl_profile_feed_follows WHERE owner IN (@a,@b) OR follower IN (@a,@b)",
|
|
("@a", alice.ToString()), ("@b", bob.ToString()));
|
|
Exec(bootstrap, null, "DELETE FROM ogl_profile_feed_activity_receipts WHERE owner IN (@a,@b)",
|
|
("@a", alice.ToString()), ("@b", bob.ToString()));
|
|
Exec(bootstrap, null, "DELETE FROM ogl_profile_feed_activity_settings WHERE owner IN (@a,@b)",
|
|
("@a", alice.ToString()), ("@b", bob.ToString()));
|
|
Exec(bootstrap, null, "DELETE FROM ogl_profile_feed_posts WHERE owner IN (@a,@b)",
|
|
("@a", alice.ToString()), ("@b", bob.ToString()));
|
|
Exec(bootstrap, null, "DELETE FROM `UserAccounts` WHERE `PrincipalID` IN (@a,@b)",
|
|
("@a", alice.ToString()), ("@b", bob.ToString()));
|
|
if (createdSyntheticUsers)
|
|
Exec(bootstrap, null, "DROP TABLE `UserAccounts`");
|
|
}
|
|
|
|
static void PurgeAvatar(MySqlConnection db, MySqlTransaction tx, UUID id)
|
|
{
|
|
// All writes share the same transaction, mirroring the production
|
|
// PurgeLocalProfileFeed and account row deletion contract.
|
|
string p = id.ToString();
|
|
Exec(db, tx, "DELETE FROM ogl_profile_feed_comments WHERE author=@id", ("@id", p));
|
|
Exec(db, tx, "DELETE FROM ogl_profile_feed_likes WHERE actor=@id", ("@id", p));
|
|
Exec(db, tx, "DELETE FROM ogl_profile_feed_follows WHERE owner=@id OR follower=@id", ("@id", p));
|
|
Exec(db, tx, "DELETE FROM ogl_profile_feed_activity_receipts WHERE owner=@id", ("@id", p));
|
|
Exec(db, tx, "DELETE FROM ogl_profile_feed_activity_settings WHERE owner=@id", ("@id", p));
|
|
Exec(db, tx, "DELETE FROM ogl_profile_feed_posts WHERE owner=@id OR author=@id", ("@id", p));
|
|
Exec(db, tx, "DELETE FROM `UserAccounts` WHERE `PrincipalID`=@id", ("@id", p));
|
|
}
|
|
|
|
static object Scalar(MySqlConnection db, MySqlTransaction tx, string sql,
|
|
params (string key, object value)[] parameters)
|
|
{
|
|
using var cmd = db.CreateCommand();
|
|
cmd.Transaction = tx;
|
|
cmd.CommandText = sql;
|
|
foreach (var parameter in parameters)
|
|
cmd.Parameters.AddWithValue(parameter.key, parameter.value);
|
|
return cmd.ExecuteScalar();
|
|
}
|
|
|
|
static void Exec(MySqlConnection db, MySqlTransaction tx, string sql,
|
|
params (string key, object value)[] parameters)
|
|
{
|
|
using var cmd = db.CreateCommand();
|
|
cmd.Transaction = tx;
|
|
cmd.CommandText = sql;
|
|
foreach (var parameter in parameters)
|
|
cmd.Parameters.AddWithValue(parameter.key, parameter.value);
|
|
cmd.ExecuteNonQuery();
|
|
}
|
|
|
|
static void Check(bool condition, string message)
|
|
{
|
|
if (!condition)
|
|
throw new InvalidOperationException("OGL Feed MariaDB: " + message);
|
|
}
|