Skip to content

Commit

Permalink
Merge branch 'main' into step
Browse files Browse the repository at this point in the history
  • Loading branch information
gungunj authored May 10, 2024
2 parents 32d73f6 + b133865 commit c016c93
Show file tree
Hide file tree
Showing 267 changed files with 67,784 additions and 126 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Setup Nodejs
uses: actions/setup-node@v3
with:
cache: "npm"
cache: 'npm'
node-version: 16

- name: Install Dep
Expand All @@ -97,8 +97,8 @@ jobs:
if: ${{fromJson(env.DIFF_STATE).needJAVA}}
uses: actions/setup-java@v4
with:
java-version: "8"
distribution: "temurin"
java-version: '8'
distribution: 'temurin'

- name: Install JDK Dependency
if: ${{fromJson(env.DIFF_STATE).needJAVA}}
Expand Down Expand Up @@ -127,8 +127,11 @@ jobs:
PULL_REQUEST_ID: ${{ github.event.pull_request.number }}
HEAD_BRANCH_NAME: ${{github.head_ref}}
HEAD_REPOSITORY: ${{github.event.pull_request.head.repo.full_name}}
BASE_REPOSITORY: ${{github.event.pull_request.base.repo.full_name}}
GITHUB_REPOSITORY: ${{github.repository}}
ACTION_ID: ${{github.run_id}}
PR_EVENT_ACTION: ${{github.event.action}}
NOTIFY_CONFIG_JSON: ${{secrets.NOTIFY_CONFIG_JSON}}

- name: Upload PR Result Error
if: ${{fromJson(env.CHECK_RESULT).hasError}}
Expand Down Expand Up @@ -160,6 +163,7 @@ jobs:
PULL_REQUEST_ID: ${{ github.event.pull_request.number }}
HEAD_BRANCH_NAME: ${{github.head_ref}}
HEAD_REPOSITORY: ${{github.event.pull_request.head.repo.full_name}}
BASE_REPOSITORY: ${{github.event.pull_request.base.repo.full_name}}
GITHUB_REPOSITORY: ${{github.repository}}
ACTION_ID: ${{github.run_id}}

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,6 @@ jobs:
HEAD_BRANCH_NAME: ${{github.head_ref}}
GITHUB_REPOSITORY: ${{github.repository}}
ACTION_ID: ${{github.run_id}}
AMC_URL: ${{secrets.AMC_URL}}
AMC_BODY: ${{secrets.AMC_BODY}}
AMU_URL: ${{secrets.AMU_URL}}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ node_modules/

**/dist-theme/
**/*.zip
*.zip
jar/

**/target/

Expand Down
4 changes: 4 additions & 0 deletions EmailFetcher_fdddf/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
.idea
target/
Test.java
44 changes: 44 additions & 0 deletions EmailFetcher_fdddf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 邮件拉取器
邮件拉取器,适配IMAP, POP3协议邮箱。支持将附件保存到OSS中。

## 逻辑详情

### getInboxEmails

获取邮箱收件箱邮件列表

* 入参:int page 默认1, int pageSize 默认10
* 出参:`List<Email>`

### getInboxEmailsWithConfig

获取邮箱收件箱邮件列表,支持运行时配置参数

* 入参:int page 默认1, int pageSize 默认10, EmailConfig config
* 出参:`List<Email>`

### extractEmails

提取邮件内容
* 入参:无
* 出参:`List<Email>`

### extractEmailsWithConfig

提取邮件内容,支持运行时配置参数
* 入参:EmailConfig config
* 出参:`List<Email>`

## 使用步骤说明

1. 应用引用依赖库
2. 配置应用配置参数
3. 逻辑调用示例截图

![Snipaste_2024-04-29_14-48-29.jpg](Snipaste_2024-04-29_14-48-29.jpg)


## 应用演示链接

[使用了本依赖库的制品应用链接]
https://dev-test430-qa.app.codewave.163.com/email
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mvn install:install-file -Dfile="nasl-metadata-maven-plugin-1.3.0.jar" -DpomFile="pom.xml"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mvn install:install-file -Dfile="nasl-metadata-maven-plugin-1.3.0.jar" -DpomFile="pom.xml"
Binary file not shown.
74 changes: 74 additions & 0 deletions EmailFetcher_fdddf/jar/nasl-metadata-maven-plugin-1.3.0/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.netease.lowcode</groupId>
<artifactId>nasl-metadata-maven-plugin</artifactId>
<version>1.3.0</version>
<packaging>maven-plugin</packaging>

