MightyNetwork::DB::User
Disclaimer: the objects that are mentionned here are objects as in Object-oriented programming, not as ActivityPub objects.
Model for users.
This structure is not federated.
MightyNetwork::DB::User inherits attributes from MightyNetwork::DB and adds the following attributes.
Primary key, UUID.
my $id = $user->id;
$user->id('e69b4429-4b6b-4e3e-bb2d-411770cd27a1');
Username of the user. Will be used for sign-in and to create the actor username.
my $username = $user->username;
$user->username('foo');
Salted hash of the user’s password.
my $password = $user->password;
$user->password('salted_hashed_password');
PostgreSQL’s timestamp. Date of creation of the user.
my $created_at = $user->created_at;
$user->created_at('2004-10-19 10:23:54');
MightyNetwork::DB::Note inherits methods from MightyNetwork::DB and adds the following methods.
Just a wrapper around MightyNetwork::DB#find_by_fields-hash-collection method, with no collection
argument.
my $user = MightyNetwork::DB::User->new(app => $c-> app)
->get_user_by_id($id);
Just a wrapper around MightyNetwork::DB#find_by_fields-hash-collection method, with no collection
argument.
my $user = MightyNetwork::DB::User->new(app => $c-> app)
->get_user_by_username($username);
Returns the MightyNetwork::DB::ActivityPub::Actor object linked to this user.
my $actor = $user->get_actor;
Returns a Mojo::Collection of followers linked to this user.
my $followers_collection = $user->get_followers
MightyNetwork::DB::User also adds the following private methods.
Returns a boolean indicating if the username is already taken.
if (MightyNetwork::DB::User->new(app => $c->app)->_is_username_taken('foo')) {
…
} else {
…
}
MightyNetwork::DB::User also modifies the following methods.
Before creating the database record, it checks if the username provided in the hash table is already taken.
Returns undef
if the username is already taken.
my $created_object = MightyNetwork::DB::User->new(app => $c->app)->create({ foo => 'bar' });
See MightyNetwork::DB#create-hash
MightyNetwork::DB, MightyNetwork::DB::ActivityPub::Actor, MightyNetwork::DB::ActivityPub::Follow, Mojo::Base