question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can I change the user behind the VotableThing instance?

See original GitHub issue

Imagine I have two logins:

var importReddit = new Reddit();
importReddit.LogIn(TargetUsername, TargetPassword);

var exportReddit = new Reddit();
exportReddit.LogIn(DestUsername, DestPassword);

var savedThingies = importAccount.GetSaved();

How can I then transfer the saved things to the second account?

Ideally, I need to be able to .SetUser(User) and then loop and call Save. IE:

var savedThingies = importAccount.GetSaved();
foreach (var savedPost in savedThingies)
{
    savedPost.SetReddit(exportReddit); // or SetUser
    savedPost.Save();
}

I was thinking there had to be another way. Can I somehow get the URI from savedPost, load up a new VotableItem or something and then save?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
VictorioBerracommented, Feb 3, 2021

I just tested this with the following code and it seems to be working.

var savedThingies = importAccount.GetSaved().ToList();
// Change login instance!
importReddit.LogIn(DestUsername, DestPassword);
foreach (var savedPost in savedThingies)
{
    Console.WriteLine("Saving thing " + savedPost.FullName + " " + savedPost.Id + " " + savedPost.Shortlink);
    try {
        savedPost.Save();
        Console.WriteLine("Success.");
    }
    catch(Exception ex)
    {
        Console.WriteLine("Failed!");
        Console.WriteLine(ex);
    }
}
0reactions
CrustyJewcommented, Feb 3, 2021

ohhh yeah that might work. So in that case you’d want to do a new “get post” on your import instance and then save the post. Alternatively I think you can actually just call the LogIn method again on your instance of Reddit to change the user like you were originally wanting to do now that I think about it more >.<

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changing your instance user role
To change your user role: Open the Account menu to access the My Instance section. Click the Change User Role instance action. ·...
Read more >
Feature request: Make it possible to change a username
I know it's technically difficult, but still it's very important for trans and non-binary people to be able to change their username.
Read more >
Change the name of your macOS user account and home ...
You can change the name of your user account only while logged in to a different account, which must be an administrator account....
Read more >
Considerations for Editing Users
Keep in mind that Salesforce Customer Support can't change usernames or deactivate users from an org. If you get a Duplicate Username error,...
Read more >
Change User Information
Update User Profile · From the navigation header, select More > Admin. · Under Governance, select People. · In the list of instance...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found