Projects onedev server Issues #972
#972  IRC Notification
Open
Jerome St-Louis opened 5 months ago

There are notifications for Slack and Discord, but these are just centralized / proprietary copycats of the original Internet Relay Chat.

Could we please get support for IRC Notification? :) libera.chat is a popular network for open-source software development projects.

Perhaps the functionality can otherwise be added as a webhook with something like https://github.com/ammen99/github-irc-webhook ?

Robin Shen commented 5 months ago

Will investigate when I have time. Also any contribution is welcomed, 😃 Adding a new notification is pretty simple if it allows to send notification via a webhook like Slack/Discord.

polarian commented 3 months ago

@robin I might be able to do this for you I have experience with the irc protocol see: https://git.polarian.dev/Polarian/ircj

I would need permission to use my own IRC wrapper as a dependency however, and I doubt you want another dependency added to OneDev :/

Robin Shen commented 3 months ago

@polarian this is great! Just refer to current Slack/Discord implementation when you are working on IRC plugin.

polarian commented 3 months ago

by the way @robin IRC does not support webhook, the only way to do it is having a persistent socket connection to the IRC server they want the notification on which could get... messy and inefficient.

In the long run it might be better have something like this:

OneDev --> IRC notification daemon --> IRC server

OneDev and IRC notification daemon would work over HTTP webhook, and the notification daemon would (preferably) be written in a lower level language thus to be faster and more efficient to negate the lack of webhook support for IRC.

Of course this would be a very ambitious approach to doing it, but it would be a scalable and efficient method of doing it, allowing the notiifcation daemon to be isolated stops the main OneDev instance from eating too many resources, as for IRC notifications, for each server a new socket connection will need to be established and (preferably) maintained, best to keep this separate.

Be happy to know your opinion though :)

Robin Shen commented 3 months ago

Instead of writing daemon in a different language, please implement it via a background thread in Java in same process as OneDev server. This makes OneDev maintenance (both deploying and developing) a lot easier and is one major benefit of OneDev actually. Performance is normally not a problem for self-hosted instance, and OneDev is not aiming to provide service to millions of people like GitHub/GitLab.

On how to start background thread when OneDev starts, and tear it down when OneDev stops, please check DefaultMailManager, which polls mail box periodically in a background thread to create issues/comments via email.

polarian commented 3 months ago

@robin sure, it is your codebase. I just do not recommend this, if people use many IRC servers for notifications, each server needs to maintain a connection.

There is one solution is for the bot to not keep a connection and only connect to IRC to send the notification and then leave. But this could mean constantly connecting and disconnecting which could be highly inefficient.

I do not know which one would be worse. I believe the latter approach would be the best, as IRC sends "PING" commands keeping a connection would drain bandwidth.

Robin Shen commented 3 months ago

I am not familiar with IRC,but in a self-hosted environment, I guess there might not be many IRC servers.

polarian commented 3 months ago
I will need to work on my IRC library a little, it has been ages since I have used it, and I abandoned it for a period of time because I abandoned my IRC related projects.

I believe I need to backport it to be Java 11 compliant, because I believe that is the java version OneDev is built with. I also need to fix the repository and also provide dependency repository for it again, since I disposed of my maven repository about 6 months ago because I stopped programming in java.

In short, especially due to my lack of time, this feature might take a while to implement. If any other developers want to take over or support to speed up the feature, either mention me here or email me at polarian@polarian.dev.

I do plan to implement this though, I think it will be quite fun to do.


polarian commented 3 months ago

Hm, seems email responses have issues parsing plaintext, and understanding my new paragraphs, meh works well enough

Robin Shen commented 3 months ago

No hurry at all. Just take your time.

polarian commented 2 months ago

Looking at the documentation, there is two types of plugins and I am unsure which one would suit this well...

Should this be included as a builtin plugin or an external plugin?

Robin Shen commented 2 months ago

Builtin plugin means to ship together with OneDev main program, and external plugin means to ship separately. Since you are contributing this to OneDev main program, you may create it as a builtin plugin.

polarian commented 2 months ago

Thanks :)

polarian commented 2 months ago

@jerstlouis Could you please list the features you would like included in this plugin?

Jerome St-Louis commented 2 months ago

