/// <summary>
        /// The handle.
        /// </summary>
        /// <param name="event">
        /// The event.
        /// </param>
        public void Handle(RepositoryEvent <Attachment> @event)
        {
            if (@event.RepositoryEventType != RepositoryEventType.Delete || this._boardSettings.UseFileTable)
            {
                return;
            }

            if (@event.Entity == null)
            {
                @event.Entity = this._attachmentRepository.ListTyped(attachmentID: @event.EntityId).FirstOrDefault();
            }

            if (@event.Entity == null)
            {
                return;
            }

            try
            {
                @event.Entity.DeleteFile();
            }
            catch (Exception e)
            {
                // error deleting that file...
                this._logger.Warn(e, "Error Deleting Attachment");
            }
        }
Beispiel #2
0
        public void Compare_Repos_July_vs_Today(string owner)
        {
            NotificationBuilder         nbuilder        = new NotificationBuilder();
            NotificationChannelsBuilder channelsBuilder = new NotificationChannelsBuilder().UseSmtpPickupDirectory(@"c:\work").UseSmtpPickupDirectory(@"c:\work2\send");

            List <RepositoryEvent> Events = new List <RepositoryEvent>();
            ITableSnapshotBuilder  builder;

            builder = RepositoryListSnapshotBuilder.CreateInMemorySnapshotFromRequest(Resources.GetRepositoryResponse(owner, RepositoryResponseGeneration.July));
            ITableSnapshot microsoftSnapshotJuly = builder.Build();

            builder = RepositoryListSnapshotBuilder.CreateInMemorySnapshotFromRequest(this.Extractor.GetMetadataAsynch(this.Token, owner).Result);
            ITableSnapshot microsoftSnapshotToday = builder.Build();

            TableDiffByLookup differ = new TableDiffByLookup(microsoftSnapshotJuly, microsoftSnapshotToday);


            differ.DifferencesDelegate = (deletedRecord, inserted) =>
            {
                EventType   et       = EventType.Created;
                IDataRecord template = inserted;
                if ((deletedRecord != null) && (inserted != null))
                {
                    et       = EventType.Modified;
                    template = inserted;
                }

                if ((deletedRecord != null) && (inserted == null))
                {
                    et       = EventType.Deleted;
                    template = deletedRecord;
                    //RepositoryTableSnapshot.CreatedAtFieldName
                }

                RepositoryEvent ev = EventFactory.CreateRepositoryEvent(template, et);
                nbuilder.AddEvent(ev);
            };
            differ.Execute();
            //Assert.Equal(1312, differ.OldSnapshotRecordCount);

            //create Notification
            //Deliver Notification

            nbuilder.AddChannels(channelsBuilder);

            List <Notification> toSend = new List <Notification>();

            for (int i = 0; i < 5; i++)
            {
                Notification noti = nbuilder.Build();
                noti.From = new NotificationAddress()
                {
                    Identifier = "*****@*****.**"
                };
                noti.To = new NotificationAddress[] { noti.From };
                toSend.Add(noti);
            }

            Postman.DeliverNotification(toSend);
        }
Beispiel #3
0
        /// <summary>
        /// The handle.
        /// </summary>
        /// <param name="event">
        /// The event.
        /// </param>
        public void Handle(RepositoryEvent <UserGroup> @event)
        {
            if ([email protected](RepositoryEventType.New))
            {
                return;
            }

            this.ClearAccess();
        }
Beispiel #4
0
        /// <summary>
        /// The handle.
        /// </summary>
        /// <param name="event">
        /// The event.
        /// </param>
        public void Handle(RepositoryEvent <Rank> @event)
        {
            // Clearing cache with old permissions data...
            this.DataCache.RemoveOf <object>(
                k => k.Key.StartsWith(string.Format(Constants.Cache.ActiveUserLazyData, string.Empty)));

            // Clear Styling Caching
            this.DataCache.Remove(Constants.Cache.GroupRankStyles);
        }
Beispiel #5
0
        /// <summary>
        /// The handle.
        /// </summary>
        /// <param name="event">
        /// The event.
        /// </param>
        public void Handle(RepositoryEvent <Group> @event)
        {
            // remove caching in case something got updated...
            this.ClearModeratorsCache();

            // Clearing cache with old permissions data...
            this.DataCache.Remove(
                k => k.StartsWith(string.Format(Constants.Cache.ActiveUserLazyData, string.Empty)));
        }
Beispiel #6
0
        /// <summary>
        /// The handle.
        /// </summary>
        /// <param name="event">
        /// The event.
        /// </param>
        public void Handle(RepositoryEvent <User> @event)
        {
            if ([email protected](RepositoryEventType.Delete))
            {
                return;
            }

            // clear the cache
            this.DataCache.Clear();
        }
