Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dependencies to match quality checklist #35

Merged
merged 12 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor
node_modules
.sqlite
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomStringSomeRandomString
DB_DATABASE=airtng

# Twilio API credentials
# Found at https://www.twilio.com/user/account/voice
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Laravel

on:
push:
branches: [ master ]
pull_request:
branches: [ master, next ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate --force
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Create Database
run: |
mkdir -p database
touch database/database-test.sqlite
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
po5i marked this conversation as resolved.
Show resolved Hide resolved
run: |
php artisan migrate --database=testing --force
vendor/bin/phpunit
13 changes: 13 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pull_request_rules:
- name: automatic merge for Dependabot pull requests
conditions:
- author=dependabot-preview[bot]
- status-success=build (macos-latest, 10)
- status-success=build (macos-latest, 12)
- status-success=build (windows-latest, 10)
- status-success=build (windows-latest, 12)
- status-success=build (ubuntu-latest, 10)
- status-success=build (ubuntu-latest, 12)
po5i marked this conversation as resolved.
Show resolved Hide resolved
actions:
merge:
method: squash
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:37:"PHPUnit\Runner\DefaultTestResultCache":880:{a:2:{s:7:"defects";a:7:{s:37:"ReservationControllerTest::testCreate";i:4;s:50:"ReservationControllerTest::testAcceptRejectConfirm";i:4;s:49:"ReservationControllerTest::testAcceptRejectReject";i:4;s:52:"ReservationControllerTest::testAcceptRejectNoPending";i:4;s:31:"UserControllerTest::testNewUser";i:4;s:53:"VacationPropertyControllerTest::testCreateNewProperty";i:4;s:48:"VacationPropertyControllerTest::testEditProperty";i:4;}s:5:"times";a:7:{s:37:"ReservationControllerTest::testCreate";d:0.098;s:50:"ReservationControllerTest::testAcceptRejectConfirm";d:0.002;s:49:"ReservationControllerTest::testAcceptRejectReject";d:0.002;s:52:"ReservationControllerTest::testAcceptRejectNoPending";d:0.002;s:31:"UserControllerTest::testNewUser";d:0.002;s:53:"VacationPropertyControllerTest::testCreateNewProperty";d:0.002;s:48:"VacationPropertyControllerTest::testEditProperty";d:0.002;}}}
po5i marked this conversation as resolved.
Show resolved Hide resolved
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

73 changes: 73 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contributing to Twilio

All third party contributors acknowledge that any contributions they provide will be made under the same open source license that the open source project is provided under.
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM php:7.4

WORKDIR /usr/src/app

RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y git
RUN apt-get install -y zip unzip

COPY composer* ./
RUN curl --silent --show-error https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer


COPY . .
RUN make install

EXPOSE 8000

CMD [ "php", "artisan", "serve", "--host=0.0.0.0" ]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Twilio Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
install:
touch database/database.sqlite
touch database/database-test.sqlite
composer install
php artisan key:generate --force
php artisan migrate --force

serve-setup:
php artisan serve --host=127.0.0.1
open-browser:
python3 -m webbrowser "http://127.0.0.1:8000";
serve: open-browser serve-setup
18 changes: 10 additions & 8 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Exceptions;

use Exception;
use Throwable;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
Expand All @@ -23,12 +23,12 @@ class Handler extends ExceptionHandler
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @param \Throwable $exception
* @return void
*
* @throws \Exception
*/
public function report(Exception $e)
public function report(Throwable $e)
{
return parent::report($e);
}
Expand All @@ -37,10 +37,12 @@ public function report(Exception $e)
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
* @param \Throwable $exception
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Throwable
*/
public function render($request, Exception $e)
public function render($request, Throwable $e)
{
if ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
Expand Down
21 changes: 16 additions & 5 deletions app/Http/Controllers/ReservationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use App\VacationProperty;
use DB;
use Twilio\Rest\Client;
use Twilio\Twiml;
use Twilio\TwiML\MessagingResponse;

class ReservationController extends Controller
{
Expand Down Expand Up @@ -46,11 +46,22 @@ public function acceptReject(Request $request)
{
$hostNumber = $request->input('From');
$smsInput = strtolower($request->input('Body'));
$host = User::where(DB::raw("CONCAT('+',country_code::text, phone_number::text)"), 'LIKE', "%".$hostNumber."%")
->get()
->first();

$connection = config('database.default');
$driver = config("database.connections.{$connection}.driver");
if ($driver === 'sqlite') {
$concat_string = DB::raw("'+' || country_code || phone_number");
} else {
$concat_string = DB::raw("CONCAT('+',country_code::text, phone_number::text)");
}
po5i marked this conversation as resolved.
Show resolved Hide resolved

$host = User::where($concat_string, 'LIKE', "%".$hostNumber."%")
->get()
->first();
$reservation = $host->pendingReservations()->first();

$smsResponse = null;

if (!is_null($reservation))
{
if (strpos($smsInput, 'yes') !== false || strpos($smsInput, 'accept') !== false)
Expand All @@ -74,7 +85,7 @@ public function acceptReject(Request $request)

private function respond($smsResponse, $reservation)
{
$response = new Twiml();
$response = new MessagingResponse();
$response->message($smsResponse);

if (!is_null($reservation))
Expand Down
58 changes: 52 additions & 6 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,71 @@ class Kernel extends HttpKernel
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];

/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],

'api' => [
'throttle:60,1',
'bindings',
],
];

/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];

/**
* The priority-sorted list of middleware.
*
* This forces non-global middleware to always be in the given order.
*
* @var array
*/
protected $middlewarePriority = [
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\Authenticate::class,
\Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Illuminate\Auth\Middleware\Authorize::class,
];
}
Loading