MightyNetwork :: DB :: User (source, CPAN)

CONTENTS

NAME

MightyNetwork::DB::User

Disclaimer: the objects that are mentionned here are objects as in Object-oriented programming, not as ActivityPub objects.

DESCRIPTION

Model for users.

This structure is not federated.

ATTRIBUTES

MightyNetwork::DB::User inherits attributes from MightyNetwork::DB and adds the following attributes.

id

Primary key, UUID.

my $id = $user->id;
$user->id('e69b4429-4b6b-4e3e-bb2d-411770cd27a1');

username

Username of the user. Will be used for sign-in and to create the actor username.

my $username = $user->username;
$user->username('foo');

password

Salted hash of the user’s password.

my $password = $user->password;
$user->password('salted_hashed_password');

created_at

PostgreSQL’s timestamp. Date of creation of the user.

my $created_at = $user->created_at;
$user->created_at('2004-10-19 10:23:54');

METHODS

MightyNetwork::DB::Note inherits methods from MightyNetwork::DB and adds the following methods.

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_id($id);

get_user_by_username($username)

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);

get_actor

Returns the MightyNetwork::DB::ActivityPub::Actor object linked to this user.

my $actor = $user->get_actor;

get_followers

Returns a Mojo::Collection of followers linked to this user.

my $followers_collection = $user->get_followers

PRIVATE METHODS

MightyNetwork::DB::User also adds the following private methods.

_is_username_taken($username)

Returns a boolean indicating if the username is already taken.

if (MightyNetwork::DB::User->new(app => $c->app)->_is_username_taken('foo')) {
    …
} else {
    …
}

MODIFIED METHODS

MightyNetwork::DB::User also modifies the following methods.

create($hash)

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

SEE ALSO

MightyNetwork::DB, MightyNetwork::DB::ActivityPub::Actor, MightyNetwork::DB::ActivityPub::Follow, Mojo::Base