github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/pkg/email/action.go (about) 1 // Copyright 2023 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 package email 5 6 import "github.com/google/syzkaller/dashboard/dashapi" 7 8 type OldThreadInfo struct { 9 ThreadType dashapi.DiscussionType 10 } 11 12 type MessageAction string 13 14 const ( 15 ActionIgnore MessageAction = "ignore" 16 ActionAppend MessageAction = "append" 17 ActionNewThread MessageAction = "new-thread" 18 ) 19 20 func NewMessageAction(msg *Email, msgType dashapi.DiscussionType, oldThread *OldThreadInfo) MessageAction { 21 if msg.InReplyTo == "" { 22 // If it's not a reply, always start a new thread. 23 return ActionNewThread 24 } 25 if oldThread != nil { 26 // Sometimes patches are sent as replies to the bug report. 27 // In this case, we'd better report it as a new discussion. 28 if msgType == dashapi.DiscussionPatch && 29 msgType != oldThread.ThreadType { 30 return ActionNewThread 31 } 32 // Otherwise just append the message. 33 return ActionAppend 34 } 35 if msg.OwnEmail { 36 // Most likely it's a bot's public reply to a non-public 37 // patch testing request. Ignore it. 38 return ActionIgnore 39 } 40 // If the original discussion is not recorded anywhere, it means 41 // we were likely only mentioned in some further discussion. 42 // Remember then only the sub-thread visible to us. 43 return ActionNewThread 44 }