Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

WIP: Group feature #102

Merged
merged 34 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cebb0d6
added initial migration, model and controller for group feature. see …
andreas83 Mar 5, 2020
fd92133
Added Group views, controllers, routes etc.
andreas83 Mar 6, 2020
e4567ef
added group create form
andreas83 Mar 6, 2020
93f2836
moved fileupload into one helper class
andreas83 Mar 7, 2020
cbdf908
Some more work on group feature
andreas83 Mar 8, 2020
84a019d
latest work on group
andreas83 Mar 9, 2020
77da934
upated readme
andreas83 Mar 9, 2020
4f7219a
Group Feature
andreas83 Mar 9, 2020
66baaf7
Merge branch 'feature/101-Groups' of https://github.com/andreas83/Soc…
andreas83 Mar 9, 2020
d4759f8
Added join/leave function
andreas83 Mar 10, 2020
8cf7c53
Added membership box to group pages
andreas83 Mar 10, 2020
674bde7
Added Stats to content and group table (members, posts, comments etc)
andreas83 Mar 17, 2020
c665d2b
added is member function
andreas83 Mar 18, 2020
3ffd255
Merge branch 'feature/101-Groups' of https://github.com/andreas83/Soc…
andreas83 Mar 18, 2020
f4e8a6c
bugfix for login issues
andreas83 Mar 18, 2020
9865fa9
fix register issue
andreas83 Mar 18, 2020
1706593
removed test funciton
andreas83 Mar 19, 2020
5b44925
fixed upload avatar issue
andreas83 Mar 21, 2020
b234218
added background upload option for moderators
andreas83 Mar 21, 2020
21da95d
fixed anonymous postings
andreas83 Mar 21, 2020
de4d7b1
fixed dynamic type conversion :(
andreas83 Mar 21, 2020
404fe41
fixed bg change
andreas83 Mar 21, 2020
ce47e34
some work on the lock an feel
andreas83 Mar 22, 2020
82b964f
fixed comment layout
andreas83 Mar 22, 2020
122c601
fixed css issue
andreas83 Mar 22, 2020
1e20787
some css changes
andreas83 Mar 23, 2020
35b4970
fixed some js warnings
andreas83 Mar 23, 2020
44f548e
some updates of external dependencies - maybe related to #116y
Sep 21, 2020
785fe07
added new function approveMembership and declineMembership as part of…
andreas83 Jan 19, 2021
ba8e2c5
Merge branch 'feature/101-Groups' of https://github.com/andreas83/Soc…
andreas83 Jan 19, 2021
d94a117
hotfix for security issue #116y
Sep 25, 2020
d015ce4
added missing namespacey
Sep 27, 2020
8ef0e28
added group_id to getter
andreas83 Jan 19, 2021
0785c69
added group id filter to get content endpoint
andreas83 Jan 19, 2021
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
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

## About Project

works pretty similar to a well known social network, but you can host it on your very own infrastructure. No external dependencies needed. Focus of this project was security and performance.
works pretty similar to a well known social network, but you can host it on your very own infrastructure. No external dependencies needed. Focus of this project is stability. security and performance.

## Anouncement

On 13.02.2020 i decided to move version 2.0 to deprecated branch
At moment the new master has less features than 2.0, but iam working hard to restore the most important ones.
On 13.02.2020 i decided to mark version 2.0 as deprecated and started to rewrite everything from scratch.
At moment the master has less features than 2.0, but iam working hard to restore the most important ones.
Feel free to join the development process by creating tasks (feature request) or make code improvements.


Expand Down Expand Up @@ -135,16 +135,14 @@ Demo is still alive here: https://social.codejungle.org/
Please report feature requests and bugs.
Demo is here: https://dev.codejungle.org/

Planed features:
Working features are:

oauth login
websockets (notifications)
hashtags interpretation
image gallery
profile
* Share, Commnet, Reshare, Likes
* OpenGraph Tag parsing
* OAuth login via Github and Facebook

low prio
syntaxhighlighting
**Attention**
This is a early stage beta, things can change drasticly.


## 4. Donate
Expand Down
2 changes: 1 addition & 1 deletion app/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Content extends Model
*/
protected $fillable = [
'user_id', 'html_content', 'json_content', 'anonymous',
'has_comment', 'is_comment', 'parent_id',
'has_comment', 'is_comment', 'comments', 'parent_id',
];

/**
Expand Down
23 changes: 23 additions & 0 deletions app/Group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Group extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'description', 'avatar',
'background', 'visibility', 'members', 'posts',
];

public function content()
{
return $this->belongsToMany('App\Content');
}
}
25 changes: 25 additions & 0 deletions app/GroupMembers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class GroupMembers extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'group_id', 'user_id', 'status', 'is_moderator',
];

/**
* Get the user.
*/
public function user()
{
return $this->belongsTo('App\User');
}
}
2 changes: 2 additions & 0 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ public function socialLiteLogin($provider)

