-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POC #4
base: master
Are you sure you want to change the base?
POC #4
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,4 @@ | ||
--- | ||
name: codecov | ||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
jobs: | ||
codecov: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: 17 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
maven- | ||
- run: mvn clean install | ||
- uses: codecov/codecov-action@v3 | ||
with: | ||
files: ./target/site/jacoco/jacoco.xml | ||
fail_ci_if_error: true | ||
# @todo #1 Add codecov GHA | ||
# Add codecov GHA after implementation of POC |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,5 @@ | ||
# elegant | ||
This is a pre-configured template for your projects in Java, you can use it with any language, [more about it](https://h1alexbel.github.io/2023/01/21/maintainable-project-template.html) | ||
<img src="blamer-notifications.svg" width="150" alt="blamer-bot"/> | ||
|
||
## Tools: | ||
- [Rultor](https://www.rultor.com/) for CI/CD. | ||
- [0pdd](https://www.0pdd.com/) for issue management. | ||
- [Renovate](https://www.mend.io/free-developer-tools/renovate/) for dependency control. | ||
- [xcop](https://www.yegor256.com/2017/08/29/xcop.html) GitHub action for XML style check. | ||
[![codecov](https://codecov.io/gh/Blamer-io/hub/branch/master/graph/badge.svg?token=5HCTK3KRGL)](https://codecov.io/gh/Blamer-io/notifications) | ||
|
||
## How to use? | ||
- Configure actions in `workflows` folder. | ||
- [Configure](https://doc.rultor.com/reference.html) the `@rultor`. | ||
- [Configure](https://www.yegor256.com/2017/04/05/pdd-in-action.html) the `0pdd`. | ||
- [Configure](https://github.com/marketplace/renovate) the `renovate`. | ||
|
||
And you're good to go! | ||
Blamer Notifications is a service that transfers GitHub notifications into text notifications for Telegram |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
MIT License | ||
|
||
Copyright (c) 2023 Blamer.io | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
--> | ||
<!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.0//EN" | ||
"https://checkstyle.org/dtds/suppressions_1_0.dtd"> | ||
<suppressions> | ||
<suppress checks="LineLength" files=".*\.java$" lines="0-23"/> | ||
<suppress checks="HiddenField" files=".*\.java$" lines="23-9999"/> | ||
<suppress checks="DesignForExtension" files=".*\.java$" lines="0-9999"/> | ||
<suppress checks="HideUtilityClassConstructor" files="NotificationsAppEntry.java" lines="0-9999"/> | ||
<suppress checks="FinalClass" files=".*\.java$" lines="0-9999"/> | ||
</suppressions> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
MIT License | ||
|
||
Copyright (c) 2023 Blamer.io | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
--> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>3.0.6</version> | ||
<relativePath/> | ||
<!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>io.blamer</groupId> | ||
<artifactId>notifications</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>notifications</name> | ||
<description>Demo project for Spring Boot</description> | ||
<properties> | ||
<java.version>17</java.version> | ||
<maven-checkstyle-plugin.version>3.2.2</maven-checkstyle-plugin.version> | ||
<checkstyle.version>8.15</checkstyle.version> | ||
<jtcop-maven-plugin.version>0.1.9</jtcop-maven-plugin.version> | ||
<jcabi-github.version>1.5.0</jcabi-github.version> | ||
<netty-resolver-dns-native-macos.version>4.1.91.Final</netty-resolver-dns-native-macos.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-webflux</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.jcabi</groupId> | ||
<artifactId>jcabi-github</artifactId> | ||
<version>${jcabi-github.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.netty</groupId> | ||
<artifactId>netty-resolver-dns-native-macos</artifactId> | ||
<version>${netty-resolver-dns-native-macos.version}</version> | ||
<classifier>osx-aarch_64</classifier> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @l3r8yJ why do we need this dependency? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @h1alexbel netty doesn't work without it on m1 cpu |
||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-devtools</artifactId> | ||
<scope>runtime</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-configuration-processor</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.projectreactor</groupId> | ||
<artifactId>reactor-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<configuration> | ||
<excludes> | ||
<exclude> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
</exclude> | ||
</excludes> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-checkstyle-plugin</artifactId> | ||
<version>${maven-checkstyle-plugin.version}</version> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.puppycrawl.tools</groupId> | ||
<artifactId>checkstyle</artifactId> | ||
<version>${checkstyle.version}</version> | ||
</dependency> | ||
</dependencies> | ||
<executions> | ||
<execution> | ||
<id>verify-style</id> | ||
<phase>process-classes</phase> | ||
<goals> | ||
<goal>check</goal> | ||
</goals> | ||
<configuration> | ||
<suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression> | ||
<suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.github.volodya-lombrozo</groupId> | ||
<artifactId>jtcop-maven-plugin</artifactId> | ||
<version>${jtcop-maven-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>check</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2023 Blamer.io | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.blamer.notifications; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
/** | ||
* Entry class. | ||
* | ||
* @since 0.0.0 | ||
*/ | ||
@SpringBootApplication | ||
public class NotificationsAppEntry { | ||
|
||
/** | ||
* Entry point. | ||
* | ||
* @param args application arguments | ||
*/ | ||
public static void main(final String[] args) { | ||
SpringApplication.run(NotificationsAppEntry.class, args); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2023 Blamer.io | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.blamer.notifications.controller; | ||
|
||
import io.blamer.notifications.message.UpdateMessage; | ||
import io.blamer.notifications.user.TelegramUser; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.*; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @l3r8yJ remove wildcard import |
||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequestMapping("/api/v1/notifications") | ||
@RequiredArgsConstructor | ||
public class NotificationsController { | ||
|
||
private final WebClient webClient; | ||
|
||
@ResponseStatus(HttpStatus.ACCEPTED) | ||
@PostMapping | ||
public Mono<Void> receiveUser(@RequestBody final Mono<TelegramUser> user) { | ||
return user | ||
.doOnNext(usr -> log.info("Received {}", usr)) | ||
.map( | ||
usr -> | ||
this.webClient.post() | ||
.uri("/api/v1/bot/updates") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @l3r8yJ I think we can transfer messages to the hub initially then from hub, we grooming the notifications and resend them to the bot WDYT? |
||
.contentType(MediaType.APPLICATION_JSON) | ||
.bodyValue( | ||
Flux.generate( | ||
synchronousSink -> synchronousSink.next( | ||
new UpdateMessage("Update!", usr.getChat()) | ||
) | ||
) | ||
) | ||
.retrieve() | ||
.bodyToFlux(Void.class) | ||
.then() | ||
).then(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@l3r8yJ remove the comments please