-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
522 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,28 +4,67 @@ | |
|
||
use Auth; | ||
use Emoji; | ||
use Notifynder; | ||
use App\Models\User; | ||
use App\Models\Team; | ||
use App\Models\Wiki; | ||
use App\Models\Page; | ||
use App\Models\Space; | ||
use App\Models\Comment; | ||
use Illuminate\Http\Request; | ||
|
||
/** | ||
* Class CommentController | ||
* | ||
* @package App\Http\Controllers | ||
* @author Zeeshan Ahmed <[email protected]> | ||
*/ | ||
class CommentController extends Controller | ||
{ | ||
/** | ||
* @var \Illuminate\Http\Request | ||
*/ | ||
protected $request; | ||
|
||
protected $comment; | ||
|
||
/** | ||
* @var \App\Models\Page | ||
*/ | ||
protected $page; | ||
|
||
public function __construct(Request $request, Page $page, Comment $comment) | ||
/** | ||
* @var \App\Models\Comment | ||
*/ | ||
protected $comment; | ||
|
||
/** | ||
* @var \App\Models\User | ||
*/ | ||
protected $user; | ||
|
||
/** | ||
* CommentController constructor. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \App\Models\Page $page | ||
* @param \App\Models\Comment $comment | ||
* @param \App\Models\User $user | ||
*/ | ||
public function __construct(Request $request, Page $page, Comment $comment, User $user) | ||
{ | ||
$this->page = $page; | ||
$this->user = $user; | ||
$this->request = $request; | ||
$this->comment = $comment; | ||
$this->page = $page; | ||
} | ||
|
||
/** | ||
* Create a new wiki comment. | ||
* | ||
* @param \App\Models\Team $team | ||
* @param \App\Models\Space $space | ||
* @param \App\Models\Wiki $wiki | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function storeWikiComment(Team $team, Space $space, Wiki $wiki) | ||
{ | ||
$this->validate($this->request, Comment::COMMENT_RULES); | ||
|
@@ -45,24 +84,32 @@ public function storeWikiComment(Team $team, Space $space, Wiki $wiki) | |
]); | ||
} | ||
|
||
/** | ||
* Notify all users that are mentioned in comment. | ||
* | ||
* @param $mentions | ||
* @param $wiki | ||
* @param null $page | ||
* @return bool | ||
*/ | ||
public function notifyMentionedUsers($mentions, $wiki, $page = null) | ||
{ | ||
foreach ($mentions as $mention) { | ||
$mention = str_replace('@', '', $mention); | ||
|
||
$user = \App\Models\User::where('slug', $mention)->first(); | ||
$user = $this->user->getUser($mention);; | ||
|
||
if(is_null($page)) { | ||
$url = route('wikis.show', [Auth::user()->getTeam()->slug, $wiki->space->slug, $wiki->slug]); | ||
\Notifynder::category('wiki.user.mentioned') | ||
Notifynder::category('wiki.user.mentioned') | ||
->from(Auth::user()->id) | ||
->to($user->id) | ||
->url($url) | ||
->extra(['wiki_name' => $wiki->name, 'username' => Auth::user()->name]) | ||
->send(); | ||
} else { | ||
$url = route('pages.show', [Auth::user()->getTeam()->slug, $wiki->space->slug, $wiki->slug, $page->slug]); | ||
\Notifynder::category('page.user.mentioned') | ||
Notifynder::category('page.user.mentioned') | ||
->from(Auth::user()->id) | ||
->to($user->id) | ||
->url($url) | ||
|
@@ -75,6 +122,15 @@ public function notifyMentionedUsers($mentions, $wiki, $page = null) | |
return true; | ||
} | ||
|
||
/** | ||
* Create a new page comment. | ||
* | ||
* @param \App\Models\Team $team | ||
* @param \App\Models\Space $space | ||
* @param \App\Models\Wiki $wiki | ||
* @param \App\Models\Page $page | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function storePageComment(Team $team, Space $space, Wiki $wiki, Page $page) | ||
{ | ||
|
||
|
@@ -95,15 +151,25 @@ public function storePageComment(Team $team, Space $space, Wiki $wiki, Page $pag | |
]); | ||
} | ||
|
||
/** | ||
* Delete comment. | ||
* | ||
* @return \Illuminate\Http\JsonResponse | ||
*/ | ||
public function destroy() | ||
{ | ||
$this->comment->where('id', $this->request->get('commentId'))->where('user_id', Auth::user()->id)->delete(); | ||
$this->comment->deleteComment($this->request->get('commentId')); | ||
|
||
return response()->json([ | ||
'deleted' => true, | ||
], 200); | ||
} | ||
|
||
/** | ||
* Update comment. | ||
* | ||
* @return \Illuminate\Http\JsonResponse | ||
*/ | ||
public function update() | ||
{ | ||
$this->validate($this->request, Comment::COMMENT_RULES); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,29 +4,54 @@ | |
|
||
use DB; | ||
use Carbon\Carbon; | ||
use App\Models\Team; | ||
use App\Models\Integration; | ||
use Illuminate\Http\Request; | ||
use App\Models\{ | ||
Team, Integration | ||
}; | ||
|
||
/** | ||
* Class IntegrationController | ||
* | ||
* @package App\Http\Controllers | ||
* @author Zeeshan Ahmed <[email protected]> | ||
*/ | ||
class IntegrationController extends Controller | ||
{ | ||
/** | ||
* @var \Illuminate\Http\Request | ||
*/ | ||
protected $request; | ||
|
||
/** | ||
* @var \App\Models\Integration | ||
*/ | ||
protected $integration; | ||
|
||
/** | ||
* IntegrationController constructor. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \App\Models\Integration $integration | ||
*/ | ||
public function __construct(Request $request, Integration $integration) | ||
{ | ||
$this->request = $request; | ||
$this->integration = $integration; | ||
} | ||
|
||
/** | ||
* Store a new slack integration. | ||
* | ||
* @param \App\Models\Team $team | ||
* @return \Illuminate\Http\RedirectResponse | ||
* | ||
*/ | ||
public function storeSlackIntegration(Team $team) | ||
{ | ||
$this->validate($this->request, Integration::INTEGRATION_RULES); | ||
|
||
$teamIntegration = $this->integration->storeSlackIntegration($this->request->all(), $team->id); | ||
|
||
// Update all the integration actions on which user want to be notified on slack. | ||
foreach ($this->request->integrations as $integration) { | ||
DB::table('team_integration_actions')->insert([ | ||
'integration_id' => $teamIntegration->id, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,22 +3,46 @@ | |
namespace App\Http\Controllers; | ||
|
||
use Mail; | ||
use Illuminate\Http\Request; | ||
use App\Models\Team; | ||
use App\Models\Invite; | ||
use Illuminate\Http\Request; | ||
|
||
/** | ||
* Class InviteController | ||
* | ||
* @package App\Http\Controllers | ||
* @author Zeeshan Ahmed <[email protected]> | ||
*/ | ||
class InviteController extends Controller | ||
{ | ||
/** | ||
* @var \Illuminate\Http\Request | ||
*/ | ||
protected $request; | ||
|
||
/** | ||
* @var \App\Models\Invite | ||
*/ | ||
protected $invite; | ||
|
||
/** | ||
* InviteController constructor. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \App\Models\Invite $invite | ||
*/ | ||
public function __construct(Request $request, Invite $invite) | ||
{ | ||
$this->request = $request; | ||
$this->invite = $invite; | ||
} | ||
|
||
/** | ||
* Invite user to team. | ||
* | ||
* @param \App\Models\Team $team | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function store(Team $team) | ||
{ | ||
$this->validate($this->request, Invite::INVITE_RULES, [ | ||
|
@@ -36,6 +60,13 @@ public function store(Team $team) | |
]); | ||
} | ||
|
||
/** | ||
* Send invitation mail to the invited user. | ||
* | ||
* @param $invitation | ||
* @param $team | ||
* @return bool | ||
*/ | ||
public function sendInvitationEmail($invitation, $team) | ||
{ | ||
Mail::send('mails.invitation', ['invitation' => $invitation, 'team' => $team], function ($message) use ($invitation, $team) { | ||
|
@@ -47,9 +78,16 @@ public function sendInvitationEmail($invitation, $team) | |
return true; | ||
} | ||
|
||
/** | ||
* Delete pending invitation. | ||
* | ||
* @param \App\Models\Team $team | ||
* @param $invitationCode | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function destroy(Team $team, $invitationCode) | ||
{ | ||
$this->invite->where('code', $invitationCode)->where('team_id', $team->id)->delete(); | ||
$this->invite->deleteInvitation($invitationCode, $team->id); | ||
|
||
return redirect()->back()->with([ | ||
'alert' => 'Invitation successfully removed.', | ||
|
Oops, something went wrong.