[UBER-783, UBERF-61] Messsage thread notification fixes (#3640)

Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com>
This commit is contained in:
Oleg Solodkov
2023-08-30 12:52:07 +07:00
committed by GitHub
parent 93fd82a797
commit af73876255
12 changed files with 121 additions and 35 deletions
+26 -3
View File
@@ -13,7 +13,15 @@
// limitations under the License.
//
import chunter, { Backlink, chunterId, ChunterSpace, Comment, Message, ThreadMessage } from '@hcengineering/chunter'
import chunter, {
Backlink,
chunterId,
ChunterSpace,
Comment,
DirectMessage,
Message,
ThreadMessage
} from '@hcengineering/chunter'
import contact, { Employee, PersonAccount } from '@hcengineering/contact'
import core, {
Account,
@@ -455,8 +463,8 @@ export async function IsDirectMessage (
type: NotificationType,
control: TriggerControl
): Promise<boolean> {
const space = (await control.findAll(chunter.class.DirectMessage, { _id: doc.space }))[0]
return space !== undefined
const dm = (await control.findAll(chunter.class.DirectMessage, { _id: doc._id as Ref<DirectMessage> }))[0]
return dm !== undefined
}
function isBacklink (ptx: TxCollectionCUD<Doc, Backlink>, hierarchy: Hierarchy): boolean {
@@ -508,6 +516,20 @@ export async function IsChannelMessage (
return space !== undefined
}
/**
* @public
*/
export async function IsThreadMessage (
tx: Tx,
doc: Doc,
user: Ref<Account>,
type: NotificationType,
control: TriggerControl
): Promise<boolean> {
const space = (await control.findAll(chunter.class.DirectMessage, { _id: doc.space }))[0]
return space !== undefined
}
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export default async () => ({
trigger: {
@@ -520,6 +542,7 @@ export default async () => ({
ChannelHTMLPresenter: channelHTMLPresenter,
ChannelTextPresenter: channelTextPresenter,
IsDirectMessage,
IsThreadMessage,
IsMeMentioned,
IsChannelMessage
}
+1
View File
@@ -49,6 +49,7 @@ export default plugin(serverChunterId, {
ChannelTextPresenter: '' as Resource<Presenter>,
IsDirectMessage: '' as TypeMatchFunc,
IsChannelMessage: '' as TypeMatchFunc,
IsThreadMessage: '' as TypeMatchFunc,
IsMeMentioned: '' as TypeMatchFunc
}
})