@polarian Thank you very much for asking. I can think of the following basic capabilities of the top of my head:

  • Notification of new commits pushed
  • Notification of builds of a particular branch newly succeeding / failing
  • Notification of new issues filed
  • The ability to specify to which server(s) / channel(s) these notifications should happen

I imagine the capabilities should be very similar to the existing Slack & Discord plugins ?

polarian commented 2 months ago

The issue is that IRC is not one centralised instance like slack or discord, which means different channels could be contained on different servers, which could cause complications.

polarian commented 2 months ago

Do you want notifications to a specific IRC channel, or do you want it to also go to specific users directly?

Jerome St-Louis commented 2 months ago

@polarian personally I think IRC channel notifications would be the common use case. But for maximum flexibility make every potential users happy, ideally the plugin should allow listing servers, and for each server which channels / users to notify, and for each of these which notifications to send.

polarian commented 2 months ago

That makes this a lot more complex.

The issue is I understand the IRC protocol (or used to) very well, but I have not contributed or read any of the onedev codebase, which means it might be difficult for someone unfamiliar with the codebase to implement this feature in the most user friendly way.

I am sure Robin will help me out if I need it, but I will still give it a go at the least :)

Robin Shen commented 2 months ago

@polarian please check the slack plugin, it allows one to specify which notification should be sent to which channel. Any question, feel free to contact me.

polarian commented 2 months ago

Thanks Robin :)

Jerome St-Louis commented 2 months ago

@polarian The ability to specify one (or more, if possible) server/channel combination per project for which notifications should be sent out would be a great start, if a more flexible approach adds too much complexity. A OneDev plugin bot could either remain idle in each server/channel it needs, or could join / notify / leave otherwise (that could potentially be an option as well).

Robin Shen commented 2 months ago

@polarian slack notification tutorial in case you need to play with it: https://docs.onedev.io/tutorials/notification/slack-notification/

polarian commented 2 months ago

Thanks for the help, I have mirrored onedev to my git instance because for whatever reason onedev server has poor performance on my network, probably bad BGP routing to the host server, but I don't know. I will copy it over to code.onedev.io for a PR when I am finished :)

polarian commented 2 months ago

I would run onedev as my git instance but gitea is what I have setup, no hard feelings 😄

polarian commented 2 months ago

I have realised after reviewing the codebase of ircj (my irc wrapper I wrote a while back, as most java irc wrappers are pretty bad or do not serve my needs), and there is a lot of issues with the codebase.

I will have to postpone working on this plugin until I get the ircj codebase up to scratch, I do not want to merge sh*t code into OneDev.

I do have limited time though so @jerstlouis just because I want to implement this (mainly cause I would like to use it too :P) does not mean that it will ever be implemented, so please don't get your hopes up too much unfortunately, as I can not make any guarantees.

Robin Shen commented 2 months ago

@polarian no problem. take your time

Jerome St-Louis commented 2 months ago

no worries @polarian , I greatly appreciate that you would like to help with this :) It would be nice to have this IRC notifications functionality, but we have managed fine without it for a long time :)

polarian commented 2 months ago

@jerstlouis I could write up a quick bot using the OneDev REST API to check for new versions, which could provide this functionality while I work on integrating it into OneDev?

polarian commented 2 months ago

However this still requires for me to get ircj up to scratch before I can even start working on OneDev integrations.

OneDev referenced from other issue 2 months ago
OneDev referenced from other issue 1 month ago
OneDev referenced from other issue 1 month ago
OneDev referenced from other issue 2 weeks ago
Prabir Shrestha commented 2 weeks ago

Probably worth supporting https://github.com/caronc/apprise syntax so it can work for lot of notifications service though it seems to be lacking IRC support.

polarian commented 2 weeks ago

I would like to be the one to implement this feature, but I have not had time.

Implementing IRC manually would be more robust in the first place, and would be neater than a monolithic library to implement notifications for a bunch of platforms which nobody has requested support for, and thus, this might not be the best idea!


issue 1 of 1
Type
New Feature
Priority
Normal
Assignee
Issue Votes (1)
Watchers (6)
Reference
issue onedev/server#972
Please wait...
Page is in error, reload to recover