notifico icon indicating copy to clipboard operation
notifico copied to clipboard

Gitea support

Open belliash opened this issue 6 years ago • 8 comments

Please add support for Gitea. I have tried to setup Notifico with my Gitea installation, but all deliveries ends up with error 500. Here are headers:

Connection: keep-alive
Content-Length: 3390
Content-Type: text/html; charset=utf-8
Date: Sun, 22 Jul 2018 12:27:13 GMT
Server: nginx/1.10.3 (Ubuntu)
X-Sentry-Id: 13544b2f9e824afea919610dd1ce1bfc

I can provide as many information as necessary. Just let me know.

belliash avatar Jul 22 '18 12:07 belliash

A payload example for reproduction would be helpful :)

Croydon avatar Jul 23 '18 00:07 Croydon

Here is the obfuscated version:

{
  "secret": "",
  "ref": "refs/heads/fix_file_dir",
  "before": "[HASH1]",
  "after": "[HASH2]",
  "compare_url": "[URL]",
  "commits": [
    {
      "id": "[HASH]",
      "message": "Some message goes here",
      "url": "[URL]",
      "author": {
        "name": "[NAME]",
        "email": "[E_MAIL]",
        "username": "[LOGIN]"
      },
      "committer": {
        "name": "[NAME]",
        "email": "[E_MAIL]",
        "username": "[LOGIN]"
      },
      "verification": null,
      "timestamp": "2018-07-23T07:07:27+02:00"
    }
  ],
  "repository": {
    "id": 21,
    "owner": {
      "id": 13,
      "login": "PSharp",
      "full_name": "P# Interpreter",
      "email": "",
      "avatar_url": "[URL]",
      "username": "PSharp"
    },
    "name": "psharp",
    "full_name": "PSharp/psharp",
    "description": "P# Interpreter Source",
    "empty": false,
    "private": false,
    "fork": false,
    "parent": null,
    "mirror": false,
    "size": 9711,
    "html_url": "https://git.codingworkshop.eu.org/PSharp/psharp",
    "ssh_url": "[URL]",
    "clone_url": "https://git.codingworkshop.eu.org/PSharp/psharp.git",
    "website": "",
    "stars_count": 2,
    "forks_count": 0,
    "watchers_count": 3,
    "open_issues_count": 7,
    "default_branch": "master",
    "created_at": "2018-07-12T13:53:02+02:00",
    "updated_at": "2018-07-23T07:07:42+02:00",
    "permissions": {
      "admin": false,
      "push": false,
      "pull": false
    }
  },
  "pusher": {
    "id": 21,
    "login": "[LOGIN]",
    "full_name": "",
    "email": "[LOGIN]@noreply.codingworkshop.git",
    "avatar_url": "[URL]",
    "username": "[LOGIN]"
  },
  "sender": {
    "id": 21,
    "login": "[LOGIN]",
    "full_name": "",
    "email": "[LOGIN]@noreply.codingworkshop.git",
    "avatar_url": "[URL]",
    "username": "[LOGIN]"
  }
}

If you need original, please let me know how can I provide it to you.

belliash avatar Jul 23 '18 05:07 belliash

I forgotten about headers:

Request URL: http://n.tkte.ch/h/****** Request method: POST Content-Type: application/json X-GitHub-Delivery: 45b3a580-854a-4fbf-8990-5fe242aa0232 X-GitHub-Event: push X-Gitea-Delivery: 45b3a580-854a-4fbf-8990-5fe242aa0232 X-Gitea-Event: push X-Gogs-Delivery: 45b3a580-854a-4fbf-8990-5fe242aa0232 X-Gogs-Event: push

belliash avatar Jul 23 '18 05:07 belliash

Actually looks like only push event is causing error 500. Information about creating new branch is sent successfully to IRC channel.

belliash avatar Jul 23 '18 05:07 belliash

Any chance to get this fixed soon? I believe the Gitea's payload should be compatible with GitHub and even there is some difference, it should not result in internal server error...

belliash avatar Jul 25 '18 14:07 belliash

Bump!

belliash avatar Aug 22 '18 04:08 belliash

I initially did the github implementation and don't really have the time to look into this, from what I gather Tk is also currently very busy with other stuff. The best option for you, if you want this feature soon™, is to look into it yourself.

The README shows you how to start the bots and website, then post the request to a configured webhook and check the exception you get. Either paste it here and we can help or try to fix it yourself, I'll happily review your code.

Your main entry point is here (also probably the source of the exception): https://github.com/notifico/notifico/blob/master/notifico/services/hooks/github.py

If you need any hints, I'm happy to help, you can also come by the IRC channel on freenode (#notifico).

Dav1dde avatar Aug 22 '18 16:08 Dav1dde

With a working gitea + notifico setup (see issue #205), I was able to check what is wrong with the github hook. Gitea's webhooks payload is seems to be based on the Github webhooks paylod, but with a few changes (for instance, the 'compare' value is renamed 'compare_url'...)

With a simple patch, I was able to fix the 'push' notification.

Now, @TkTech, do you prefer a modified version of hooks/github.py compatible with gitea, or a whole 'new' hooks/gitea.py ?

sdegrande avatar Jul 27 '22 21:07 sdegrande