From 0172f0ce8ac543d287fef02786960d3e980556f4 Mon Sep 17 00:00:00 2001 From: Derf Null Date: Sun, 4 Jun 2023 14:28:04 +0200 Subject: add profile editor --- lib/Travelynx/Model/Users.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib/Travelynx/Model/Users.pm') diff --git a/lib/Travelynx/Model/Users.pm b/lib/Travelynx/Model/Users.pm index fbd53fd..7326e34 100644 --- a/lib/Travelynx/Model/Users.pm +++ b/lib/Travelynx/Model/Users.pm @@ -750,6 +750,30 @@ sub update_webhook_status { ); } +sub set_profile { + my ( $self, %opt ) = @_; + + my $db = $opt{db} // $self->{pg}->db; + my $uid = $opt{uid}; + my $profile = $opt{profile}; + + $db->update( + 'users', + { profile => JSON->new->encode($profile) }, + { id => $uid } + ); +} + +sub get_profile { + my ( $self, %opt ) = @_; + + my $db = $opt{db} // $self->{pg}->db; + my $uid = $opt{uid}; + + return $db->select( 'users', ['profile'], { id => $uid } ) + ->expand->hash->{profile}; +} + sub get_relation { my ( $self, %opt ) = @_; -- cgit v1.2.3