#972  IRC Notification
Closed
Jerome St-Louis opened 1 year 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 1 year 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.

Unknown commented 1 year 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 1 year ago

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

Unknown commented 1 year 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 1 year 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.

Unknown commented 1 year 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 1 year ago

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

Unknown commented 1 year 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.


Unknown commented 1 year ago

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

Robin Shen commented 1 year ago

No hurry at all. Just take your time.

Unknown commented 1 year 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 1 year 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.

Unknown commented 1 year ago

Thanks :)

Unknown commented 1 year ago

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

Jerome St-Louis commented 1 year 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 ?

Unknown commented 1 year 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.

Unknown commented 1 year 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 1 year 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.

Unknown commented 1 year 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 1 year 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.

Unknown commented 1 year ago

Thanks Robin :)

Jerome St-Louis commented 1 year 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 1 year ago

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

Unknown commented 1 year 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 :)

Unknown commented 1 year ago

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

Unknown commented 1 year 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 1 year ago

@polarian no problem. take your time

Jerome St-Louis commented 1 year 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 :)

Unknown commented 1 year 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?

Unknown commented 1 year 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 1 year ago
OneDev referenced from other issue 1 year ago
OneDev referenced from other issue 1 year ago
OneDev referenced from other issue 1 year ago
Prabir Shrestha commented 1 year 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.

Unknown commented 1 year 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!


Jerome St-Louis referenced from other issue 1 year ago
Unknown commented 1 year ago

Just a heads up, today I have patched IRCJ, I will be giving this implementation a shot over the following days. Please do not expect much from me, Onedev has a huge codebase and its my first contribution, so I am walking in the dark here.

The only advantage I have is the fact I have experience with the IRC protocol, so lets hope that is enough 😃

If you want to see the commits I am making in the following days, watch the commits to this branch:

https://onedev.polarian.dev/onedev/onedev-server/~commits?query=branch%28irc-support%29

PR into this repository will be created upon the feature being finished/working.

Jerome St-Louis commented 1 year ago

Thanks for working on this @polarian .

As mentioned in #1289 it would be nice to get notifications of failed/fixed builds on IRC as well.

In case it could be of any use for you as a reference, I wrote this very basic / unfinished IRC client a long time ago:

https://github.com/ecere/ecere-sdk/blob/latest/samples/net/eirc/eIRC.ec

Unknown commented 1 year ago

For me, IRC is not the issue, it is whether or not I can understand the onedev source code.

Robin has already given me links to other modules (discord and slack) which I can take a look at to see how he has implemented notifications.

Unknown commented 1 year ago

@robin Hey I would ask if you got javadocs, but I am pretty sure the answer is no due to issue #1046 I submitted a WHILE ago.

Meh I will figure it out on my own, just will take longer than typing a Class into the javadocs and reading about all its methods and attributes and what they do.

Robin Shen commented 1 year ago

No javadoc sorry. Unfortunately you will have to look into source to understand things. Let me know if you have questions (please be specific, I may not have time to give you things like a detailed architectural design...)

Robin Shen changed state to 'Closed' 4 months ago
Previous Value Current Value
Open
Closed
Robin Shen commented 4 months ago

This is closed as there is no resource for this.

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