Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into new/…
Browse files Browse the repository at this point in the history
…default-favorite-channels

* 'develop' of github.com:RocketChat/Rocket.Chat: (28 commits)
  [IMPROVE] Notify logged agents when their departments change (#16033)
  [IMPROVE] Replace fullEmojiData publication by REST (#15901)
  [IMPROVE] Replace adminRooms publication by REST (#15948)
  [IMPROVE] Replace webdavAccounts publication by REST (#15926)
  [IMPROVE] Replace oauth publications by REST (#15878)
  [IMPROVE] Replace userAutocomplete publication by REST (#15956)
  [IMPROVE] Replace discussionsOfARoom publication by REST (#15908)
  [FIX] width of upload-progress-text (#16023)
  corrected Grammatical errors (#15570)
  Upgrade limax to 2.0.0 (#16020)
  [IMPROVE] Replace customSounds publication by REST (#15907)
  [FIX] Message list scrolling to bottom on reactions (#16018)
  [IMPROVE] Replace stdout publication by REST (#16004)
  [FIX] SAML logout error (#15978)
  [FIX] Added Join button to Read Only rooms. (#16016)
  [IMPROVE] Replace fullUserStatusData publication by REST (#15942)
  [IMPROVE] Replace userData subscriptions by REST (#15916)
  [FIX] z-index of new message button (#16013)
  [FIX] new message popup (#16017)
  [FIX] Changed renderMessage priority, fixed Katex on/off setting (#16012)
  ...
  • Loading branch information
gabriellsh committed Dec 20, 2019
2 parents a036fc0 + 50c69e2 commit 033357b
Show file tree
Hide file tree
Showing 191 changed files with 4,287 additions and 1,751 deletions.
2 changes: 1 addition & 1 deletion .meteor/packages
Expand Up @@ -58,7 +58,6 @@ jparker:gravatar
kadira:blaze-layout
kadira:flow-router
keepnox:perfect-scrollbar
mizzao:autocomplete
mizzao:timesync
mrt:reactive-store
mystor:device-detection
Expand Down Expand Up @@ -97,3 +96,4 @@ webapp@1.7.5
webapp-hashing@1.0.9
rocketchat:oauth2-server
rocketchat:i18n
dandv:caret-position
3 changes: 1 addition & 2 deletions .meteor/versions
Expand Up @@ -86,7 +86,6 @@ meteorspark:util@0.2.0
minifier-css@1.4.3
minifier-js@2.5.1
minimongo@1.4.5
mizzao:autocomplete@0.5.1
mizzao:timesync@0.3.4
mobile-experience@1.0.5
mobile-status-bar@1.0.14
Expand Down Expand Up @@ -128,7 +127,7 @@ rocketchat:livechat@0.0.1
rocketchat:mongo-config@0.0.1
rocketchat:oauth2-server@2.1.0
rocketchat:push@3.3.1
rocketchat:streamer@1.0.2
rocketchat:streamer@1.1.0
rocketchat:tap-i18n@1.9.1
rocketchat:version@1.0.0
routepolicy@1.1.0
Expand Down
2 changes: 1 addition & 1 deletion .stylelintignore
@@ -1,4 +1,4 @@
app/theme/client/vendor/fontello/css/fontello.css
packages/meteor-autocomplete/client/autocomplete.css
app/meteor-autocomplete/client/autocomplete.css
app/katex/katex.min.css
app/emoji-emojione/client/*.css
16 changes: 8 additions & 8 deletions README.md
Expand Up @@ -83,7 +83,7 @@ Join thousands of members worldwide 24/7 in our [community server](https://open.

[![Rocket.Chat](https://open.rocket.chat/api/v1/shield.svg?type=channel&name=Rocket.Chat&channel=dev)](https://open.rocket.chat/channel/dev) for developers needing help from the community to developing new features.

You can also join the conversation at [Twitter](https://twitter.com/RocketChat) and [Facebook](https://www.facebook.com/RocketChatApp).
You can also join the conversation on [Twitter](https://twitter.com/RocketChat) and [Facebook](https://www.facebook.com/RocketChatApp).

# Desktop Apps
Download the Native Cross-Platform Desktop Application at [Rocket.Chat.Electron](https://github.com/RocketChat/Rocket.Chat.Electron/releases)
Expand Down Expand Up @@ -138,7 +138,7 @@ The easiest way to install a ready-to-run Rocket.Chat server on a Linux machine,
[![DP deploy](https://raw.githubusercontent.com/DFabric/DPlatform-ShellCore/images/logo.png)](https://dfabric.github.io/DPlatform-ShellCore)

## IndieHosters
Get your Rocket.Chat instance hosted in a "as a Service" style. You register and we manage it for you! (updates, backup...).
Get your Rocket.Chat instance hosted in an "as a Service" style. You register and we manage it for you! (updates, backup...).

[![Rocket.Chat on IndieHosters](https://indie.host/signup.png)](https://indiehosters.net/shop/product/rocket-chat-21)

Expand Down Expand Up @@ -236,7 +236,7 @@ Run Rocket.Chat on your easy to use personal device.

# About Rocket.Chat

Rocket.Chat is a Web Chat Server, developed in JavaScript, using the [Meteor](https://www.meteor.com/install) fullstack framework.
Rocket.Chat is a Web Chat Server, developed in JavaScript, using the [Meteor](https://www.meteor.com/install) full stack framework.

It is a great solution for communities and companies wanting to privately host their own chat service or for developers looking forward to build and evolve their own chat platforms.

Expand Down Expand Up @@ -321,7 +321,7 @@ It is a great solution for communities and companies wanting to privately host t

## Roadmap

To see an up to date view of what we have planned view our [milestones](https://github.com/RocketChat/Rocket.Chat/milestones).
To see an up to date view of what we have planned, view our [milestones](https://github.com/RocketChat/Rocket.Chat/milestones).


## How it all started
Expand Down Expand Up @@ -352,7 +352,7 @@ Please use the [Stack Overflow TAG](http://stackoverflow.com/questions/tagged/ro
#### Hubot

The docker image is ready.
Everyone can start hacking the adapter code, or launch his/her own bot within a few minutes now.
Everyone can start hacking the adapter code or launch his/her own bot within a few minutes now.
Please head over to the [Hubot Integration Project](https://github.com/RocketChat/hubot-rocketchat) for more information.


Expand Down Expand Up @@ -393,7 +393,7 @@ meteor npm install
meteor npm start
```

In order to debug the server part use [meteor debugging](https://docs.meteor.com/commandline.html#meteordebug). You should use Chrome for best debugging experience:
To debug the server part, use [meteor debugging](https://docs.meteor.com/commandline.html#meteordebug). You should use Chrome for best debugging experience:

```sh
meteor debug
Expand All @@ -416,7 +416,7 @@ If you want to help, send an email to support at rocket.chat to be invited to th

## How to Contribute

Already a JavaScript developer? Familiar with Meteor? [Pick an issue](https://github.com/RocketChat/Rocket.Chat/labels/contrib%3A%20easy), push a PR and instantly become a member of Rocket.Chat's international contributors community. For more information, check out our [Contributing Guide](.github/CONTRIBUTING.md) and our [Official Documentation for Contributors](https://rocket.chat/docs/contributing/).
Already a JavaScript developer? Familiar with Meteor? [Pick an issue](https://github.com/RocketChat/Rocket.Chat/labels/contrib%3A%20easy), push a PR and instantly become a member of Rocket.Chat's international contributors' community. For more information, check out our [Contributing Guide](.github/CONTRIBUTING.md) and our [Official Documentation for Contributors](https://rocket.chat/docs/contributing/).

A lot of work has already gone into Rocket.Chat, but we have much bigger plans for it!

Expand All @@ -434,7 +434,7 @@ Thanks to our core team
[Marcelo Schmidt](https://github.com/marceloschmidt),
[Rodrigo Nascimento](https://github.com/rodrigok),
[Sing Li](https://github.com/Sing-Li),
and to hundreds of awesome [contributors](https://github.com/RocketChat/Rocket.Chat/graphs/contributors).
and hundreds of awesome [contributors](https://github.com/RocketChat/Rocket.Chat/graphs/contributors).

![JoyPixels](https://i.imgur.com/OrhYvLe.png)

Expand Down
25 changes: 24 additions & 1 deletion app/api/server/api.js
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { DDPCommon } from 'meteor/ddp-common';
import { DDP } from 'meteor/ddp';
import { Accounts } from 'meteor/accounts-base';
Expand Down Expand Up @@ -312,6 +313,13 @@ export class APIClass extends Restivus {
route: `${ this.request.route }${ this.request.method.toLowerCase() }`,
};
let result;

const connection = {
id: Random.id(),
close() {},
token: this.token,
};

try {
api.enforceRateLimit(objectForRateLimitMatch, this.request, this.response);

Expand All @@ -321,7 +329,18 @@ export class APIClass extends Restivus {
});
}

result = originalAction.apply(this);
const invocation = new DDPCommon.MethodInvocation({
connection,
isSimulation: false,
userId: this.userId,
});

Accounts._accountData[connection.id] = {
connection,
};
Accounts._setAccountData(connection.id, 'loginToken', this.token);

result = DDP._CurrentInvocation.withValue(invocation, () => originalAction.apply(this));
} catch (e) {
logger.debug(`${ method } ${ route } threw an error:`, e.stack);

Expand All @@ -331,6 +350,8 @@ export class APIClass extends Restivus {
}[e.error] || 'failure';

result = API.v1[apiMethod](e.message, e.error);
} finally {
delete Accounts._accountData[connection.id];
}

result = result || API.v1.success();
Expand Down Expand Up @@ -545,6 +566,8 @@ const getUserAuth = function _getUserAuth(...args) {
token = Accounts._hashLoginToken(this.request.headers['x-auth-token']);
}

this.token = token;

return {
userId: this.request.headers['x-user-id'],
token,
Expand Down
4 changes: 4 additions & 0 deletions app/api/server/index.js
Expand Up @@ -32,5 +32,9 @@ import './v1/subscriptions';
import './v1/users';
import './v1/video-conference';
import './v1/autotranslate';
import './v1/webdav';
import './v1/oauthapps';
import './v1/custom-sounds';
import './v1/custom-user-status';

export { API, APIClass, defaultRateLimiterOptions } from './api';
20 changes: 20 additions & 0 deletions app/api/server/lib/custom-sounds.js
@@ -0,0 +1,20 @@
import { CustomSounds } from '../../../models/server/raw';

export async function findCustomSounds({ query = {}, pagination: { offset, count, sort } }) {
const cursor = await CustomSounds.find(query, {
sort: sort || { name: 1 },
skip: offset,
limit: count,
});

const total = await cursor.count();

const sounds = await cursor.toArray();

return {
sounds,
count: sounds.length,
offset,
total,
};
}
20 changes: 20 additions & 0 deletions app/api/server/lib/custom-user-status.js
@@ -0,0 +1,20 @@
import { CustomUserStatus } from '../../../models/server/raw';

export async function findCustomUserStatus({ query = {}, pagination: { offset, count, sort } }) {
const cursor = await CustomUserStatus.find(query, {
sort: sort || { name: 1 },
skip: offset,
limit: count,
});

const total = await cursor.count();

const statuses = await cursor.toArray();

return {
statuses,
count: statuses.length,
offset,
total,
};
}
20 changes: 20 additions & 0 deletions app/api/server/lib/emoji-custom.js
@@ -0,0 +1,20 @@
import { EmojiCustom } from '../../../models/server/raw';

export async function findEmojisCustom({ query = {}, pagination: { offset, count, sort } }) {
const cursor = EmojiCustom.find(query, {
sort: sort || { name: 1 },
skip: offset,
limit: count,
});

const total = await cursor.count();

const emojis = await cursor.toArray();

return {
emojis,
count: emojis.length,
offset,
total,
};
}
25 changes: 25 additions & 0 deletions app/api/server/lib/messages.js
Expand Up @@ -115,3 +115,28 @@ export async function findSnippetedMessages({ uid, roomId, pagination: { offset,
total,
};
}

export async function findDiscussionsFromRoom({ uid, roomId, pagination: { offset, count, sort } }) {
const room = await Rooms.findOneById(roomId);

if (!await canAccessRoomAsync(room, { _id: uid })) {
throw new Error('error-not-allowed');
}

const cursor = Messages.findDiscussionsByRoom(roomId, {
sort: sort || { ts: -1 },
skip: offset,
limit: count,
});

const total = await cursor.count();

const messages = await cursor.toArray();

return {
messages,
count: messages.length,
offset,
total,
};
}
13 changes: 13 additions & 0 deletions app/api/server/lib/oauthApps.js
@@ -0,0 +1,13 @@
import { OAuthApps } from '../../../models/server/raw';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';

export async function findOAuthApps({ uid }) {
if (!await hasPermissionAsync(uid, 'manage-oauth-apps')) {
throw new Error('error-not-allowed');
}
return OAuthApps.find().toArray();
}

export async function findOneAuthApp({ clientId, appId }) {
return OAuthApps.findOneAuthAppByIdOrClientId({ clientId, appId });
}
77 changes: 77 additions & 0 deletions app/api/server/lib/rooms.js
@@ -0,0 +1,77 @@
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { Rooms } from '../../../models/server/raw';

export async function findAdminRooms({ uid, filter, types = [], pagination: { offset, count, sort } }) {
if (!await hasPermissionAsync(uid, 'view-room-administration')) {
throw new Error('error-not-authorized');
}
const fields = {
prid: 1,
fname: 1,
name: 1,
t: 1,
cl: 1,
u: 1,
usernames: 1,
usersCount: 1,
muted: 1,
unmuted: 1,
ro: 1,
default: 1,
topic: 1,
msgs: 1,
archived: 1,
tokenpass: 1,
};

const name = filter && filter.trim();
const discussion = types && types.includes('discussions');
const showTypes = Array.isArray(types) ? types.filter((type) => type !== 'discussions') : [];
const options = {
fields,
sort: sort || { default: -1, name: 1 },
skip: offset,
limit: count,
};

let cursor = Rooms.findByNameContaining(name, discussion, options);

if (name && showTypes.length) {
cursor = Rooms.findByNameContainingAndTypes(name, showTypes, discussion, options);
} else if (showTypes.length) {
cursor = Rooms.findByTypes(showTypes, discussion, options);
}

const total = await cursor.count();

const rooms = await cursor.toArray();

return {
rooms,
count: rooms.length,
offset,
total,
};
}

export async function findChannelAndPrivateAutocomplete({ uid, selector }) {
if (!await hasPermissionAsync(uid, 'view-other-user-channels')) {
return { items: [] };
}
const options = {
fields: {
_id: 1,
name: 1,
},
limit: 10,
sort: {
name: 1,
},
};

const rooms = await Rooms.findChannelAndPrivateByNameStarting(selector.name, options).toArray();

return {
items: rooms,
};
}
27 changes: 27 additions & 0 deletions app/api/server/lib/users.js
@@ -0,0 +1,27 @@
import { Users } from '../../../models/server/raw';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';

export async function findUsersToAutocomplete({ uid, selector }) {
if (!await hasPermissionAsync(uid, 'view-outside-room')) {
return { items: [] };
}
const exceptions = selector.exceptions || [];
const conditions = selector.conditions || {};
const options = {
fields: {
name: 1,
username: 1,
status: 1,
},
sort: {
username: 1,
},
limit: 10,
};

const users = await Users.findActiveByUsernameOrNameRegexWithExceptionsAndConditions(selector.term, exceptions, conditions, options).toArray();

return {
items: users,
};
}

0 comments on commit 033357b

Please sign in to comment.