return response()->json([
'user' => $user,
'groups' => $user->groups()->get()
]);
}

protected function authenticated(Request $request, $user)
{
return response()->json([
'user' => $user,
'groups' => $user->groups()->get()
]);
}
}
36 changes: 33 additions & 3 deletions app/Http/Controllers/ContentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
namespace App\Http\Controllers;

use App\Content;
use App\Group;
use App\Http\Controllers\Helper\RemoteContent;
use App\Http\Requests\ContentDestroyRequest;
use App\Http\Requests\ContentStoreRequest;
use Auth;
use DB;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Stevebauman\Purify\Facades\Purify;

class ContentController extends Controller
{
Expand All @@ -19,20 +21,36 @@ public function store(ContentStoreRequest $request)

$content = new Content();
$content->json_content = json_encode($validated['json_content']);
$content->html_content = $validated['html_content'];
$content->anonymous = $validated['anonymous'];
$content->html_content = Purify::clean($validated['html_content']);
$content->anonymous = ($validated['anonymous'] ? 'true' : 'false');
if($validated['anonymous']==true)
{
$content->user_id=(getenv("anonymous") !== false ? getenv("anonymous") : 1 );
} else {
$content->user_id = Auth::user()->id;
}
$content->visibility = $validated['visibility'];

$content->has_comment = ($validated['has_comment'] ? 'true' : 'false');
$content->is_comment = ($validated['is_comment'] ? 'true' : 'false');
$content->comments = 0;
$content->parent_id = $validated['parent_id'];

$content->user_id = Auth::user()->id;
$content->group_id = ($request->group_id > 0 ? $request->group_id : 0);

if ($content->group_id > 0) {
$group = Group::find($content->group_id);
$group->posts = $group->posts + 1;
$group->save();
}


$content->save();

if ($request->is_comment) {
$parent = Content::find($request->parent_id);
$parent->has_comment = 'true';
$parent->comments = $parent->comments + 1;
$parent->save();
}

Expand Down Expand Up @@ -85,6 +103,9 @@ public function index(Request $request)
if ($request->has('user_id') && $request->user_id > 0) {
$content->where('users.id', '=', $request->user_id);
}
if ($request->has('group_id') && $request->group_id > 0) {
$content->where('contents.group_id', '=', $request->group_id);
}
if ($request->has('limit') && $request->limit <= 100) {
$content->limit($request->limit);
} else {
Expand All @@ -104,6 +125,15 @@ public function destroy(Request $request, $id)
$content = Content::find($id);

if ($content->user_id == Auth::user()->id) {
if ('true' == $content->is_comment) {
$parent = Content::find($content->parent_id);

$parent->comments = $parent->comments - 1;
if (0 == $parent->comments) {
$parent->has_comment = 'false';
}
$parent->save();
}
$content->destroy($id);
}
}
Expand Down
Loading