-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into monorepo
- Loading branch information
Showing
247 changed files
with
5,894 additions
and
1,443 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,3 +88,4 @@ rocketchat:i18n | |
rocketchat:postcss | ||
dandv:caret-position | ||
[email protected] | ||
url |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
|
||
import { handleError } from '../../../../client/lib/utils/handleError'; | ||
import { IMessage } from '../../../../definition/IMessage'; | ||
|
||
// Action Links namespace creation. | ||
export const actionLinks = { | ||
actions: new Map<string, Function>(), | ||
register(name: string, fn: Function): void { | ||
actionLinks.actions.set(name, fn); | ||
}, | ||
// getMessage(name, messageId) { | ||
// const userId = Meteor.userId(); | ||
// if (!userId) { | ||
// throw new Meteor.Error('error-invalid-user', 'Invalid user', { | ||
// function: 'actionLinks.getMessage', | ||
// }); | ||
// } | ||
|
||
// const message = Messages.findOne({ _id: messageId }); | ||
// if (!message) { | ||
// throw new Meteor.Error('error-invalid-message', 'Invalid message', { | ||
// function: 'actionLinks.getMessage', | ||
// }); | ||
// } | ||
|
||
// const subscription = Subscriptions.findOne({ | ||
// 'rid': message.rid, | ||
// 'u._id': userId, | ||
// }); | ||
// if (!subscription) { | ||
// throw new Meteor.Error('error-not-allowed', 'Not allowed', { | ||
// function: 'actionLinks.getMessage', | ||
// }); | ||
// } | ||
|
||
// if (!message.actionLinks || !message.actionLinks[name]) { | ||
// throw new Meteor.Error('error-invalid-actionlink', 'Invalid action link', { | ||
// function: 'actionLinks.getMessage', | ||
// }); | ||
// } | ||
|
||
// return message; | ||
// }, | ||
run(method: string, message: IMessage, instance: undefined): void { | ||
const actionLink = message.actionLinks && message.actionLinks.find((action) => action.method_id === method); | ||
|
||
if (!actionLink) { | ||
throw new Meteor.Error('error-invalid-actionlink', 'Invalid action link'); | ||
} | ||
|
||
if (!actionLinks.actions.has(actionLink.method_id)) { | ||
throw new Meteor.Error('error-invalid-actionlink', 'Invalid action link'); | ||
} | ||
|
||
const fn = actionLinks.actions.get(actionLink.method_id); | ||
|
||
let ranClient = false; | ||
|
||
if (fn) { | ||
// run just on client side | ||
fn(message, actionLink.params, instance); | ||
|
||
ranClient = true; | ||
} | ||
|
||
// and run on server side | ||
Meteor.call('actionLinkHandler', name, message._id, (err: Error) => { | ||
if (err && !ranClient) { | ||
handleError(err); | ||
} | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { IMessage } from '../../../definition/IMessage'; | ||
import { highlightWords, getRegexHighlight, getRegexHighlightUrl } from './helper'; | ||
|
||
// TODO: delete this file after message rewrites | ||
export const createHighlightWordsMessageRenderer = ({ | ||
wordsToHighlight, | ||
}: { | ||
wordsToHighlight: string[]; | ||
}): (<T extends IMessage & { html: string }>(message: T) => T) => { | ||
const highlights = wordsToHighlight.map((highlight) => ({ | ||
highlight, | ||
regex: getRegexHighlight(highlight), | ||
urlRegex: getRegexHighlightUrl(highlight), | ||
})); | ||
|
||
return <T extends IMessage & { html: string }>(message: T): T => { | ||
if (!message.html?.trim()) { | ||
return message; | ||
} | ||
|
||
message.html = highlightWords(message.html, highlights); | ||
return message; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { createHighlightWordsMessageRenderer } from './client'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.