You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2020/12/07 19:01:31 UTC

[GitHub] [fineract] fynmanoj opened a new pull request #1538: FINERACT-1277-Message-Gateway-webhook

fynmanoj opened a new pull request #1538:
URL: https://github.com/apache/fineract/pull/1538


   ## Description
   
   Describe the changes made and why they were made.
   
   Ignore if these details are present on the associated [Apache Fineract JIRA ticket](https://github.com/apache/fineract/pull/1284).
   
   
   ## Checklist
   
   Please make sure these boxes are checked before submitting your pull request - thanks!
   
   - [ ] Write the commit message as per https://github.com/apache/fineract/#pull-requests
   
   - [ ] Acknowledge that we will not review PRs that are not passing the build _("green")_ - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
   
   - [ ] Create/update unit or integration tests for verifying the changes made.
   
   - [ ] Follow coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions.
   
   - [ ] Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/api-docs/apiLive.htm with details of any API changes
   
   - [ ] Submission is not a "code dump".  (Large changes can be made "in repository" via a branch.  Ask on the developer mailing list for guidance, if required.)
   
   FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [fineract] github-actions[bot] commented on pull request #1538: FINERACT-1277-Message-Gateway-webhook

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #1538:
URL: https://github.com/apache/fineract/pull/1538#issuecomment-792390458


   This pull request seems to be stale.  Are you still planning to work on it?  We will automatically close it in 30 days.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [fineract] vorburger commented on a change in pull request #1538: FINERACT-1277-Message-Gateway-webhook

Posted by GitBox <gi...@apache.org>.
vorburger commented on a change in pull request #1538:
URL: https://github.com/apache/fineract/pull/1538#discussion_r541646227



##########
File path: fineract-provider/src/main/java/org/apache/fineract/infrastructure/hooks/processor/MessageGatewayHookProcessor.java
##########
@@ -0,0 +1,121 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.infrastructure.hooks.processor;
+
+import static org.apache.fineract.infrastructure.hooks.api.HookApiConstants.SMSProviderIdParamName;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import java.io.IOException;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException;
+import org.apache.fineract.infrastructure.hooks.domain.Hook;
+import org.apache.fineract.infrastructure.hooks.domain.HookConfiguration;
+import org.apache.fineract.infrastructure.sms.domain.SmsMessage;
+import org.apache.fineract.infrastructure.sms.domain.SmsMessageRepository;
+import org.apache.fineract.infrastructure.sms.scheduler.SmsMessageScheduledJobService;
+import org.apache.fineract.portfolio.client.domain.Client;
+import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
+import org.apache.fineract.template.domain.Template;
+import org.apache.fineract.template.domain.TemplateRepository;
+import org.apache.fineract.template.service.TemplateMergeService;
+import org.apache.fineract.useradministration.domain.AppUser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class MessageGatewayHookProcessor implements HookProcessor {
+
+    private static final Logger LOG = LoggerFactory.getLogger(MessageGatewayHookProcessor.class);
+
+    private final ClientRepositoryWrapper clientRepository;
+    private final TemplateRepository templateRepository;
+    private final TemplateMergeService templateMergeService;
+
+    private final SmsMessageRepository smsMessageRepository;
+    private final SmsMessageScheduledJobService smsMessageScheduledJobService;
+
+    @Autowired
+    public MessageGatewayHookProcessor(ClientRepositoryWrapper clientRepository, TemplateRepository templateRepository,
+            TemplateMergeService templateMergeService, SmsMessageRepository smsMessageRepository,
+            SmsMessageScheduledJobService smsMessageScheduledJobService) {
+        this.clientRepository = clientRepository;
+        this.templateRepository = templateRepository;
+        this.templateMergeService = templateMergeService;
+        this.smsMessageRepository = smsMessageRepository;
+        this.smsMessageScheduledJobService = smsMessageScheduledJobService;
+    }
+
+    @Override
+    public void process(final Hook hook, @SuppressWarnings("unused") final AppUser appUser, final String payload, final String entityName,
+            final String actionName, final String tenantIdentifier, final String authToken) throws IOException {
+
+        final Set<HookConfiguration> config = hook.getHookConfig();
+
+        Integer SMSProviderId = null;
+
+        for (final HookConfiguration conf : config) {
+            final String fieldName = conf.getFieldName();
+            if (fieldName.equals(SMSProviderIdParamName)) {
+                SMSProviderId = Integer.parseInt(conf.getFieldValue());
+            }
+        }
+
+        String templateName = entityName + "_" + actionName;
+
+        // 1 : find template via mapper using entity and action
+        Template template = null;

Review comment:
       ```suggestion
           Template template;
   ```
   
   is better, because it will be assign in the `if .. else` below anyway, so it's "safer" not to initialize it with null

##########
File path: fineract-provider/src/main/java/org/apache/fineract/infrastructure/hooks/processor/MessageGatewayHookProcessor.java
##########
@@ -0,0 +1,121 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.infrastructure.hooks.processor;
+
+import static org.apache.fineract.infrastructure.hooks.api.HookApiConstants.SMSProviderIdParamName;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import java.io.IOException;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException;
+import org.apache.fineract.infrastructure.hooks.domain.Hook;
+import org.apache.fineract.infrastructure.hooks.domain.HookConfiguration;
+import org.apache.fineract.infrastructure.sms.domain.SmsMessage;
+import org.apache.fineract.infrastructure.sms.domain.SmsMessageRepository;
+import org.apache.fineract.infrastructure.sms.scheduler.SmsMessageScheduledJobService;
+import org.apache.fineract.portfolio.client.domain.Client;
+import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
+import org.apache.fineract.template.domain.Template;
+import org.apache.fineract.template.domain.TemplateRepository;
+import org.apache.fineract.template.service.TemplateMergeService;
+import org.apache.fineract.useradministration.domain.AppUser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class MessageGatewayHookProcessor implements HookProcessor {
+
+    private static final Logger LOG = LoggerFactory.getLogger(MessageGatewayHookProcessor.class);
+
+    private final ClientRepositoryWrapper clientRepository;
+    private final TemplateRepository templateRepository;
+    private final TemplateMergeService templateMergeService;
+
+    private final SmsMessageRepository smsMessageRepository;
+    private final SmsMessageScheduledJobService smsMessageScheduledJobService;
+
+    @Autowired
+    public MessageGatewayHookProcessor(ClientRepositoryWrapper clientRepository, TemplateRepository templateRepository,
+            TemplateMergeService templateMergeService, SmsMessageRepository smsMessageRepository,
+            SmsMessageScheduledJobService smsMessageScheduledJobService) {
+        this.clientRepository = clientRepository;
+        this.templateRepository = templateRepository;
+        this.templateMergeService = templateMergeService;
+        this.smsMessageRepository = smsMessageRepository;
+        this.smsMessageScheduledJobService = smsMessageScheduledJobService;
+    }
+
+    @Override
+    public void process(final Hook hook, @SuppressWarnings("unused") final AppUser appUser, final String payload, final String entityName,
+            final String actionName, final String tenantIdentifier, final String authToken) throws IOException {
+
+        final Set<HookConfiguration> config = hook.getHookConfig();
+
+        Integer SMSProviderId = null;
+
+        for (final HookConfiguration conf : config) {
+            final String fieldName = conf.getFieldName();
+            if (fieldName.equals(SMSProviderIdParamName)) {
+                SMSProviderId = Integer.parseInt(conf.getFieldValue());
+            }
+        }
+
+        String templateName = entityName + "_" + actionName;
+
+        // 1 : find template via mapper using entity and action
+        Template template = null;
+        List<Template> templates = this.templateRepository.findByTemplateMapper("SMS_tempalte_Key", templateName);

Review comment:
       ```suggestion
           List<Template> templates = this.templateRepository.findByTemplateMapper("SMS_template_Key", templateName);
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [fineract] github-actions[bot] commented on pull request #1538: FINERACT-1277-Message-Gateway-webhook

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #1538:
URL: https://github.com/apache/fineract/pull/1538#issuecomment-759861013


   This pull request seems to be stale.  Are you still planning to work on it?  We will automatically close it in 30 days.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [fineract] BLasan commented on pull request #1538: FINERACT-1277-Message-Gateway-webhook

Posted by GitBox <gi...@apache.org>.
BLasan commented on pull request #1538:
URL: https://github.com/apache/fineract/pull/1538#issuecomment-766094270


   > @BLasan it looks like this is inactive, and @fynmanoj abandoned it, yes.
   > 
   > But to be honest, from where I sit, you benefit the project more by working on new issues than by "cleaning up" other people's PRs. It's OK to just let these "stale" PRs by automatically closed by our bot, if the original author no longer has any interest in them - that's life. If someone really does care to get a contribution merged, normally they are expected to follow-up on review feedback.
   > 
   > But it's your choice what you like to work on and contribute!  You can also post to the mailing list to ask. I got hundred to propose you! Depending on your skills and interest.
   
   Thank you sir! I'm interested in taking up some new issues :)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [fineract] BLasan commented on pull request #1538: FINERACT-1277-Message-Gateway-webhook

Posted by GitBox <gi...@apache.org>.
BLasan commented on pull request #1538:
URL: https://github.com/apache/fineract/pull/1538#issuecomment-762682945


   @vorburger Is this inactive? If so shall I rebase this and resend a PR?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [fineract] vorburger commented on pull request #1538: FINERACT-1277-Message-Gateway-webhook

Posted by GitBox <gi...@apache.org>.
vorburger commented on pull request #1538:
URL: https://github.com/apache/fineract/pull/1538#issuecomment-766095367


   > Thank you sir! I'm interested in taking up some new issues :)
   
   @BLasan have you already joined our developer mailing list http://fineract.apache.org/#contribute as per https://github.com/apache/fineract#community? Please send a short email introducing yourself there to say Hello to everyone. If you state there that you are interested in new issues, perhaps with some context about your skills and interests if you like, I'll reply with a link to possible issues!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [fineract] github-actions[bot] closed pull request #1538: FINERACT-1277-Message-Gateway-webhook

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed pull request #1538:
URL: https://github.com/apache/fineract/pull/1538


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [fineract] BLasan commented on pull request #1538: FINERACT-1277-Message-Gateway-webhook

Posted by GitBox <gi...@apache.org>.
BLasan commented on pull request #1538:
URL: https://github.com/apache/fineract/pull/1538#issuecomment-766099873


   > > Thank you sir! I'm interested in taking up some new issues :)
   > 
   > @BLasan have you already joined our developer mailing list http://fineract.apache.org/#contribute as per https://github.com/apache/fineract#community? Please send a short email introducing yourself there to say Hello to everyone. If you state there that you are interested in new issues, perhaps with some context about your skills and interests if you like, I'll reply with a link to possible issues!
   
   I've sent a blank mail as requested to dev-subscribe. And thank you for the guidance sir!!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [fineract] vorburger commented on pull request #1538: FINERACT-1277-Message-Gateway-webhook

Posted by GitBox <gi...@apache.org>.
vorburger commented on pull request #1538:
URL: https://github.com/apache/fineract/pull/1538#issuecomment-766091542


   @BLasan it looks like this is inactive, and @fynmanoj abandoned it, yes. 
   
   But to be honest, from where I sit, you benefit the project more by working on new issues than by "cleaning up" other people's PRs. It's OK to just let these "stale" PRs by automatically closed by our bot, if the original author no longer has any interest in them - that's life. If someone really does care to get a contribution merged, normally they are expected to follow-up on review feedback.
   
   But it's your choice what you like to work on and contribute! 😃 You can also post to the mailing list to ask. I got hundred to propose you! Depending on your skills and interest.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org