Beispiel #7
0
        /// <summary>
        /// The handle.
        /// </summary>
        /// <param name="event">
        /// The event.
        /// </param>
        public void Handle(RepositoryEvent <Forum> @event)
        {
            /*if ([email protected](RepositoryEventType.Delete, RepositoryEventType.Update))
             * {
             *  return;
             * }*/

            // clear active discussions cache..
            this.DataCache.Remove(Constants.Cache.ActiveDiscussions);

            this.ClearModeratorsCache();
        }
        /// <summary>
        /// The handle.
        /// </summary>
        /// <param name="event">
        /// The event.
        /// </param>
        public void Handle(RepositoryEvent <Category> @event)
        {
            if ([email protected](RepositoryEventType.Delete, RepositoryEventType.Update))
            {
                return;
            }

            // clear moderatorss cache
            this._dataCache.Remove(Constants.Cache.ForumModerators);

            // clear category cache...
            this._dataCache.Remove(Constants.Cache.ForumCategory);

            // clear active discussions cache..
            this._dataCache.Remove(Constants.Cache.ForumActiveDiscussions);
        }
Beispiel #9
0
 static ReponseClassSpec()
 {
     //Discarded unreachable code: IL_0002, IL_0006, IL_0012, IL_0019
     //IL_0003: Incompatible stack heights: 0 vs 1
     //IL_0007: Incompatible stack heights: 0 vs 1
     //IL_0013: Incompatible stack heights: 0 vs 1
     //IL_001a: Incompatible stack heights: 0 vs 1
     SingletonReader.PushGlobal();
     _PrinterEvent = new string[6]
     {
         "B",
         "KB",
         "MB",
         "GB",
         "TB",
         "PB"
     };
     m_MockEvent = new RepositoryEvent();
 }
Beispiel #10
0
        private static MattermostMessage GetMessageRepository(RepositoryEvent payload)
        {
            var retVal = BaseMessageForRepo(payload.repository.full_name);

            var repoMd = $"[{payload.repository.name}]({payload.repository.html_url})";
            var userMd = $"[{payload.sender.login}]({payload.sender.html_url})";
            var orgMd  = $"[{payload.organization.login}]({payload.organization.url})";

            switch (payload.action)
            {
            case "created":
                retVal.Text = $"{userMd} created new repository {repoMd} in {orgMd}";
                break;

            default:
                throw new NotImplementedException($"Unhandled Event action: {payload.action}");
            }

            return(retVal);
        }
 /// <summary>
 /// The handle.
 /// </summary>
 /// <param name="event">
 /// The event.
 /// </param>
 public void Handle(RepositoryEvent <ShoutboxMessage> @event)
 {
     this._dataCache.Remove(Constants.Cache.Shoutbox);
 }
Beispiel #12
0
        private object ConvertPayload()
        {
            switch (Event)
            {
            case PingEvent.EventString:
                return(PingEvent.FromJson(PayloadText));

            case CommitCommentEvent.EventString:
                return(CommitCommentEvent.FromJson(PayloadText));

            case CreateEvent.EventString:
                return(CreateEvent.FromJson(PayloadText));

            case DeleteEvent.EventString:
                return(DeleteEvent.FromJson(PayloadText));

            case DeploymentEvent.EventString:
                return(DeploymentEvent.FromJson(PayloadText));

            case DeploymentStatusEvent.EventString:
                return(DeploymentStatusEvent.FromJson(PayloadText));

            case ForkEvent.EventString:
                return(ForkEvent.FromJson(PayloadText));

            case GollumEvent.EventString:
                return(GollumEvent.FromJson(PayloadText));

            case InstallationEvent.EventString:
                return(InstallationEvent.FromJson(PayloadText));

            case InstallationRepositoriesEvent.EventString:
                return(InstallationRepositoriesEvent.FromJson(PayloadText));

            case IssueCommentEvent.EventString:
                return(IssueCommentEvent.FromJson(PayloadText));

            case IssuesEvent.EventString:
                return(IssuesEvent.FromJson(PayloadText));

            case LabelEvent.EventString:
                return(LabelEvent.FromJson(PayloadText));

            case MemberEvent.EventString:
                return(MemberEvent.FromJson(PayloadText));

            case MembershipEvent.EventString:
                return(MembershipEvent.FromJson(PayloadText));

            case MilestoneEvent.EventString:
                return(MilestoneEvent.FromJson(PayloadText));

            case OrganizationEvent.EventString:
                return(OrganizationEvent.FromJson(PayloadText));

            case OrgBlockEvent.EventString:
                return(OrgBlockEvent.FromJson(PayloadText));

            case PageBuildEvent.EventString:
                return(PageBuildEvent.FromJson(PayloadText));

            case ProjectCardEvent.EventString:
                return(ProjectCardEvent.FromJson(PayloadText));

            case ProjectColumnEvent.EventString:
                return(ProjectColumnEvent.FromJson(PayloadText));

            case ProjectEvent.EventString:
                return(ProjectEvent.FromJson(PayloadText));

            case PublicEvent.EventString:
                return(PublicEvent.FromJson(PayloadText));

            case PullRequestEvent.EventString:
                return(PullRequestEvent.FromJson(PayloadText));

            case PullRequestReviewEvent.EventString:
                return(PullRequestReviewEvent.FromJson(PayloadText));

            case PullRequestReviewCommentEvent.EventString:
                return(PullRequestReviewCommentEvent.FromJson(PayloadText));

            case PushEvent.EventString:
                return(PushEvent.FromJson(PayloadText));

            case ReleaseEvent.EventString:
                return(ReleaseEvent.FromJson(PayloadText));

            case RepositoryEvent.EventString:
                return(RepositoryEvent.FromJson(PayloadText));

            case StatusEvent.EventString:
                return(StatusEvent.FromJson(PayloadText));

            case WatchEvent.EventString:
                return(WatchEvent.FromJson(PayloadText));

            default:
                throw new NotImplementedException(
                          $"Event Type: `{Event}` is not implemented. Want it added? Open an issue at https://github.com/promofaux/GithubWebhooks");
            }
        }
Beispiel #13
0
        /// <summary>
        /// The handle.
        /// </summary>
        /// <param name="event">
        /// The event.
        /// </param>
        public void Handle(RepositoryEvent <UserForum> @event)
        {
            this.ClearModeratorsCache();

            this.DataCache.Remove(Constants.Cache.BoardModerators);
        }
Beispiel #14
0
 /// <summary>
 /// The handle.
 /// </summary>
 /// <param name="event">
 /// The event.
 /// </param>
 public void Handle(RepositoryEvent <Topic> @event)
 {
     this.Get <IDataCache>().Remove(Constants.Cache.BoardStats);
     this.Get <IDataCache>().Remove(Constants.Cache.BoardUserStats);
 }
Beispiel #15
0
 /// <summary>
 /// The handle.
 /// </summary>
 /// <param name="event">
 /// The event.
 /// </param>
 public void Handle(RepositoryEvent <BBCode> @event)
 {
     this.DataCache.Remove(Constants.Cache.CustomBBCode);
     this.Get <IObjectStore>().RemoveOf <IProcessReplaceRules>();
 }
Beispiel #16
0
 public List <Event> AlleEvents()
 {
     repoEvent = new RepositoryEvent(new MSSQLEvent());
     return(repoEvent.AlleEvents());
 }
Beispiel #17
0
 /// <summary>
 /// The handle.
 /// </summary>
 /// <param name="event">
 /// The event.
 /// </param>
 public void Handle(RepositoryEvent <Spam_Words> @event)
 {
     this.DataCache.Remove(Constants.Cache.SpamWords);
 }
Beispiel #18
0
 /// <summary>
 /// The handle.
 /// </summary>
 /// <param name="event">
 /// The event.
 /// </param>
 public void Handle(RepositoryEvent <AccessMask> @event)
 {
     this.ClearModeratorsCache();
 }
Beispiel #19
0
 /// <summary>
 /// The handle.
 /// </summary>
 /// <param name="event">
 /// The event.
 /// </param>
 public void Handle(RepositoryEvent <BannedIP> @event)
 {
     this.DataCache.Remove(Constants.Cache.BannedIP);
 }
Beispiel #20
0
 /// <summary>
 /// The handle.
 /// </summary>
 /// <param name="event">
 /// The event.
 /// </param>
 public void Handle(RepositoryEvent <Replace_Words> @event)
 {
     this.DataCache.Remove(Constants.Cache.ReplaceWords);
 }
Beispiel #21
0
 public void EventAanmaken(Event events)
 {
     repoEvent = new RepositoryEvent(new MSSQLEvent());
     repoEvent.EventAanmaken(events);
 }
Beispiel #22
0
 public EventController()
 {
     TrainingContext = new TrainingContext();
     RepoEvent       = new RepositoryEvent(TrainingContext);
 }
Beispiel #23
0
 public void EventVerwijderen(int eventID)
 {
     repoEvent = new RepositoryEvent(new MSSQLEvent());
     repoEvent.EventVerwijderen(eventID);
 }
Beispiel #24
0
 /// <summary>
 /// The handle.
 /// </summary>
 /// <param name="event">
 /// The event.
 /// </param>
 public void Handle(RepositoryEvent <Message> @event)
 {
     this.Get <IDataCache>().Remove(Constants.Cache.BoardStats);
     this.Get <IDataCache>().Remove(Constants.Cache.BoardUserStats);
     this.Get <IDataCache>().Remove(Constants.Cache.MostActiveUsers);
 }
 /// <summary>
 /// The handle.
 /// </summary>
 /// <param name="event">
 /// The event.
 /// </param>
 public void Handle(RepositoryEvent <Smiley> @event)
 {
     this._dataCache.Remove(Constants.Cache.Smilies);
     this._objectStore.RemoveOf <IProcessReplaceRules>();
 }