Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
KyrneDev committed Jul 21, 2021
0 parents commit 8bc84aa
Show file tree
Hide file tree
Showing 58 changed files with 3,320 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/vendor
composer.phar
.DS_Store
Thumbs.db
node_modules
bower_components
.idea
.floo*
package-lock.json
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 Charlie

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.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Whisper - Private Messaging for Flarum
![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg?style=flat-square) ![Latest Stable Version](https://img.shields.io/packagist/v/kyrne/whisper.svg?style=flat-square) ![Donate](https://img.shields.io/static/v1?label=Donate&message=PayPal&color=Blue&style=flat-square&logo=Paypal&link=https%3A%2F%2Fpaypal.me%2FCharlieK20)

A [Flarum](http://flarum.org) extension. Add private messaging functionality to your Flarum Community!

Simple to install, no settings, just set the permission and you're ready to go.

Read all the info here:

t
45 changes: 45 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "kyrne/whisper",
"description": "Private Messaging for Flarum.",
"keywords": [
"flarum",
"friendsofflarum",
"kyrne",
"settings",
"points",
"private message"
],
"type": "flarum-extension",
"license": "MIT",
"authors": [
{
"name": "Charlie Kern",
"email": "[email protected]",
"homepage": "https://redevs.org"
}
],
"support": {
"issues": "https://github.com/kyrne/whisper-public/issues",
"source": "https://github.com/kyrne/whisper-public",
"forum": "https://discuss.flarum.org/d/24073-whisper-private-messaging-for-flarum"
},
"require": {
"flarum/core": "^1.0.2"
},
"autoload": {
"psr-4": {
"Kyrne\\Whisper\\": "src/"
}
},
"extra": {
"flarum-extension": {
"title": "Whisper",
"icon": {
"name": "fas fa-comments",
"background": "linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(224,64,251,1) 0%, rgba(33,150,243,1) 100%)",
"color": "#000"
},
"category": "feature"
}
}
}
64 changes: 64 additions & 0 deletions extend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php


namespace Kyrne\Whisper;

use Flarum\Api\Controller;
use Flarum\Extend;
use Flarum\Formatter\Event\Configuring;
use Flarum\User\User;
use Flarum\Api\Serializer\ForumSerializer;
use Flarum\Api\Serializer\CurrentUserSerializer;
use Kyrne\Whisper\Api\Controllers;
use Kyrne\Whisper\Api\Serializers\ConversationRecipientSerializer;
use Kyrne\Whisper\Api\Serializers\ConversationSerializer;

return [
(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js'),
(new Extend\Frontend('forum'))
->js(__DIR__.'/js/dist/forum.js')
->css(__DIR__.'/resources/less/extension.less')
->route('/whisper/messages/{id}', 'whisper.messages')
->route('/whisper/conversations', 'whisper.conversation'),
new Extend\Locales(__DIR__.'/resources/locale'),
(new Extend\Model(User::class))
->hasMany('conversations' ,ConversationUser::class, 'user_id'),
(new Extend\Routes('api'))
->get('/whisper/conversations', 'whisper.conversations.index', Controllers\ListConversationsController::class)
->get('/whisper/messages/{id}', 'whisper.messages.list', Controllers\ListMessagesController::class)
->post('/whisper/conversations', 'whisper.conversations.create', Controllers\CreateConversationController::class)
->post('/whisper/messages', 'whisper.messages.create', Controllers\CreateMessageController::class)
->post('/whisper/messages/typing', 'whisper.message.typing', Controllers\TypingPusherController::class)
->post('/whisper/messages/read', 'whisper.message.read', Controllers\ReadMessageController::class)
->delete('/whisper/messages{id}', 'whisper.messages.delete', Controllers\DeleteMessageController::class)
//->patch('/messages/{id}', 'messages.update', Controllers\UpdateMessageController::class)
//->delete('/messages/{id}', 'messages.delete', Controllers\DeleteMessageController::class)
->get('/whisper/conversations/{id}', 'whisper.conversations.show', Controllers\ShowConversationController::class),

(new Extend\ApiSerializer(ForumSerializer::class))
->attribute('canMessage', function (ForumSerializer $serializer) {
return $serializer->getActor()->can('startConversation');
}),

(new Extend\ApiSerializer(CurrentUserSerializer::class))
->attribute('unreadMessages', function (CurrentUserSerializer $serializer) {
return $serializer->getActor()->unread_messages;
}),

(new Extend\Settings())
->serializeToForum('whisperReturnKey', 'kyrne-whisper.return_key', function ($value) {
return (bool) $value;
}),
(new Extend\ApiSerializer(CurrentUserSerializer::class))
->hasMany('conversations', ConversationRecipientSerializer::class),

(new Extend\ApiController(Controller\ListUsersController::class))
->addInclude('conversations'),
(new Extend\ApiController(Controller\ShowUserController::class))
->addInclude('conversations'),
(new Extend\ApiController(Controller\CreateUserController::class))
->addInclude('conversations'),
(new Extend\ApiController(Controller\UpdateUserController::class))
->addInclude('conversations'),
];
1 change: 1 addition & 0 deletions js/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/admin';
2 changes: 2 additions & 0 deletions js/dist/admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions js/dist/admin.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions js/dist/forum.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/dist/forum.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/forum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/forum';
18 changes: 18 additions & 0 deletions js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"private": true,
"name": "@kyrne/whisper",
"dependencies": {
"dompurify": "^2.0.11",
"flarum-webpack-config": "^0.1.0-beta.10",
"webpack": "^4.26.0",
"webpack-cli": "^3.1.2"
},
"scripts": {
"dev": "webpack --mode development --watch",
"build": "webpack --mode production",
"lint": "prettier --single-quote --trailing-comma es5 --print-width 150 --tab-width 4 --write 'src/**/*'"
},
"devDependencies": {
"prettier": "^1.18.2"
}
}
17 changes: 17 additions & 0 deletions js/src/admin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import app from 'flarum/app';

app.initializers.add('kyrne-whisper', () => {

app.extensionData
.for('kyrne-whisper')
.registerSetting({
setting: 'kyrne-whisper.return_key',
type: 'bool',
label: app.translator.trans('kyrne-whisper.admin.settings.return_key')
})
.registerPermission({
icon: 'fas fa-user-lock',
label: app.translator.trans('kyrne-whisper.admin.permissions.start_label'),
permission: 'startConversation',
}, 'start')
});
12 changes: 12 additions & 0 deletions js/src/forum/addConversationsDropdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { extend } from 'flarum/extend';
import app from 'flarum/app';
import HeaderSecondary from 'flarum/components/HeaderSecondary';
import ConversationsDropdown from './components/ConversationsDropdown';

export default function() {
extend(HeaderSecondary.prototype, 'items', function(items) {
if ((app.forum.attribute('canMessage') || (app.session.user && app.session.user.conversations().length))) {
items.add('Messages', <ConversationsDropdown/>, 20);
}
});
}
Loading

0 comments on commit 8bc84aa

Please sign in to comment.