<name>Nasl Metadata Maven Plugin</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0.10</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-manager</artifactId>
<version>2.8.4</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.8</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-common-artifact-filters</artifactId>
<version>3.0.1</version>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-aether-provider</artifactId>
<version>3.3.9</version>
</dependency>

<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.2</version>
<configuration>
<goalPrefix>nasl-metadata-maven-plugin</goalPrefix>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
</plugin>
</plugins>
</build>
</project>
97 changes: 97 additions & 0 deletions EmailFetcher_fdddf/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://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>2.2.9.RELEASE</version><!--与当前制品应用默认版本统一-->
</parent>

<groupId>fdddf</groupId>
<artifactId>EmailFetcher</artifactId>
<name>EmailFetcher</name>
<description>邮件拉取工具,支持IMAP/POP3协议;支持邮件附件保存到OSS</description>
<version>1.2.2</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nasl.ide.version>3.3</nasl.ide.version>
</properties>
<dependencies>
<!--本案例是本地系统引入nasl-metadata-collector-0.8.0.jar的方式。
若把nasl-metadata-collector-0.8.0.jar安装到自己的maven仓库,
注意修改artifactId和groupId的情况下,不要使用<scope>system</scope>,会在发布时造成依赖中断。
不修改artifactId和groupId的情况下,nasl-metadata-maven-plugin会做特殊处理-->
<dependency>
<artifactId>nasl-metadata-collector</artifactId>
<groupId>com.netease.lowcode</groupId>
<version>0.8.0</version>
<optional>true</optional>
<scope>system</scope>
<systemPath>${project.basedir}/jar/nasl-metadata-collector-0.8.0.jar</systemPath>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.mail/javax.mail -->
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.16.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-s3 -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.12.440</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.aliyun.oss/aliyun-sdk-oss -->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.17.4</version>
</dependency>
<!--制品应用使用Springboot框架,父应用引用了的包,为了防止版本冲突,scope可设置为provided-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.netease.lowcode</groupId>
<artifactId>nasl-metadata-maven-plugin</artifactId>
<version>1.3.0</version>
<configuration>
<jarWithDependencies>false</jarWithDependencies>
</configuration>
<executions>
<execution>
<goals>
<goal>archive</goal>
</goals>
</execution>
</executions>
</plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target></configuration></plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.fdddf.emailfetcher;

import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.fdddf.emailfetcher.api.EmailExtractor;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class AmazonOSS {
protected final EmailConfig cfg;

private static final Logger logger = LoggerFactory.getLogger(EmailExtractor.class);

public AmazonOSS(EmailConfig cfg) {
this.cfg = cfg;
}

public List<String> saveAttachmentToOSS(Map<String, InputStream> attachments) {
BasicAWSCredentials credentials = new BasicAWSCredentials(cfg.ossAccessKeyId, cfg.ossAccessKeySecret);
AWSStaticCredentialsProvider provider = new AWSStaticCredentialsProvider(credentials);

String endpoint = cfg.ossEndpoint;
if (!endpoint.startsWith("http")) {
endpoint = "https://" + endpoint;
}
String bucketDomain = cfg.ossBucketDomain;
if (!bucketDomain.startsWith("http")) {
bucketDomain = "https://" + bucketDomain;
}

AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
.withCredentials(provider)
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(
endpoint,
""))
.withPathStyleAccessEnabled(false)
.withChunkedEncodingDisabled(true)
.build();

List<String> savedAttachments = new ArrayList<>();

for (String filename : attachments.keySet()) {
logger.info("will put attachment to oss: {}", filename);
String objectName = FilenameUtils.getName(filename);
if (cfg.ossFolder != null && !cfg.ossFolder.isEmpty()) {
objectName = cfg.ossFolder + "/" + objectName;
}

try {
if (s3Client.doesObjectExist(cfg.ossBucketName, objectName)) {
savedAttachments.add(bucketDomain + "/" + objectName);
continue;
}
s3Client.putObject(cfg.ossBucketName, objectName, attachments.get(filename), null);
} catch (AmazonServiceException e) {
logger.error("Caught an OSSException, which means your request made it to OSS, "
+ "but was rejected with an error response for some reason.", e);
e.printStackTrace();
continue;
}

savedAttachments.add(bucketDomain + "/" + objectName);
}
s3Client.shutdown();

return savedAttachments;
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.fdddf.emailfetcher;

import javax.mail.Folder;
import javax.mail.search.SearchTerm;

public interface CustomFilter {
public SearchTerm getCustomSearch(Folder folder);
}
Loading

0 comments on commit c016c93

Please sign in to comment.