diff options
Diffstat (limited to 'lib/Travelynx')
| -rw-r--r-- | lib/Travelynx/Command/database.pm | 25 | ||||
| -rw-r--r-- | lib/Travelynx/Controller/Account.pm | 25 | 
2 files changed, 50 insertions, 0 deletions
| diff --git a/lib/Travelynx/Command/database.pm b/lib/Travelynx/Command/database.pm index 79ff086..11a946e 100644 --- a/lib/Travelynx/Command/database.pm +++ b/lib/Travelynx/Command/database.pm @@ -456,6 +456,31 @@ my @migrations = (  			}  		);  	}, + +	# v10 -> v11 +	sub { +		my ($db) = @_; +		$db->query( +			qq{ +				create table webhooks ( +					user_id integer not null references users (id) primary key, +					enabled boolean not null, +					url varchar(1000) not null, +					token varchar(250), +					errored boolean, +					latest_run timestamptz, +					output text +				); +				comment on table webhooks is 'URLs and bearer tokens for push events'; +				create view webhooks_str as select +					user_id, enabled, url, token, errored, output, +					extract(epoch from latest_run) as latest_run_ts +					from webhooks +				; +				update schema_version set version = 11; +			} +		); +	},  );  sub setup_db { diff --git a/lib/Travelynx/Controller/Account.pm b/lib/Travelynx/Controller/Account.pm index 8d5b21f..75b8f02 100644 --- a/lib/Travelynx/Controller/Account.pm +++ b/lib/Travelynx/Controller/Account.pm @@ -230,6 +230,31 @@ sub privacy {  	}  } +sub webhook { +	my ($self) = @_; + +	my $hook = $self->get_webhook; + +	if ( $self->param('action') and $self->param('action') eq 'save' ) { +		$hook->{url}     = $self->param('url'); +		$hook->{token}   = $self->param('token'); +		$hook->{enabled} = $self->param('enabled') // 0; +		$self->set_webhook( +			url     => $hook->{url}, +			token   => $hook->{token}, +			enabled => $hook->{enabled} +		); +		$hook = $self->get_webhook; +	} +	else { +		$self->param( url     => $hook->{url} ); +		$self->param( token   => $hook->{token} ); +		$self->param( enabled => $hook->{enabled} ); +	} + +	$self->render( 'webhooks', hook => $hook ); +} +  sub change_mail {  	my ($self) = @_; | 
