Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
fd02b426
"apps/meteor/ee/git@gitlab.ow2.org:RocketChat/Rocket.Chat.git" did not exist on "3b3275f6863e18e78894fb1920b53063ebd9c6fc"
Commit
fd02b426
authored
9 years ago
by
Diego Sampaio
Browse files
Options
Downloads
Patches
Plain Diff
moving files to expose functions
parent
154764ab
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/fileUpload.coffee
+9
-29
9 additions, 29 deletions
lib/fileUpload.coffee
packages/rocketchat-lib/lib/fileUploadRestrictions.js
+28
-0
28 additions, 0 deletions
packages/rocketchat-lib/lib/fileUploadRestrictions.js
packages/rocketchat-lib/package.js
+1
-0
1 addition, 0 deletions
packages/rocketchat-lib/package.js
with
38 additions
and
29 deletions
lib/fileUpload.coffee
+
9
−
29
View file @
fd02b426
...
...
@@ -9,26 +9,6 @@ if UploadFS?
remove
:
(
userId
,
doc
)
->
return
userId
is
doc
.
userId
fileUploadMediaWhiteList
=
->
return
unless
RocketChat
.
settings
.
get
(
'FileUpload_MediaTypeWhiteList'
)
return
_
.
map
(
RocketChat
.
settings
.
get
(
'FileUpload_MediaTypeWhiteList'
).
split
(
','
),
(
item
)
->
return
item
.
trim
()
)
@
fileUploadIsValidContentType
=
(
type
)
->
list
=
fileUploadMediaWhiteList
()
if
!
list
or
_
.
contains
list
,
type
return
true
else
wildCardGlob
=
'/*'
wildcards
=
_
.
filter
list
,
(
item
)
->
return
item
.
indexOf
(
wildCardGlob
)
>
0
if
_
.
contains
wildcards
,
type
.
replace
(
/(\/.*)$/
,
wildCardGlob
)
return
true
;
return
false
;
initFileStore
=
->
cookie
=
new
Cookies
()
if
Meteor
.
isClient
...
...
@@ -42,7 +22,7 @@ if UploadFS?
collectionName
:
'rocketchat_uploads'
filter
:
new
UploadFS
.
Filter
maxSize
:
RocketChat
.
settings
.
get
(
'FileUpload_MaxFileSize'
)
contentTypes
:
fileUploadMediaWhiteList
()
contentTypes
:
RocketChat
.
fileUploadMediaWhiteList
()
onFinishUpload
:
->
console
.
log
arguments
transformWrite
:
(
readStream
,
writeStream
,
fileId
,
file
)
->
...
...
@@ -83,11 +63,11 @@ if UploadFS?
res
.
setHeader
'content-disposition'
,
"attachment; filename=
\"
#{
encodeURIComponent
(
file
.
name
)
}
\"
"
return
true
Meteor
.
startup
->
if
Meteor
.
isServer
initFileStore
()
else
Tracker
.
autorun
(
c
)
->
if
Meteor
.
userId
()
and
RocketChat
.
settings
.
subscription
.
ready
()
initFileStore
()
c
.
stop
()
Meteor
.
startup
->
if
Meteor
.
isServer
initFileStore
()
else
Tracker
.
autorun
(
c
)
->
if
Meteor
.
userId
()
and
RocketChat
.
settings
.
subscription
.
ready
()
initFileStore
()
c
.
stop
()
This diff is collapsed.
Click to expand it.
packages/rocketchat-lib/lib/fileUploadRestrictions.js
0 → 100644
+
28
−
0
View file @
fd02b426
RocketChat
.
fileUploadMediaWhiteList
=
function
()
{
var
mediaTypeWhiteList
=
RocketChat
.
settings
.
get
(
'
FileUpload_MediaTypeWhiteList
'
);
console
.
log
(
'
mediaTypeWhiteList ->
'
,
mediaTypeWhiteList
);
if
(
!
mediaTypeWhiteList
)
{
return
;
}
return
_
.
map
(
mediaTypeWhiteList
.
split
(
'
,
'
),
function
(
item
)
{
return
item
.
trim
();
});
};
RocketChat
.
fileUploadIsValidContentType
=
function
(
type
)
{
var
list
,
wildCardGlob
,
wildcards
;
list
=
RocketChat
.
fileUploadMediaWhiteList
();
if
(
!
list
||
_
.
contains
(
list
,
type
))
{
return
true
;
}
else
{
wildCardGlob
=
'
/*
'
;
wildcards
=
_
.
filter
(
list
,
function
(
item
)
{
return
item
.
indexOf
(
wildCardGlob
)
>
0
;
});
if
(
_
.
contains
(
wildcards
,
type
.
replace
(
/
(\/
.*
)
$/
,
wildCardGlob
)))
{
return
true
;
}
}
return
false
;
};
This diff is collapsed.
Click to expand it.
packages/rocketchat-lib/package.js
+
1
−
0
View file @
fd02b426
...
...
@@ -38,6 +38,7 @@ Package.onUse(function(api) {
api
.
addFiles
(
'
lib/settings.coffee
'
);
api
.
addFiles
(
'
lib/configLogger.coffee
'
);
api
.
addFiles
(
'
lib/callbacks.coffee
'
);
api
.
addFiles
(
'
lib/fileUploadRestrictions.js
'
);
api
.
addFiles
(
'
lib/slashCommand.coffee
'
);
api
.
addFiles
(
'
lib/Message.coffee
'
);
api
.
addFiles
(
'
lib/MessageTypes.coffee
'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment