fixed messaage reply not regexing properlly if contenttype == hmll
This commit is contained in:
parent
505fbc8a7e
commit
400b2bde87
3 changed files with 42 additions and 16 deletions
|
|
@ -33,7 +33,7 @@ const
|
||||||
anchor: "newest",
|
anchor: "newest",
|
||||||
num_before: 100,
|
num_before: 100,
|
||||||
num_after: 0,
|
num_after: 0,
|
||||||
apply_markdown: false,
|
// apply_markdown: false,
|
||||||
narrow: [
|
narrow: [
|
||||||
{ operator: "stream", operand: stream },
|
{ operator: "stream", operand: stream },
|
||||||
{ operator: "topic", operand: topic },
|
{ operator: "topic", operand: topic },
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,4 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
header {
|
|
||||||
box-sizing: border-box;
|
|
||||||
margin: 1em;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -35,6 +35,41 @@ let validateRule = (rule) => {
|
||||||
return rule.match(/.+:.+;/gm);
|
return rule.match(/.+:.+;/gm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parsing replies, there are two scenarios:
|
||||||
|
// we are either getting the message as plain markdown
|
||||||
|
// or we are getting the message pre-rendered as HTML (default Zulip behaviour)
|
||||||
|
// see /src/api/zulip/index.js line 36
|
||||||
|
|
||||||
|
const handleMDReply = message => {
|
||||||
|
message.responseTo = {
|
||||||
|
id: message.content
|
||||||
|
.replace(/.*\/near\//gm, '')
|
||||||
|
.replace(/\):.*[^]+/gm, ''),
|
||||||
|
sender_id: message.content
|
||||||
|
.replace(/@_\*\*.*\|/gm, '')
|
||||||
|
.replace(/\*\*.\[said\].*[^]+/gm, ''),
|
||||||
|
quote: message.content
|
||||||
|
.replace(/[^]+.*```quote\n/gm, '')
|
||||||
|
.replace(/ \n```/gm, '')
|
||||||
|
}
|
||||||
|
// console.log(message.responseTo)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleHTMLReply = message => {
|
||||||
|
message.responseTo = {
|
||||||
|
id: message.content
|
||||||
|
.replace(/.*\/near\//gm, '')
|
||||||
|
.replace(/".*[^]+/gm, ''),
|
||||||
|
sender_id: message.content
|
||||||
|
.replace(/[^]+data-user-id="/gm, '')
|
||||||
|
.replace(/">[^]+/gm, ''),
|
||||||
|
quote: message.content
|
||||||
|
.replace(/.*[^]+<\/p>\n<blockquote>\n<p>/gm, '')
|
||||||
|
.replace(/ <\/p>\n<\/blockquote>/gm, '')
|
||||||
|
}
|
||||||
|
// console.log(message.responseTo)
|
||||||
|
}
|
||||||
|
|
||||||
export default createStore({
|
export default createStore({
|
||||||
|
|
||||||
strict: process.env.NODE_ENV !== 'production',
|
strict: process.env.NODE_ENV !== 'production',
|
||||||
|
|
@ -55,17 +90,12 @@ export default createStore({
|
||||||
|
|
||||||
addMessage: (state, message) => {
|
addMessage: (state, message) => {
|
||||||
if (message.content.startsWith('@_**')) {
|
if (message.content.startsWith('@_**')) {
|
||||||
message.responseTo = {
|
handleMDReply(message)
|
||||||
id: message.content
|
} else if (
|
||||||
.replace(/.*\/near\//gm, '')
|
message.content.includes('user-mention') &&
|
||||||
.replace(/\):.*[^]+/gm, ''),
|
message.content.includes('blockquote')
|
||||||
sender_id: message.content
|
) {
|
||||||
.replace(/@_\*\*.*\|/gm, '')
|
handleHTMLReply(message)
|
||||||
.replace(/\*\*.\[said\].*[^]+/gm, ''),
|
|
||||||
quote: message.content
|
|
||||||
.replace(/[^]+.*```quote\n/gm, '')
|
|
||||||
.replace(/ \n```/gm, '')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
state.contents.push(message)
|
state.contents.push(message)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue