private void onDiscussionParserEvent(UserEvents.DiscussionEvent e, DateTime eventTimestamp, DiscussionUpdateType type) { switch (type) { case DiscussionUpdateType.InitialSnapshot: // Don't send out any notifications on initial snapshot, e.g. when just connected to host // because we don't want to notify about all old events return; case DiscussionUpdateType.NewMergeRequest: // Notify about whatever is found in a new merge request DiscussionEvent?.Invoke(e); return; case DiscussionUpdateType.PeriodicUpdate: // Notify about new events in merge requests that are cached already if (_cachedDiscussions.TryGetValue(e.MergeRequestKey, out CachedDiscussions cached) && cached.PrevTimeStamp.HasValue && eventTimestamp > cached.PrevTimeStamp.Value) { DiscussionEvent?.Invoke(e); } return; } Debug.Assert(false); }
private void onDiscussionsLoaded(MergeRequestKey mrk, IEnumerable <Discussion> discussions, DiscussionUpdateType type) { if (discussions.Count() == 0) { return; } foreach (Discussion discussion in discussions) { foreach (DiscussionNote note in discussion.Notes) { if (note.System && note.Body == "resolved all threads") { DiscussionEvent?.Invoke(new UserEvents.DiscussionEvent( mrk, UserEvents.DiscussionEvent.Type.ResolvedAllThreads, note.Author), note.Updated_At, type); } else if (note.System && note.Body == "approved this merge request") { DiscussionEvent?.Invoke(new UserEvents.DiscussionEvent( mrk, UserEvents.DiscussionEvent.Type.ApprovalStatusChange, new UserEvents.DiscussionEvent.ApprovalStatusChangeDescription(true, note.Author)), note.Updated_At, type); } else if (note.System && note.Body == "unapproved this merge request") { DiscussionEvent?.Invoke(new UserEvents.DiscussionEvent( mrk, UserEvents.DiscussionEvent.Type.ApprovalStatusChange, new UserEvents.DiscussionEvent.ApprovalStatusChangeDescription(false, note.Author)), note.Updated_At, type); } else if (Helpers.IsUserMentioned(note.Body, _currentUser)) { DiscussionEvent?.Invoke(new UserEvents.DiscussionEvent( mrk, UserEvents.DiscussionEvent.Type.MentionedCurrentUser, note.Author), note.Updated_At, type); } else if (_keywords != null) { foreach (string keyword in _keywords) { if (note.Body.Trim().StartsWith(keyword, StringComparison.CurrentCultureIgnoreCase)) { DiscussionEvent?.Invoke(new UserEvents.DiscussionEvent( mrk, UserEvents.DiscussionEvent.Type.Keyword, new UserEvents.DiscussionEvent.KeywordDescription(keyword, note.Author)), note.Updated_At, type); } } } } } }