Skip to content
Snippets Groups Projects

feat: Add support for "project_destroy" and "project_rename" hooks

1 unresolved thread

Resolves #80 (closed)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
30 30 public class WebhooksResource {
31 31
32 32 private static final Logger LOGGER = LoggerFactory.getLogger(WebhooksResource.class);
33
33
34 public static final String CREATE_EVENT = "project_create";
  • Instead of static strings, we should use an enum with a method to cast a name to the enum. A lot of our logic gets way cleaner that way. An example of this is from the membership portal, in the image formats:

        public enum ImageStoreFormats {
            SMALL, LARGE, PRINT, WEB, WEB_SRC;
    
            public String getName() {
                return this.name().toLowerCase();
            }
    
            public static ImageStoreFormat getFormat(String name) {
                if (name == null) {
                    return null;
                }
                return Stream.of(values()).filter(v -> name.equalsIgnoreCase(v.getName())).findFirst().orElse(null);
            }
        }

    With this sort of thing, if you replace the null return with an UNSUPPORTED enum, you could then do something like this:

    SupportedEventType t = getSupportedEventType(theString);
    switch(t) {
      case PROJECT_CREATE:
        doTheThing();
        break;
      ...
      case UNSUPPORTED:
        LOGGER.trace("Dropped event {}", theString);
        break;
    }
  • Zachary Sabourin changed this line in version 4 of the diff

    changed this line in version 4 of the diff

  • Please register or sign in to reply
  • Zachary Sabourin marked this merge request as draft

    marked this merge request as draft

  • Zachary Sabourin added 2 commits

    added 2 commits

    • 1780baf6 - feat: Add EventType enum
    • d381f15a - feat: Restructure validation to use event enum

    Compare with previous version

  • added 1 commit

    • bb923132 - fix: fix session closing issue

    Compare with previous version

  • added 1 commit

    • 4af3433f - feat: Update spec to include new field

    Compare with previous version

  • added 1 commit

    • 6aaa939e - feat: Add testing for delete and renam hooks

    Compare with previous version

  • Zachary Sabourin marked this merge request as ready

    marked this merge request as ready

  • @malowe ready for review :)

  • merged

  • Martin Lowe mentioned in commit e421d3ac

    mentioned in commit e421d3ac

  • Please register or sign in to reply
    Loading