We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
recipient.Key#CopyNonNil()
1 parent e89bbdc commit bd94e4bCopy full SHA for bd94e4b
internal/recipient/recipient.go
@@ -33,6 +33,24 @@ func (r Key) MarshalText() (text []byte, err error) {
33
}
34
35
36
+// CopyNonNil copies non-nil fields from the provided recipient.Key to the current one and
37
+// returns the modified recipient key.
38
+func (r Key) CopyNonNil(recipientKey Key) Key {
39
+ if !r.ContactID.Valid && recipientKey.ContactID.Valid {
40
+ r.ContactID = recipientKey.ContactID
41
+ }
42
+
43
+ if !r.GroupID.Valid && recipientKey.GroupID.Valid {
44
+ r.GroupID = recipientKey.GroupID
45
46
47
+ if !r.ScheduleID.Valid && recipientKey.ScheduleID.Valid {
48
+ r.ScheduleID = recipientKey.ScheduleID
49
50
51
+ return r
52
+}
53
54
func ToKey(r Recipient) Key {
55
switch v := r.(type) {
56
case *Contact:
0 commit comments