mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
Added User Feedback support.
This commit is contained in:
parent
e50de69420
commit
3434dc1a97
14 changed files with 1065 additions and 149 deletions
|
|
@ -42,6 +42,7 @@ import mage.remote.MageVersionException;
|
|||
import mage.server.draft.DraftManager;
|
||||
import mage.server.game.*;
|
||||
import mage.server.services.LogKeys;
|
||||
import mage.server.services.impl.FeedbackServiceImpl;
|
||||
import mage.server.services.impl.LogServiceImpl;
|
||||
import mage.server.tournament.TournamentFactory;
|
||||
import mage.server.tournament.TournamentManager;
|
||||
|
|
@ -61,7 +62,7 @@ import java.util.concurrent.ExecutorService;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author BetaSteward_at_googlemail.com, noxx
|
||||
*/
|
||||
public class MageServerImpl implements MageServer {
|
||||
|
||||
|
|
@ -707,6 +708,19 @@ public class MageServerImpl implements MageServer {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFeedbackMessage(final String sessionId, final String username, final String title, final String type, final String message, final String email) throws MageException {
|
||||
if (title != null && message != null) {
|
||||
execute("sendFeedbackMessage", sessionId, new Action() {
|
||||
public void execute() {
|
||||
String host = SessionManager.getInstance().getSession(sessionId).getHost();
|
||||
FeedbackServiceImpl.instance.feedback(username, title, type, message, email, host);
|
||||
LogServiceImpl.instance.log(LogKeys.KEY_FEEDBACK_ADDED, sessionId, username, host);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void sendBroadcastMessage(final String sessionId, final String message) throws MageException {
|
||||
if (message != null) {
|
||||
execute("sendBroadcastMessage", sessionId, new Action() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package mage.server.services;
|
||||
|
||||
/**
|
||||
* Responsible for gathering feedback from users and storing them in DB.
|
||||
*
|
||||
* @author noxx
|
||||
*/
|
||||
public interface FeedbackService {
|
||||
|
||||
/**
|
||||
* Saves feedback.
|
||||
*/
|
||||
void feedback(String username, String title, String type, String message, String email, String host);
|
||||
}
|
||||
|
|
@ -28,4 +28,6 @@ public interface LogKeys {
|
|||
public static final String KEY_WRONG_VERSION = "wrongVersion";
|
||||
|
||||
public static final String KEY_NOT_ADMIN = "notAdminRestrictedOperation";
|
||||
|
||||
public static final String KEY_FEEDBACK_ADDED = "feedbackAdded";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package mage.server.services.impl;
|
||||
|
||||
import mage.db.EntityManager;
|
||||
import mage.server.services.FeedbackService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
*/
|
||||
public enum FeedbackServiceImpl implements FeedbackService {
|
||||
instance;
|
||||
|
||||
private static Logger log = Logger.getLogger(FeedbackServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public void feedback(String username, String title, String type, String message, String email, String host) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
try {
|
||||
EntityManager.instance.insertFeedback(username, title, type, message, email, host, cal.getTime());
|
||||
} catch (Exception e) {
|
||||
log.fatal(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue