Skip to content
This repository has been archived by the owner on Sep 18, 2019. It is now read-only.

File attachments for Chat client and oc-handle #143

Merged
merged 19 commits into from
Oct 14, 2014
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
js/main.min.js merge=ours
js/vendor/* merge=ours
4 changes: 3 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ module.exports = function(grunt) {
'js/vendor/applycontactavatar.js' : ['js/src/vendor/applycontactavatar.js'],
'js/vendor/cache.js' : [ 'js/src/vendor/cache.js' ],
'js/vendor/time.js' : [ 'js/src/vendor/time.js' ],
'js/vendor/rangyinputs.js' : [ 'js/src/bower_components/rangyinputs-jquery-src/index.js']
'js/vendor/rangyinputs.js' : [ 'js/src/bower_components/rangyinputs-jquery-src/index.js'],
'js/vendor/moment.js' : [ 'js/src/bower_components/moment/moment.js'],

}
}
}
Expand Down
43 changes: 42 additions & 1 deletion app/chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OCA\Chat\OCH\Db\PushMessageMapper;
use OCA\Chat\OCH\Db\UserMapper;
use OCA\Chat\OCH\Db\UserOnlineMapper;
use OCA\Chat\OCH\Db\AttachmentMapper;
use OCA\Chat\Db\BackendMapper;
use OCA\Chat\OCH\Commands\Greet;
use OCA\Chat\OCH\Commands\Invite;
Expand All @@ -24,6 +25,8 @@
use OCA\Chat\OCH\Commands\SendChatMsg;
use OCA\Chat\OCH\Commands\StartConv;
use OCA\Chat\OCH\Commands\SyncOnline;
use OCA\Chat\OCH\Commands\AttachFile;
use OCA\Chat\OCH\Commands\RemoveFile;
use OCA\Chat\OCH\Data\GetUsers;
use OCA\Chat\OCH\Data\Messages;
use OCA\Chat\OCH\Push\Get;
Expand Down Expand Up @@ -111,6 +114,14 @@ public function __construct(array $urlParams = array()) {
return new BackendMapper($c->query('ServerContainer')->getDb());
});

$container->registerService('AttachmentMapper', function ($c) use ($app) {
return new AttachmentMapper(
$c->query('ServerContainer')->getDb(),
$app
);
});


/**
* Command API Requests
*/
Expand Down Expand Up @@ -146,6 +157,15 @@ public function __construct(array $urlParams = array()) {
return new SyncOnline($app);
});

$container->registerService('AttachFileCommand', function ($c) use($app) {
return new AttachFile($app);
});

$container->registerService('RemoveFileCommand', function ($c) use($app) {
return new RemoveFile($app);
});


/**
* Push API Requests
*/
Expand Down Expand Up @@ -417,11 +437,15 @@ public function getInitConvs(){
));
$messages = $getMessages->execute();
$messages = $messages['messages'];

$attachmentMapper = $this->c['AttachmentMapper'];
$files = $attachmentMapper->findRawByConv($conv->getConversationId());
$r['och'][$conv->getConversationId()] = array(
"id" => $conv->getConversationId(),
"users"=> $users,
"backend" => "och",
"messages" => $messages
"messages" => $messages,
"files" => $files
);
if(count($users) === 2){
foreach($users as $user){
Expand Down Expand Up @@ -468,4 +492,21 @@ public function getInitConvs(){
return $r;
}

/**
* @param $path path to file
* @return int id of the file
*/
public function getFileId($path){
$userFolder = $this->c->getServer()->getUserFolder(\OCP\User::getUser());
$file = $userFolder->get($path);
return $file->getId();
}

/**
* @return string current ownCloud user id
*/
public function getUserId(){
return $this->c['UserSession']->getUser()->getUID();
}

}
41 changes: 41 additions & 0 deletions appinfo/database.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,45 @@
</field>
</declaration>
</table>
<table>
<name>*dbprefix*chat_attachments</name>
<declaration>
<field>
<name>id</name>
<type>integer</type>
<notnull>true</notnull>
<autoincrement>1</autoincrement>
<length>4</length>
</field>
<field>
<name>owner</name>
<type>text</type>
<notnull>true</notnull>
<length>255</length>
</field>
<field>
<name>path</name>
<type>text</type>
<notnull>true</notnull>
<length>25555</length>
</field>
<field>
<name>file_id</name>
<type>integer</type>
<notnull>true</notnull>
<length>255</length>
</field>
<field>
<name>timestamp</name>
<type>bigint</type>
<notnull>true</notnull>
</field>
<field>
<name>conv_id</name>
<type>text</type>
<notnull>true</notnull>
<length>25555</length>
</field>
</declaration>
</table>
</database>
2 changes: 1 addition & 1 deletion appinfo/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.1.0
0.2.1.5
3 changes: 2 additions & 1 deletion controller/och/apicontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ApiController extends Controller {
const USER_TO_INVITE_NOT_OC_USER = 12;
const NO_CHAT_MSG = 13;
const NO_USER = 14;
const NOT_OWNER_OF_FILE =15;

public function __construct($appName, IRequest $request, Chat $app){
parent::__construct($appName, $request);
Expand All @@ -60,7 +61,7 @@ public function route($type, $data){
try{
switch($requestType){
case "command":
$possibleCommands = array('greet', 'join', 'invite', 'send_chat_msg', 'online', 'offline', 'start_conv', 'delete_init_conv');
$possibleCommands = array('greet', 'join', 'invite', 'send_chat_msg', 'online', 'offline', 'start_conv', 'delete_init_conv', 'attach_file', 'remove_file');
if(in_array($action, $possibleCommands)){
$commandClass = $this->c[$this->convertClassName($action) . 'Command'];
$commandClass->setRequestData($data);
Expand Down
82 changes: 82 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@
top: 5px;
}

.chat-msg-file-button {
position:absolute;
width:32px;
height:32px;
right: 110px;
top: 5px;
}

#chat-msg-form {
width: 100%;
position: relative;
Expand Down Expand Up @@ -370,6 +378,13 @@
position:static !important;
}

.avatar-list-expanded-button{
padding:0px !important;
margin:0px;
height:20px;
position:static !important;
}

.avatar-list-expanded-item div {
margin-right:10px;
}
Expand Down Expand Up @@ -487,6 +502,22 @@
width:190px !important;
}

#files-container{
width:500px;
position:absolute;
height:auto;
bottom:0;
top:0;
left:250px;
right:0;
margin:30px;
border:1px solid #1D2D44;
border-radius: 3px;
z-index:100;
background-color:#EEEEEE;
padding:10px;
}

.online-dot {
position: absolute;
padding:0;
Expand All @@ -506,3 +537,54 @@
width: 40px;
float:left;
}

.file-owner{
width:50px;
}

.file-time{
width:50px;
text-align:center;
}

.file-path {
width:250px;
}
.file-path p {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
width:250px;
}

.file-row{
height:50px;
}
.file-preview {
padding-right:10px;
padding-left:10px;
padding-top:5px;
}

.file-unshare {
width:20px;
}

#files-container table {
vertical-align: middle;
}

#files-container table th {
font-weight: bold;
}

.files-title {
font-weight: bold;
text-align: center;
color: #1D2D44;
font-size: 18px;
}

#translations{
display:none;
}
Loading