Hi, I have been trying to replicate what you are doing with labels, but unsuccessful. I am reaching out in hope for some help.
After days, my code is bloated, but as long as I can't figure out what I am doing wrong, that's the way it goes.
In my test code, the labeler, login user and the moderator user are the same. But I am hoping to have a separate moderatorUser in the future. But that's optional. My main goes are to get the moderation over on c# and .net, just because I am more comfortable with c#/.net for running services in the cloud.
ANY help is appriciated, because I am stuck.
string username = "login username";
string password = "login password";
string labelerDid = "did:plc:dam the labeler";
string moderatorUser = labelerDid; // for now, same user
string posterAuthorDid = "did:plc:7trv the posting user";
string posterCollection = "app.bsky.feed.post";
string posterRkey = "3ld the post Rkey";
var atProtocol = new ATProtocolBuilder()
//.WithInstanceUrl(ATDid.Create(labelerDid), serviceType: "#atproto_labeler")
.EnableAutoRenewSession(true)
.WithLogger(new DebugLoggerProvider().CreateLogger("FishyFlip")).Build();
var (session, error) = await atProtocol.AuthenticateWithPasswordResultAsync(username, password);
if (session is null || atProtocol is null) { Console.WriteLine("Failed to start."); return; }
Console.WriteLine("Authenticated.");
// Get ModeratorOptions !!
// Get the labelers profileView
// TODO: converted from profileviewdetailed (?)
ProfileView labelerProfile = await ProfileTools.GetProfileAsync(atProtocol, ATIdentifier.Create(labelerDid));
// Get moderator
var moderator = ModeratorBuilder.DefineModerationOptions(labelerProfile, moderatorUser);
// Get the post
var (post, erro) = await atProtocol.Repo.GetRecordAsync(
repo: ATIdentifier.Create(posterAuthorDid),
collection: posterCollection,
rkey: posterRkey);
// TODO: Handle error
ProfileViewBasic posterProfileView = await ProfileTools.GetProfileBasicAsync(atProtocol, ATIdentifier.Create(posterAuthorDid));
var postToModerate = new PostView(
author: posterProfileView,
labels: [new Label(src: labelerProfile.Did, uri: post.Uri.Href, val: "naugty_post", cts: DateTime.Now)]
);
ModerationDecision result = moderator.ModeratePost(post: postToModerate);
Console.WriteLine("done");
The functions ProfileTools.GetProfileAsync and ProfileTools.GetProfileBasicAsync is just me building the objects from a ProfileViewDetailed object. I build the Moderator object ModeratorBuilder.DefineModerationOptions, it's a complete replica of config on the Ozone server. In the future I will probably make this from the running config or a json replica.
The ModerationDecision object looks "good", but the label isn't on the post.
Any tips where to look?
Hi, I have been trying to replicate what you are doing with labels, but unsuccessful. I am reaching out in hope for some help.
After days, my code is bloated, but as long as I can't figure out what I am doing wrong, that's the way it goes.
In my test code, the labeler, login user and the moderator user are the same. But I am hoping to have a separate moderatorUser in the future. But that's optional. My main goes are to get the moderation over on c# and .net, just because I am more comfortable with c#/.net for running services in the cloud.
ANY help is appriciated, because I am stuck.
The functions
ProfileTools.GetProfileAsyncandProfileTools.GetProfileBasicAsyncis just me building the objects from a ProfileViewDetailed object. I build the Moderator objectModeratorBuilder.DefineModerationOptions, it's a complete replica of config on the Ozone server. In the future I will probably make this from the running config or a json replica.The ModerationDecision object looks "good", but the label isn't on the post.
Any tips where to look?