From bebe7c159f00e6d5a83bb786824d5f32e4de9270 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 24 Feb 2018 16:54:28 +0300 Subject: spring boot wip --- build.gradle | 22 +- juick-notifications/build.gradle | 9 +- .../main/java/com/juick/components/MPNSClient.java | 4 +- .../main/java/com/juick/components/PushServer.java | 12 + .../components/configuration/GCMConfiguration.java | 2 +- .../configuration/NotificationsInitializer.java | 39 - juick-server-core/src/main/resources/juick.sql | 915 +++++++++++++++++++++ juick-server-core/src/main/resources/schema.sql | 915 --------------------- juick-server-jdbc/build.gradle | 37 +- .../com/juick/configuration/DataConfiguration.java | 9 +- .../configuration/RepositoryConfiguration.java | 10 - .../java/com/juick/service/MessageServiceTest.java | 9 +- juick-server-web/build.gradle | 41 +- .../server/configuration/BaseWebConfiguration.java | 30 + .../java/com/juick/server/xmpp/JidConverter.java | 13 + .../juick/server/xmpp/extensions/JuickMessage.java | 162 ++++ .../juick/server/xmpp/extensions/JuickUser.java | 65 ++ .../juick/server/xmpp/s2s/BasicXmppSession.java | 69 ++ .../NotAuthorizedAuthenticationEntryPoint.java | 3 +- juick-server/build.gradle | 16 +- .../src/main/java/com/juick/server/ApiServer.java | 12 + .../main/java/com/juick/server/XMPPConnection.java | 20 +- .../java/com/juick/server/api/Notifications.java | 2 +- .../server/configuration/ApiAppConfiguration.java | 34 +- .../juick/server/configuration/ApiInitializer.java | 64 -- .../configuration/ApiSecurityInitializer.java | 38 - .../juick/server/xmpp/extensions/JuickMessage.java | 162 ---- .../juick/server/xmpp/extensions/JuickUser.java | 65 -- .../juick/server/xmpp/helpers/JidConverter.java | 13 - .../juick/server/xmpp/s2s/BasicXmppSession.java | 69 -- .../java/com/juick/server/tests/ServerTests.java | 36 +- juick-www/build.gradle | 9 +- .../src/main/java/com/juick/www/Application.java | 12 + .../www/configuration/WwwAppConfiguration.java | 11 +- .../juick/www/configuration/WwwInitializer.java | 74 -- .../www/configuration/WwwSecurityInitializer.java | 37 - .../www/configuration/WwwServletConfiguration.java | 2 - .../src/test/java/com/juick/www/WebAppTests.java | 36 +- juick-xmpp-wip/build.gradle | 10 +- .../main/java/com/juick/components/XMPPBot.java | 6 + .../configuration/BotAppConfiguration.java | 15 +- .../components/configuration/BotInitializer.java | 56 -- .../src/test/java/com/juick/xmpp/XMPPTests.java | 28 +- 43 files changed, 1447 insertions(+), 1746 deletions(-) create mode 100644 juick-notifications/src/main/java/com/juick/components/PushServer.java delete mode 100644 juick-notifications/src/main/java/com/juick/components/configuration/NotificationsInitializer.java create mode 100644 juick-server-core/src/main/resources/juick.sql delete mode 100644 juick-server-core/src/main/resources/schema.sql create mode 100644 juick-server-web/src/main/java/com/juick/server/xmpp/JidConverter.java create mode 100644 juick-server-web/src/main/java/com/juick/server/xmpp/extensions/JuickMessage.java create mode 100644 juick-server-web/src/main/java/com/juick/server/xmpp/extensions/JuickUser.java create mode 100644 juick-server-web/src/main/java/com/juick/server/xmpp/s2s/BasicXmppSession.java create mode 100644 juick-server/src/main/java/com/juick/server/ApiServer.java delete mode 100644 juick-server/src/main/java/com/juick/server/configuration/ApiInitializer.java delete mode 100644 juick-server/src/main/java/com/juick/server/configuration/ApiSecurityInitializer.java delete mode 100644 juick-server/src/main/java/com/juick/server/xmpp/extensions/JuickMessage.java delete mode 100644 juick-server/src/main/java/com/juick/server/xmpp/extensions/JuickUser.java delete mode 100644 juick-server/src/main/java/com/juick/server/xmpp/helpers/JidConverter.java delete mode 100644 juick-server/src/main/java/com/juick/server/xmpp/s2s/BasicXmppSession.java create mode 100644 juick-www/src/main/java/com/juick/www/Application.java delete mode 100644 juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java delete mode 100644 juick-www/src/main/java/com/juick/www/configuration/WwwSecurityInitializer.java delete mode 100644 juick-xmpp-wip/src/main/java/com/juick/components/configuration/BotInitializer.java diff --git a/build.gradle b/build.gradle index f4128c78..89ffeb42 100644 --- a/build.gradle +++ b/build.gradle @@ -21,8 +21,7 @@ allprojects { } project.ext { - springFrameworkVersion = '5.0.4.RELEASE' - springSecurityVersion = '5.0.3.RELEASE' + springBootVersion = '2.0.0.RELEASE' jacksonVersion = '2.9.4' slf4jVersion = '1.7.25' logbackVersion = '1.2.3' @@ -37,20 +36,13 @@ buildscript { jcenter() } dependencies { - classpath 'org.akhikhl.gretty:gretty:+' + classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.0.RELEASE" classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0' } } apply plugin: 'java' -apply plugin: 'org.akhikhl.gretty' - -farm { - webapp ':juick-www' - webapp ':juick-server' - - - servletContainer = 'tomcat8' -} +apply plugin: 'org.springframework.boot' +apply plugin: 'io.spring.dependency-management' repositories { jcenter() @@ -62,9 +54,9 @@ dependencies { testCompile "org.json:json:20180130" testCompile "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}" testCompile "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}" - testCompile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${rootProject.jacksonVersion}" - testCompile "org.springframework:spring-jdbc:${springFrameworkVersion}" - testCompile "org.springframework:spring-test:${springFrameworkVersion}" + testCompile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${jacksonVersion}" + compile("org.springframework.boot:spring-boot-starter-jdbc") + compile("org.springframework.boot:spring-boot-starter-test") testCompile "org.slf4j:slf4j-api:${slf4jVersion}" testCompile "junit:junit:${junitVersion}" testCompile "org.hamcrest:hamcrest-all:${hamcrestVersion}" diff --git a/juick-notifications/build.gradle b/juick-notifications/build.gradle index 8cf770a6..099e5e29 100644 --- a/juick-notifications/build.gradle +++ b/juick-notifications/build.gradle @@ -1,6 +1,7 @@ apply plugin: 'java' apply plugin: 'war' -apply plugin: 'org.akhikhl.gretty' +apply plugin: 'org.springframework.boot' +apply plugin: 'io.spring.dependency-management' dependencies { compile project(':juick-server-web') @@ -14,12 +15,6 @@ dependencies { compileJava.options.encoding = 'UTF-8' -gretty { - httpPort = 8080 - contextPath = '' - servletContainer = 'tomcat8' -} - configurations { all*.exclude module: 'commons-logging' } diff --git a/juick-notifications/src/main/java/com/juick/components/MPNSClient.java b/juick-notifications/src/main/java/com/juick/components/MPNSClient.java index 21286258..efa47bb1 100644 --- a/juick-notifications/src/main/java/com/juick/components/MPNSClient.java +++ b/juick-notifications/src/main/java/com/juick/components/MPNSClient.java @@ -34,9 +34,9 @@ public class MPNSClient { @Inject private ObjectMapper jsonMapper; - @Value("${wns_application_sip}") + @Value("${wns_application_sip:}") private String applicationSip; - @Value("${wns_client_secret}") + @Value("${wns_client_secret:}") private String applicationSecret; private RestTemplate wnsService; diff --git a/juick-notifications/src/main/java/com/juick/components/PushServer.java b/juick-notifications/src/main/java/com/juick/components/PushServer.java new file mode 100644 index 00000000..c22f48dc --- /dev/null +++ b/juick-notifications/src/main/java/com/juick/components/PushServer.java @@ -0,0 +1,12 @@ +package com.juick.components; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class PushServer { + + public static void main(String[] args) { + SpringApplication.run(PushServer.class, args); + } +} diff --git a/juick-notifications/src/main/java/com/juick/components/configuration/GCMConfiguration.java b/juick-notifications/src/main/java/com/juick/components/configuration/GCMConfiguration.java index 96c7716f..27e1af0f 100644 --- a/juick-notifications/src/main/java/com/juick/components/configuration/GCMConfiguration.java +++ b/juick-notifications/src/main/java/com/juick/components/configuration/GCMConfiguration.java @@ -11,7 +11,7 @@ import org.springframework.context.annotation.Configuration; */ @Configuration public class GCMConfiguration { - @Value("${gcm_key}") + @Value("${gcm_key:}") private String gcmKey; @Bean diff --git a/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsInitializer.java b/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsInitializer.java deleted file mode 100644 index d4068d26..00000000 --- a/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsInitializer.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.juick.components.configuration; - -import org.apache.commons.codec.CharEncoding; -import org.springframework.web.filter.CharacterEncodingFilter; -import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; - -import javax.servlet.Filter; - -/** - * Created by vt on 09/02/16. - */ -public class NotificationsInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { - - @Override - protected Class[] getRootConfigClasses() { - return new Class[] {}; - } - - @Override - protected Class[] getServletConfigClasses() { - return new Class[]{ NotificationsAppConfiguration.class }; - } - - @Override - protected String[] getServletMappings() { - return new String[]{"/"}; - } - - @Override - protected Filter[] getServletFilters() { - CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(CharEncoding.UTF_8); - return new Filter[]{characterEncodingFilter}; - } - - @Override - protected String getServletName() { - return "Notifications dispatcher servlet"; - } -} diff --git a/juick-server-core/src/main/resources/juick.sql b/juick-server-core/src/main/resources/juick.sql new file mode 100644 index 00000000..518c89ab --- /dev/null +++ b/juick-server-core/src/main/resources/juick.sql @@ -0,0 +1,915 @@ +-- MySQL dump 10.16 Distrib 10.1.26-MariaDB, for debian-linux-gnu (x86_64) +-- +-- Host: localhost Database: juick +-- ------------------------------------------------------ +use juick; +-- Server version 10.1.26-MariaDB-0+deb9u1 +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `ads_messages` +-- + +DROP TABLE IF EXISTS `ads_messages`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ads_messages` ( + `message_id` int(10) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `ads_messages_log` +-- + +DROP TABLE IF EXISTS `ads_messages_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ads_messages_log` ( + `user_id` int(10) unsigned NOT NULL, + `message_id` int(10) unsigned NOT NULL, + `ts` int(10) unsigned NOT NULL DEFAULT '0' +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `android` +-- + +DROP TABLE IF EXISTS `android`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `android` ( + `user_id` int(10) unsigned NOT NULL, + `regid` char(255) NOT NULL, + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + UNIQUE KEY `regid` (`regid`), + KEY `user_id` (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `auth` +-- + +DROP TABLE IF EXISTS `auth`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `auth` ( + `user_id` int(10) unsigned NOT NULL, + `protocol` enum('xmpp','email','sms') NOT NULL, + `account` char(64) NOT NULL, + `authcode` char(8) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `bl_tags` +-- + +DROP TABLE IF EXISTS `bl_tags`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `bl_tags` ( + `user_id` int(10) unsigned NOT NULL, + `tag_id` int(10) unsigned NOT NULL, + KEY `tag_id` (`tag_id`), + KEY `user_id` (`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `bl_users` +-- + +DROP TABLE IF EXISTS `bl_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `bl_users` ( + `user_id` int(10) unsigned NOT NULL, + `bl_user_id` int(10) unsigned NOT NULL, + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`user_id`,`bl_user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `captcha` +-- + +DROP TABLE IF EXISTS `captcha`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `captcha` ( + `jid` char(64) NOT NULL, + `hash` char(16) NOT NULL, + `confirmed` tinyint(4) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `captchaimg` +-- + +DROP TABLE IF EXISTS `captchaimg`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `captchaimg` ( + `id` char(16) NOT NULL, + `txt` char(6) NOT NULL, + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `ip` char(16) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `emails` +-- + +DROP TABLE IF EXISTS `emails`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `emails` ( + `user_id` int(10) unsigned NOT NULL, + `email` char(64) NOT NULL, + `subscr_hour` tinyint(4) DEFAULT NULL, + KEY `email` (`email`) USING HASH +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `facebook` +-- + +DROP TABLE IF EXISTS `facebook`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `facebook` ( + `user_id` int(10) unsigned DEFAULT NULL, + `fb_id` bigint(20) unsigned NOT NULL, + `loginhash` char(36) DEFAULT NULL, + `access_token` char(255) DEFAULT NULL, + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `fb_name` char(64) NOT NULL, + `fb_link` char(64) NOT NULL, + `crosspost` tinyint(1) unsigned NOT NULL DEFAULT '1', + KEY `user_id` (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `favorites` +-- + +DROP TABLE IF EXISTS `favorites`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `favorites` ( + `user_id` int(10) unsigned NOT NULL, + `message_id` int(10) unsigned NOT NULL, + `ts` datetime NOT NULL, + UNIQUE KEY `user_id_2` (`user_id`,`message_id`), + KEY `user_id` (`user_id`), + KEY `message_id` (`message_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `friends_facebook` +-- + +DROP TABLE IF EXISTS `friends_facebook`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `friends_facebook` ( + `user_id` int(10) unsigned NOT NULL, + `friend_id` bigint(20) unsigned NOT NULL, + UNIQUE KEY `user_id` (`user_id`,`friend_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `images` +-- + +DROP TABLE IF EXISTS `images`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `images` ( + `mid` int(10) unsigned NOT NULL, + `rid` int(10) unsigned NOT NULL, + `thumb` int(10) unsigned NOT NULL, + `small` int(10) unsigned NOT NULL, + `medium` int(10) unsigned NOT NULL, + `height` int(10) unsigned NOT NULL, + `width` int(10) unsigned NOT NULL, + PRIMARY KEY (`mid`,`rid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `ios` +-- + +DROP TABLE IF EXISTS `ios`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ios` ( + `user_id` int(10) unsigned NOT NULL, + `token` char(64) COLLATE utf8mb4_unicode_ci NOT NULL, + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + UNIQUE KEY `token` (`token`), + KEY `user_id` (`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `jids` +-- + +DROP TABLE IF EXISTS `jids`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `jids` ( + `user_id` int(10) unsigned DEFAULT NULL, + `jid` char(64) NOT NULL, + `active` tinyint(1) NOT NULL DEFAULT '1', + `loginhash` char(36) DEFAULT NULL, + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + UNIQUE KEY `jid` (`jid`), + KEY `user_id` (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `logins` +-- + +DROP TABLE IF EXISTS `logins`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `logins` ( + `user_id` int(10) unsigned NOT NULL, + `hash` char(16) NOT NULL, + UNIQUE KEY `user_id` (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `mail` +-- + +DROP TABLE IF EXISTS `mail`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `mail` ( + `user_id` int(10) unsigned NOT NULL, + `hash` char(16) NOT NULL, + PRIMARY KEY (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `meon` +-- + +DROP TABLE IF EXISTS `meon`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `meon` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(10) unsigned NOT NULL, + `link` char(255) NOT NULL, + `name` char(32) NOT NULL, + `ico` smallint(5) unsigned DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `messages` +-- + +DROP TABLE IF EXISTS `messages`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `messages` ( + `message_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(10) unsigned NOT NULL, + `lang` enum('en','ru','fr','fa','__') NOT NULL DEFAULT '__', + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `replies` smallint(5) unsigned NOT NULL DEFAULT '0', + `maxreplyid` smallint(5) unsigned NOT NULL DEFAULT '0', + `privacy` tinyint(4) NOT NULL DEFAULT '1', + `readonly` tinyint(1) NOT NULL DEFAULT '0', + `attach` enum('jpg','mp4','png') DEFAULT NULL, + `place_id` int(10) unsigned DEFAULT NULL, + `lat` decimal(10,7) DEFAULT NULL, + `lon` decimal(10,7) DEFAULT NULL, + `popular` tinyint(4) NOT NULL DEFAULT '0', + `hidden` tinyint(3) unsigned NOT NULL DEFAULT '0', + `likes` smallint(6) NOT NULL DEFAULT '0', + `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`message_id`), + KEY `user_id` (`user_id`), + KEY `ts` (`ts`), + KEY `attach` (`attach`), + KEY `place_id` (`place_id`), + KEY `popular` (`popular`), + KEY `hidden` (`hidden`), + KEY `updated_indx` (`updated`,`message_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `messages_access` +-- + +DROP TABLE IF EXISTS `messages_access`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `messages_access` ( + `message_id` int(10) unsigned NOT NULL, + `user_id` int(10) unsigned NOT NULL, + KEY `message_id` (`message_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `messages_tags` +-- + +DROP TABLE IF EXISTS `messages_tags`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `messages_tags` ( + `message_id` int(10) unsigned NOT NULL, + `tag_id` int(10) unsigned NOT NULL, + UNIQUE KEY `message_id_2` (`message_id`,`tag_id`), + KEY `message_id` (`message_id`), + KEY `tag_id` (`tag_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `messages_txt` +-- + +DROP TABLE IF EXISTS `messages_txt`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `messages_txt` ( + `message_id` int(10) unsigned NOT NULL, + `tags` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `repliesby` varchar(96) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `txt` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, + PRIMARY KEY (`message_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `messages_votes` +-- + +DROP TABLE IF EXISTS `messages_votes`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `messages_votes` ( + `message_id` int(10) unsigned NOT NULL, + `user_id` int(10) unsigned NOT NULL, + `vote` tinyint(4) NOT NULL DEFAULT '1', + UNIQUE KEY `message_id` (`message_id`,`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `messenger` +-- + +DROP TABLE IF EXISTS `messenger`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `messenger` ( + `user_id` int(10) unsigned DEFAULT NULL, + `sender_id` bigint(20) NOT NULL, + `display_name` char(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `loginhash` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `places` +-- + +DROP TABLE IF EXISTS `places`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `places` ( + `place_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `lat` decimal(10,7) NOT NULL, + `lon` decimal(10,7) NOT NULL, + `name` char(64) NOT NULL, + `descr` char(255) DEFAULT NULL, + `url` char(128) DEFAULT NULL, + `user_id` int(10) unsigned NOT NULL, + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`place_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `places_tags` +-- + +DROP TABLE IF EXISTS `places_tags`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `places_tags` ( + `place_id` int(10) unsigned NOT NULL, + `tag_id` int(10) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `pm` +-- + +DROP TABLE IF EXISTS `pm`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `pm` ( + `user_id` int(10) unsigned NOT NULL, + `user_id_to` int(10) unsigned NOT NULL, + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `txt` text NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `pm_inroster` +-- + +DROP TABLE IF EXISTS `pm_inroster`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `pm_inroster` ( + `user_id` int(10) unsigned NOT NULL, + `jid` char(64) NOT NULL, + UNIQUE KEY `user_id_2` (`user_id`,`jid`), + KEY `user_id` (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `pm_streams` +-- + +DROP TABLE IF EXISTS `pm_streams`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `pm_streams` ( + `user_id` int(10) unsigned NOT NULL, + `user_id_to` int(10) unsigned NOT NULL, + `lastmessage` datetime NOT NULL, + `lastview` datetime DEFAULT NULL, + `unread` smallint(5) unsigned NOT NULL DEFAULT '0', + UNIQUE KEY `user_id` (`user_id`,`user_id_to`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `presence` +-- + +DROP TABLE IF EXISTS `presence`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `presence` ( + `user_id` int(10) unsigned NOT NULL, + `jid` char(64) DEFAULT NULL, + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + UNIQUE KEY `jid` (`jid`) +) ENGINE=MEMORY DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `reader_links` +-- + +DROP TABLE IF EXISTS `reader_links`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `reader_links` ( + `link_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `rss_id` int(10) unsigned NOT NULL, + `url` char(255) NOT NULL, + `title` char(255) NOT NULL, + `ts` datetime NOT NULL, + PRIMARY KEY (`link_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `reader_rss` +-- + +DROP TABLE IF EXISTS `reader_rss`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `reader_rss` ( + `rss_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `url` char(255) NOT NULL, + `lastcheck` datetime NOT NULL, + PRIMARY KEY (`rss_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `replies` +-- + +DROP TABLE IF EXISTS `replies`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `replies` ( + `message_id` int(10) unsigned NOT NULL, + `reply_id` smallint(5) unsigned NOT NULL, + `user_id` int(10) unsigned NOT NULL, + `replyto` smallint(5) unsigned NOT NULL DEFAULT '0', + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `attach` enum('jpg','mp4','png') COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `txt` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, + KEY `message_id` (`message_id`), + KEY `user_id` (`user_id`), + KEY `ts` (`ts`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `sphinx` +-- + +DROP TABLE IF EXISTS `sphinx`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `sphinx` ( + `counter_id` tinyint(3) unsigned NOT NULL, + `max_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`counter_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `subscr_messages` +-- + +DROP TABLE IF EXISTS `subscr_messages`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `subscr_messages` ( + `message_id` int(10) unsigned NOT NULL, + `suser_id` int(10) unsigned NOT NULL, + UNIQUE KEY `message_id` (`message_id`,`suser_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `subscr_tags` +-- + +DROP TABLE IF EXISTS `subscr_tags`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `subscr_tags` ( + `tag_id` int(10) unsigned NOT NULL, + `suser_id` int(10) unsigned NOT NULL, + `jid` char(64) NOT NULL, + `active` bit(1) NOT NULL DEFAULT b'1', + UNIQUE KEY `tag_id` (`tag_id`,`suser_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `subscr_users` +-- + +DROP TABLE IF EXISTS `subscr_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `subscr_users` ( + `user_id` int(10) unsigned NOT NULL, + `suser_id` int(10) unsigned NOT NULL, + `jid` char(64) DEFAULT NULL, + `active` bit(1) NOT NULL DEFAULT b'1', + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + UNIQUE KEY `user_id` (`user_id`,`suser_id`), + KEY `suser_id` (`suser_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `tags` +-- + +DROP TABLE IF EXISTS `tags`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `tags` ( + `tag_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `synonym_id` int(10) unsigned DEFAULT NULL, + `name` char(70) CHARACTER SET utf8mb4 DEFAULT NULL, + `top` tinyint(1) unsigned NOT NULL DEFAULT '0', + `noindex` tinyint(1) unsigned NOT NULL DEFAULT '0', + `stat_messages` int(10) unsigned NOT NULL DEFAULT '0', + `stat_users` smallint(5) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`tag_id`), + KEY `synonym_id` (`synonym_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `tags_ignore` +-- + +DROP TABLE IF EXISTS `tags_ignore`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `tags_ignore` ( + `tag_id` int(10) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `tags_synonyms` +-- + +DROP TABLE IF EXISTS `tags_synonyms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `tags_synonyms` ( + `name` char(64) NOT NULL, + `changeto` char(64) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `telegram` +-- + +DROP TABLE IF EXISTS `telegram`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `telegram` ( + `user_id` int(10) unsigned DEFAULT NULL, + `tg_id` bigint(20) NOT NULL, + `tg_name` char(64) COLLATE utf8mb4_unicode_ci NOT NULL, + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `loginhash` char(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `telegram_chats` +-- + +DROP TABLE IF EXISTS `telegram_chats`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `telegram_chats` ( + `chat_id` bigint(20) DEFAULT NULL, + UNIQUE KEY `chat_id` (`chat_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `top_ignore_messages` +-- + +DROP TABLE IF EXISTS `top_ignore_messages`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `top_ignore_messages` ( + `message_id` int(10) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `top_ignore_tags` +-- + +DROP TABLE IF EXISTS `top_ignore_tags`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `top_ignore_tags` ( + `tag_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`tag_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `top_ignore_users` +-- + +DROP TABLE IF EXISTS `top_ignore_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `top_ignore_users` ( + `user_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `twitter` +-- + +DROP TABLE IF EXISTS `twitter`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `twitter` ( + `user_id` int(10) unsigned NOT NULL, + `access_token` char(64) NOT NULL, + `access_token_secret` char(64) NOT NULL, + `uname` char(64) NOT NULL, + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `crosspost` tinyint(1) unsigned NOT NULL DEFAULT '1', + PRIMARY KEY (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `useroptions` +-- + +DROP TABLE IF EXISTS `useroptions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `useroptions` ( + `user_id` int(10) unsigned NOT NULL, + `jnotify` tinyint(1) NOT NULL DEFAULT '1', + `subscr_active` tinyint(1) NOT NULL DEFAULT '1', + `off_ts` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `xmppxhtml` tinyint(1) NOT NULL DEFAULT '0', + `subscr_notify` tinyint(1) NOT NULL DEFAULT '1', + `recommendations` tinyint(1) NOT NULL DEFAULT '1', + `privacy_view` tinyint(1) NOT NULL DEFAULT '1', + `privacy_reply` tinyint(1) NOT NULL DEFAULT '1', + `privacy_pm` tinyint(1) NOT NULL DEFAULT '1', + `repliesview` tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`user_id`), + KEY `recommendations` (`recommendations`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `users` +-- + +DROP TABLE IF EXISTS `users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `users` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `nick` char(64) NOT NULL, + `passw` char(32) NOT NULL, + `lang` enum('en','ru','fr','fa','__') NOT NULL DEFAULT '__', + `banned` tinyint(3) unsigned NOT NULL DEFAULT '0', + `lastmessage` int(11) NOT NULL DEFAULT '0', + `lastpm` int(11) NOT NULL DEFAULT '0', + `lastphoto` int(11) NOT NULL DEFAULT '0', + `karma` smallint(6) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `nick` (`nick`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `users_refs` +-- + +DROP TABLE IF EXISTS `users_refs`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `users_refs` ( + `user_id` int(10) unsigned NOT NULL, + `ref` int(10) unsigned NOT NULL, + KEY `ref` (`ref`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `users_subscr` +-- + +DROP TABLE IF EXISTS `users_subscr`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `users_subscr` ( + `user_id` int(10) unsigned NOT NULL, + `cnt` smallint(5) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `usersinfo` +-- + +DROP TABLE IF EXISTS `usersinfo`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `usersinfo` ( + `user_id` int(10) unsigned NOT NULL, + `jid` char(32) DEFAULT NULL, + `fullname` char(32) DEFAULT NULL, + `country` char(32) DEFAULT NULL, + `url` char(64) DEFAULT NULL, + `gender` char(32) DEFAULT NULL, + `bday` char(10) DEFAULT NULL, + `descr` varchar(255) DEFAULT NULL, + PRIMARY KEY (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `version` +-- + +DROP TABLE IF EXISTS `version`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `version` ( + `version` bigint(20) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `vk` +-- + +DROP TABLE IF EXISTS `vk`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `vk` ( + `user_id` int(10) unsigned DEFAULT NULL, + `vk_id` bigint(20) NOT NULL, + `loginhash` char(36) DEFAULT NULL, + `access_token` char(128) NOT NULL, + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `vk_name` char(64) NOT NULL, + `vk_link` char(64) NOT NULL, + `crosspost` tinyint(3) unsigned NOT NULL DEFAULT '1', + KEY `user_id` (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `winphone` +-- + +DROP TABLE IF EXISTS `winphone`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `winphone` ( + `user_id` int(10) unsigned NOT NULL, + `url` char(255) NOT NULL, + `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + UNIQUE KEY `url` (`url`), + KEY `user_id` (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `wl_users` +-- + +DROP TABLE IF EXISTS `wl_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `wl_users` ( + `user_id` int(10) unsigned NOT NULL, + `wl_user_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`user_id`,`wl_user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2018-01-12 6:45:30 diff --git a/juick-server-core/src/main/resources/schema.sql b/juick-server-core/src/main/resources/schema.sql deleted file mode 100644 index 518c89ab..00000000 --- a/juick-server-core/src/main/resources/schema.sql +++ /dev/null @@ -1,915 +0,0 @@ --- MySQL dump 10.16 Distrib 10.1.26-MariaDB, for debian-linux-gnu (x86_64) --- --- Host: localhost Database: juick --- ------------------------------------------------------ -use juick; --- Server version 10.1.26-MariaDB-0+deb9u1 -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `ads_messages` --- - -DROP TABLE IF EXISTS `ads_messages`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `ads_messages` ( - `message_id` int(10) unsigned NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `ads_messages_log` --- - -DROP TABLE IF EXISTS `ads_messages_log`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `ads_messages_log` ( - `user_id` int(10) unsigned NOT NULL, - `message_id` int(10) unsigned NOT NULL, - `ts` int(10) unsigned NOT NULL DEFAULT '0' -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `android` --- - -DROP TABLE IF EXISTS `android`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `android` ( - `user_id` int(10) unsigned NOT NULL, - `regid` char(255) NOT NULL, - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - UNIQUE KEY `regid` (`regid`), - KEY `user_id` (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `auth` --- - -DROP TABLE IF EXISTS `auth`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `auth` ( - `user_id` int(10) unsigned NOT NULL, - `protocol` enum('xmpp','email','sms') NOT NULL, - `account` char(64) NOT NULL, - `authcode` char(8) NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `bl_tags` --- - -DROP TABLE IF EXISTS `bl_tags`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `bl_tags` ( - `user_id` int(10) unsigned NOT NULL, - `tag_id` int(10) unsigned NOT NULL, - KEY `tag_id` (`tag_id`), - KEY `user_id` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `bl_users` --- - -DROP TABLE IF EXISTS `bl_users`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `bl_users` ( - `user_id` int(10) unsigned NOT NULL, - `bl_user_id` int(10) unsigned NOT NULL, - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`user_id`,`bl_user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `captcha` --- - -DROP TABLE IF EXISTS `captcha`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `captcha` ( - `jid` char(64) NOT NULL, - `hash` char(16) NOT NULL, - `confirmed` tinyint(4) NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `captchaimg` --- - -DROP TABLE IF EXISTS `captchaimg`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `captchaimg` ( - `id` char(16) NOT NULL, - `txt` char(6) NOT NULL, - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `ip` char(16) NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `emails` --- - -DROP TABLE IF EXISTS `emails`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `emails` ( - `user_id` int(10) unsigned NOT NULL, - `email` char(64) NOT NULL, - `subscr_hour` tinyint(4) DEFAULT NULL, - KEY `email` (`email`) USING HASH -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `facebook` --- - -DROP TABLE IF EXISTS `facebook`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `facebook` ( - `user_id` int(10) unsigned DEFAULT NULL, - `fb_id` bigint(20) unsigned NOT NULL, - `loginhash` char(36) DEFAULT NULL, - `access_token` char(255) DEFAULT NULL, - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `fb_name` char(64) NOT NULL, - `fb_link` char(64) NOT NULL, - `crosspost` tinyint(1) unsigned NOT NULL DEFAULT '1', - KEY `user_id` (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `favorites` --- - -DROP TABLE IF EXISTS `favorites`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `favorites` ( - `user_id` int(10) unsigned NOT NULL, - `message_id` int(10) unsigned NOT NULL, - `ts` datetime NOT NULL, - UNIQUE KEY `user_id_2` (`user_id`,`message_id`), - KEY `user_id` (`user_id`), - KEY `message_id` (`message_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `friends_facebook` --- - -DROP TABLE IF EXISTS `friends_facebook`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `friends_facebook` ( - `user_id` int(10) unsigned NOT NULL, - `friend_id` bigint(20) unsigned NOT NULL, - UNIQUE KEY `user_id` (`user_id`,`friend_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `images` --- - -DROP TABLE IF EXISTS `images`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `images` ( - `mid` int(10) unsigned NOT NULL, - `rid` int(10) unsigned NOT NULL, - `thumb` int(10) unsigned NOT NULL, - `small` int(10) unsigned NOT NULL, - `medium` int(10) unsigned NOT NULL, - `height` int(10) unsigned NOT NULL, - `width` int(10) unsigned NOT NULL, - PRIMARY KEY (`mid`,`rid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `ios` --- - -DROP TABLE IF EXISTS `ios`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `ios` ( - `user_id` int(10) unsigned NOT NULL, - `token` char(64) COLLATE utf8mb4_unicode_ci NOT NULL, - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - UNIQUE KEY `token` (`token`), - KEY `user_id` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `jids` --- - -DROP TABLE IF EXISTS `jids`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `jids` ( - `user_id` int(10) unsigned DEFAULT NULL, - `jid` char(64) NOT NULL, - `active` tinyint(1) NOT NULL DEFAULT '1', - `loginhash` char(36) DEFAULT NULL, - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - UNIQUE KEY `jid` (`jid`), - KEY `user_id` (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `logins` --- - -DROP TABLE IF EXISTS `logins`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `logins` ( - `user_id` int(10) unsigned NOT NULL, - `hash` char(16) NOT NULL, - UNIQUE KEY `user_id` (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `mail` --- - -DROP TABLE IF EXISTS `mail`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `mail` ( - `user_id` int(10) unsigned NOT NULL, - `hash` char(16) NOT NULL, - PRIMARY KEY (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `meon` --- - -DROP TABLE IF EXISTS `meon`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `meon` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `user_id` int(10) unsigned NOT NULL, - `link` char(255) NOT NULL, - `name` char(32) NOT NULL, - `ico` smallint(5) unsigned DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `messages` --- - -DROP TABLE IF EXISTS `messages`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `messages` ( - `message_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `user_id` int(10) unsigned NOT NULL, - `lang` enum('en','ru','fr','fa','__') NOT NULL DEFAULT '__', - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `replies` smallint(5) unsigned NOT NULL DEFAULT '0', - `maxreplyid` smallint(5) unsigned NOT NULL DEFAULT '0', - `privacy` tinyint(4) NOT NULL DEFAULT '1', - `readonly` tinyint(1) NOT NULL DEFAULT '0', - `attach` enum('jpg','mp4','png') DEFAULT NULL, - `place_id` int(10) unsigned DEFAULT NULL, - `lat` decimal(10,7) DEFAULT NULL, - `lon` decimal(10,7) DEFAULT NULL, - `popular` tinyint(4) NOT NULL DEFAULT '0', - `hidden` tinyint(3) unsigned NOT NULL DEFAULT '0', - `likes` smallint(6) NOT NULL DEFAULT '0', - `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`message_id`), - KEY `user_id` (`user_id`), - KEY `ts` (`ts`), - KEY `attach` (`attach`), - KEY `place_id` (`place_id`), - KEY `popular` (`popular`), - KEY `hidden` (`hidden`), - KEY `updated_indx` (`updated`,`message_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `messages_access` --- - -DROP TABLE IF EXISTS `messages_access`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `messages_access` ( - `message_id` int(10) unsigned NOT NULL, - `user_id` int(10) unsigned NOT NULL, - KEY `message_id` (`message_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `messages_tags` --- - -DROP TABLE IF EXISTS `messages_tags`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `messages_tags` ( - `message_id` int(10) unsigned NOT NULL, - `tag_id` int(10) unsigned NOT NULL, - UNIQUE KEY `message_id_2` (`message_id`,`tag_id`), - KEY `message_id` (`message_id`), - KEY `tag_id` (`tag_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `messages_txt` --- - -DROP TABLE IF EXISTS `messages_txt`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `messages_txt` ( - `message_id` int(10) unsigned NOT NULL, - `tags` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `repliesby` varchar(96) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `txt` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, - PRIMARY KEY (`message_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `messages_votes` --- - -DROP TABLE IF EXISTS `messages_votes`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `messages_votes` ( - `message_id` int(10) unsigned NOT NULL, - `user_id` int(10) unsigned NOT NULL, - `vote` tinyint(4) NOT NULL DEFAULT '1', - UNIQUE KEY `message_id` (`message_id`,`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `messenger` --- - -DROP TABLE IF EXISTS `messenger`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `messenger` ( - `user_id` int(10) unsigned DEFAULT NULL, - `sender_id` bigint(20) NOT NULL, - `display_name` char(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `loginhash` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `places` --- - -DROP TABLE IF EXISTS `places`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `places` ( - `place_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `lat` decimal(10,7) NOT NULL, - `lon` decimal(10,7) NOT NULL, - `name` char(64) NOT NULL, - `descr` char(255) DEFAULT NULL, - `url` char(128) DEFAULT NULL, - `user_id` int(10) unsigned NOT NULL, - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`place_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `places_tags` --- - -DROP TABLE IF EXISTS `places_tags`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `places_tags` ( - `place_id` int(10) unsigned NOT NULL, - `tag_id` int(10) unsigned NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `pm` --- - -DROP TABLE IF EXISTS `pm`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `pm` ( - `user_id` int(10) unsigned NOT NULL, - `user_id_to` int(10) unsigned NOT NULL, - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `txt` text NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `pm_inroster` --- - -DROP TABLE IF EXISTS `pm_inroster`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `pm_inroster` ( - `user_id` int(10) unsigned NOT NULL, - `jid` char(64) NOT NULL, - UNIQUE KEY `user_id_2` (`user_id`,`jid`), - KEY `user_id` (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `pm_streams` --- - -DROP TABLE IF EXISTS `pm_streams`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `pm_streams` ( - `user_id` int(10) unsigned NOT NULL, - `user_id_to` int(10) unsigned NOT NULL, - `lastmessage` datetime NOT NULL, - `lastview` datetime DEFAULT NULL, - `unread` smallint(5) unsigned NOT NULL DEFAULT '0', - UNIQUE KEY `user_id` (`user_id`,`user_id_to`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `presence` --- - -DROP TABLE IF EXISTS `presence`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `presence` ( - `user_id` int(10) unsigned NOT NULL, - `jid` char(64) DEFAULT NULL, - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - UNIQUE KEY `jid` (`jid`) -) ENGINE=MEMORY DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `reader_links` --- - -DROP TABLE IF EXISTS `reader_links`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `reader_links` ( - `link_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `rss_id` int(10) unsigned NOT NULL, - `url` char(255) NOT NULL, - `title` char(255) NOT NULL, - `ts` datetime NOT NULL, - PRIMARY KEY (`link_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `reader_rss` --- - -DROP TABLE IF EXISTS `reader_rss`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `reader_rss` ( - `rss_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `url` char(255) NOT NULL, - `lastcheck` datetime NOT NULL, - PRIMARY KEY (`rss_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `replies` --- - -DROP TABLE IF EXISTS `replies`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `replies` ( - `message_id` int(10) unsigned NOT NULL, - `reply_id` smallint(5) unsigned NOT NULL, - `user_id` int(10) unsigned NOT NULL, - `replyto` smallint(5) unsigned NOT NULL DEFAULT '0', - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `attach` enum('jpg','mp4','png') COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `txt` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, - KEY `message_id` (`message_id`), - KEY `user_id` (`user_id`), - KEY `ts` (`ts`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `sphinx` --- - -DROP TABLE IF EXISTS `sphinx`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sphinx` ( - `counter_id` tinyint(3) unsigned NOT NULL, - `max_id` int(10) unsigned NOT NULL, - PRIMARY KEY (`counter_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `subscr_messages` --- - -DROP TABLE IF EXISTS `subscr_messages`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `subscr_messages` ( - `message_id` int(10) unsigned NOT NULL, - `suser_id` int(10) unsigned NOT NULL, - UNIQUE KEY `message_id` (`message_id`,`suser_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `subscr_tags` --- - -DROP TABLE IF EXISTS `subscr_tags`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `subscr_tags` ( - `tag_id` int(10) unsigned NOT NULL, - `suser_id` int(10) unsigned NOT NULL, - `jid` char(64) NOT NULL, - `active` bit(1) NOT NULL DEFAULT b'1', - UNIQUE KEY `tag_id` (`tag_id`,`suser_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `subscr_users` --- - -DROP TABLE IF EXISTS `subscr_users`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `subscr_users` ( - `user_id` int(10) unsigned NOT NULL, - `suser_id` int(10) unsigned NOT NULL, - `jid` char(64) DEFAULT NULL, - `active` bit(1) NOT NULL DEFAULT b'1', - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - UNIQUE KEY `user_id` (`user_id`,`suser_id`), - KEY `suser_id` (`suser_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `tags` --- - -DROP TABLE IF EXISTS `tags`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tags` ( - `tag_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `synonym_id` int(10) unsigned DEFAULT NULL, - `name` char(70) CHARACTER SET utf8mb4 DEFAULT NULL, - `top` tinyint(1) unsigned NOT NULL DEFAULT '0', - `noindex` tinyint(1) unsigned NOT NULL DEFAULT '0', - `stat_messages` int(10) unsigned NOT NULL DEFAULT '0', - `stat_users` smallint(5) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`tag_id`), - KEY `synonym_id` (`synonym_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `tags_ignore` --- - -DROP TABLE IF EXISTS `tags_ignore`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tags_ignore` ( - `tag_id` int(10) unsigned NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `tags_synonyms` --- - -DROP TABLE IF EXISTS `tags_synonyms`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tags_synonyms` ( - `name` char(64) NOT NULL, - `changeto` char(64) NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `telegram` --- - -DROP TABLE IF EXISTS `telegram`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `telegram` ( - `user_id` int(10) unsigned DEFAULT NULL, - `tg_id` bigint(20) NOT NULL, - `tg_name` char(64) COLLATE utf8mb4_unicode_ci NOT NULL, - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `loginhash` char(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `telegram_chats` --- - -DROP TABLE IF EXISTS `telegram_chats`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `telegram_chats` ( - `chat_id` bigint(20) DEFAULT NULL, - UNIQUE KEY `chat_id` (`chat_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `top_ignore_messages` --- - -DROP TABLE IF EXISTS `top_ignore_messages`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `top_ignore_messages` ( - `message_id` int(10) unsigned NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `top_ignore_tags` --- - -DROP TABLE IF EXISTS `top_ignore_tags`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `top_ignore_tags` ( - `tag_id` int(10) unsigned NOT NULL, - PRIMARY KEY (`tag_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `top_ignore_users` --- - -DROP TABLE IF EXISTS `top_ignore_users`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `top_ignore_users` ( - `user_id` int(10) unsigned NOT NULL, - PRIMARY KEY (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `twitter` --- - -DROP TABLE IF EXISTS `twitter`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `twitter` ( - `user_id` int(10) unsigned NOT NULL, - `access_token` char(64) NOT NULL, - `access_token_secret` char(64) NOT NULL, - `uname` char(64) NOT NULL, - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `crosspost` tinyint(1) unsigned NOT NULL DEFAULT '1', - PRIMARY KEY (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `useroptions` --- - -DROP TABLE IF EXISTS `useroptions`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `useroptions` ( - `user_id` int(10) unsigned NOT NULL, - `jnotify` tinyint(1) NOT NULL DEFAULT '1', - `subscr_active` tinyint(1) NOT NULL DEFAULT '1', - `off_ts` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `xmppxhtml` tinyint(1) NOT NULL DEFAULT '0', - `subscr_notify` tinyint(1) NOT NULL DEFAULT '1', - `recommendations` tinyint(1) NOT NULL DEFAULT '1', - `privacy_view` tinyint(1) NOT NULL DEFAULT '1', - `privacy_reply` tinyint(1) NOT NULL DEFAULT '1', - `privacy_pm` tinyint(1) NOT NULL DEFAULT '1', - `repliesview` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`user_id`), - KEY `recommendations` (`recommendations`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `users` --- - -DROP TABLE IF EXISTS `users`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `users` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `nick` char(64) NOT NULL, - `passw` char(32) NOT NULL, - `lang` enum('en','ru','fr','fa','__') NOT NULL DEFAULT '__', - `banned` tinyint(3) unsigned NOT NULL DEFAULT '0', - `lastmessage` int(11) NOT NULL DEFAULT '0', - `lastpm` int(11) NOT NULL DEFAULT '0', - `lastphoto` int(11) NOT NULL DEFAULT '0', - `karma` smallint(6) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`), - UNIQUE KEY `nick` (`nick`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `users_refs` --- - -DROP TABLE IF EXISTS `users_refs`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `users_refs` ( - `user_id` int(10) unsigned NOT NULL, - `ref` int(10) unsigned NOT NULL, - KEY `ref` (`ref`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `users_subscr` --- - -DROP TABLE IF EXISTS `users_subscr`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `users_subscr` ( - `user_id` int(10) unsigned NOT NULL, - `cnt` smallint(5) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `usersinfo` --- - -DROP TABLE IF EXISTS `usersinfo`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `usersinfo` ( - `user_id` int(10) unsigned NOT NULL, - `jid` char(32) DEFAULT NULL, - `fullname` char(32) DEFAULT NULL, - `country` char(32) DEFAULT NULL, - `url` char(64) DEFAULT NULL, - `gender` char(32) DEFAULT NULL, - `bday` char(10) DEFAULT NULL, - `descr` varchar(255) DEFAULT NULL, - PRIMARY KEY (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `version` --- - -DROP TABLE IF EXISTS `version`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `version` ( - `version` bigint(20) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `vk` --- - -DROP TABLE IF EXISTS `vk`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `vk` ( - `user_id` int(10) unsigned DEFAULT NULL, - `vk_id` bigint(20) NOT NULL, - `loginhash` char(36) DEFAULT NULL, - `access_token` char(128) NOT NULL, - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `vk_name` char(64) NOT NULL, - `vk_link` char(64) NOT NULL, - `crosspost` tinyint(3) unsigned NOT NULL DEFAULT '1', - KEY `user_id` (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `winphone` --- - -DROP TABLE IF EXISTS `winphone`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `winphone` ( - `user_id` int(10) unsigned NOT NULL, - `url` char(255) NOT NULL, - `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - UNIQUE KEY `url` (`url`), - KEY `user_id` (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `wl_users` --- - -DROP TABLE IF EXISTS `wl_users`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `wl_users` ( - `user_id` int(10) unsigned NOT NULL, - `wl_user_id` int(10) unsigned NOT NULL, - PRIMARY KEY (`user_id`,`wl_user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2018-01-12 6:45:30 diff --git a/juick-server-jdbc/build.gradle b/juick-server-jdbc/build.gradle index 76a37e4b..f17398b6 100644 --- a/juick-server-jdbc/build.gradle +++ b/juick-server-jdbc/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'java' -apply plugin: 'war' +apply plugin: 'io.spring.dependency-management' sourceCompatibility = 1.8 @@ -12,42 +12,43 @@ dependencies { compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${rootProject.jacksonVersion}" compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${rootProject.jacksonVersion}" - providedCompile "ch.qos.logback:logback-classic:${rootProject.logbackVersion}" - providedCompile "ch.qos.logback:logback-core:${rootProject.logbackVersion}" - providedCompile "ch.qos.logback:logback-access:${rootProject.logbackVersion}" + compile "ch.qos.logback:logback-classic:${rootProject.logbackVersion}" + compile "ch.qos.logback:logback-core:${rootProject.logbackVersion}" + compile "ch.qos.logback:logback-access:${rootProject.logbackVersion}" - providedCompile "org.slf4j:slf4j-api:${rootProject.slf4jVersion}" - providedCompile "org.slf4j:jcl-over-slf4j:${rootProject.slf4jVersion}" - providedCompile "org.slf4j:log4j-over-slf4j:${rootProject.slf4jVersion}" - providedCompile "org.slf4j:jul-to-slf4j:${rootProject.slf4jVersion}" + compile "org.slf4j:slf4j-api:${rootProject.slf4jVersion}" + compile "org.slf4j:jcl-over-slf4j:${rootProject.slf4jVersion}" + compile "org.slf4j:log4j-over-slf4j:${rootProject.slf4jVersion}" + compile "org.slf4j:jul-to-slf4j:${rootProject.slf4jVersion}" - providedCompile "org.apache.commons:commons-lang3:3.7" - providedCompile "org.apache.commons:commons-collections4:4.1" + compile "org.apache.commons:commons-lang3:3.7" + compile "org.apache.commons:commons-collections4:4.1" - compile "org.springframework:spring-context:${rootProject.springFrameworkVersion}" - compile "org.springframework:spring-jdbc:${rootProject.springFrameworkVersion}" + compile("org.springframework.boot:spring-boot-starter-jdbc") - providedCompile "org.apache.commons:commons-dbcp2:2.2.0" + compile "org.apache.commons:commons-dbcp2:2.2.0" compile "com.googlecode.log4jdbc:log4jdbc:1.2" compile "javax.inject:javax.inject:1" compile 'org.imgscalr:imgscalr-lib:4.2' - providedCompile 'com.h2database:h2:1.4.196' - providedCompile "javax.servlet:javax.servlet-api:3.1.0" - providedRuntime 'mysql:mysql-connector-java:5.1.40' + compile 'com.h2database:h2:1.4.196' + runtime 'mysql:mysql-connector-java:5.1.40' - providedRuntime "commons-fileupload:commons-fileupload:1.3.3" + runtime "commons-fileupload:commons-fileupload:1.3.3" testCompile project(path: ':juick-core', configuration: 'testArtifacts') testCompile "junit:junit:${rootProject.junitVersion}" testCompile "org.hamcrest:hamcrest-all:${rootProject.hamcrestVersion}" testCompile "org.mockito:mockito-core:${rootProject.mockitoVersion}" - testCompile "org.springframework:spring-test:${rootProject.springFrameworkVersion}" + testCompile("org.springframework.boot:spring-boot-starter-test") testRuntime "mysql:mysql-connector-java:5.1.40" testRuntime "org.postgresql:postgresql:42.2.1" } +dependencyManagement { + imports { mavenBom("org.springframework.boot:spring-boot-dependencies:${rootProject.springBootVersion}") } +} compileJava.options.encoding = 'UTF-8' diff --git a/juick-server-jdbc/src/main/java/com/juick/configuration/DataConfiguration.java b/juick-server-jdbc/src/main/java/com/juick/configuration/DataConfiguration.java index 2073c3c0..ee9d0baa 100644 --- a/juick-server-jdbc/src/main/java/com/juick/configuration/DataConfiguration.java +++ b/juick-server-jdbc/src/main/java/com/juick/configuration/DataConfiguration.java @@ -23,8 +23,8 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; +import org.springframework.dao.DuplicateKeyException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.transaction.PlatformTransactionManager; @@ -40,7 +40,6 @@ import java.util.List; */ @Configuration @EnableTransactionManagement -@PropertySource(value = {"classpath:juick.conf"}, ignoreResourceNotFound = true) @ComponentScan(basePackages = {"com.juick.service"}) public class DataConfiguration implements TransactionManagementConfigurer { @Value("${datasource_driver:org.h2.Driver}") @@ -246,18 +245,18 @@ public class DataConfiguration implements TransactionManagementConfigurer { " `cnt` smallint(5) unsigned NOT NULL DEFAULT '0'," + " PRIMARY KEY (`user_id`)" + ")"); - jdbcTemplate.execute("CREATE TABLE `auth` (" + + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS `auth` (" + " `user_id` int(10) unsigned NOT NULL," + " `protocol` enum('xmpp','email','sms') NOT NULL," + " `account` char(64) NOT NULL," + " `authcode` char(8) NOT NULL" + ")"); - jdbcTemplate.execute("CREATE TABLE `mail` (" + + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS `mail` (" + " `user_id` int(10) unsigned NOT NULL," + " `hash` char(16) NOT NULL," + " PRIMARY KEY (`user_id`)" + ")"); - jdbcTemplate.execute("CREATE TABLE `usersinfo` (" + + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS `usersinfo` (" + " `user_id` int(10) unsigned NOT NULL," + " `jid` char(32) DEFAULT NULL," + " `fullname` char(32) DEFAULT NULL," + diff --git a/juick-server-jdbc/src/test/java/com/juick/configuration/RepositoryConfiguration.java b/juick-server-jdbc/src/test/java/com/juick/configuration/RepositoryConfiguration.java index eac98354..4541da94 100644 --- a/juick-server-jdbc/src/test/java/com/juick/configuration/RepositoryConfiguration.java +++ b/juick-server-jdbc/src/test/java/com/juick/configuration/RepositoryConfiguration.java @@ -19,23 +19,13 @@ package com.juick.configuration; import com.juick.service.ImagesService; import com.juick.service.MockImagesService; -import com.juick.service.search.SearchService; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.DependsOn; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.datasource.DriverManagerDataSource; - -import javax.sql.DataSource; -import java.util.Collections; -import java.util.List; /** * Created by aalexeev on 11/25/16. */ @Configuration -@ComponentScan(basePackages = "com.juick.service") public class RepositoryConfiguration { @Bean public ImagesService imagesService() { diff --git a/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java b/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java index d9f095ac..b082bfd1 100644 --- a/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java +++ b/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java @@ -26,18 +26,17 @@ import com.juick.server.helpers.AnonymousUser; import com.juick.server.helpers.TagStats; import com.juick.util.MessageUtils; import org.apache.commons.lang3.StringUtils; -import org.junit.*; +import org.junit.Before; +import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import javax.inject.Inject; import java.sql.Timestamp; import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -50,7 +49,7 @@ import static org.junit.Assert.assertEquals; /** * Created by aalexeev on 11/25/16. */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @ContextConfiguration(classes = { DataConfiguration.class, RepositoryConfiguration.class }) public class MessageServiceTest extends AbstractJUnit4SpringContextTests { @Inject diff --git a/juick-server-web/build.gradle b/juick-server-web/build.gradle index 9a5e97a9..0cf63313 100644 --- a/juick-server-web/build.gradle +++ b/juick-server-web/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'java' -apply plugin: 'war' +apply plugin: 'io.spring.dependency-management' sourceCompatibility = 1.8 @@ -11,38 +11,41 @@ dependencies { compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${rootProject.jacksonVersion}" compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${rootProject.jacksonVersion}" - providedCompile "ch.qos.logback:logback-classic:${rootProject.logbackVersion}" - providedCompile "ch.qos.logback:logback-core:${rootProject.logbackVersion}" - providedCompile "ch.qos.logback:logback-access:${rootProject.logbackVersion}" + compile "ch.qos.logback:logback-classic:${rootProject.logbackVersion}" + compile "ch.qos.logback:logback-core:${rootProject.logbackVersion}" + compile "ch.qos.logback:logback-access:${rootProject.logbackVersion}" - providedCompile "org.slf4j:slf4j-api:${rootProject.slf4jVersion}" - providedCompile "org.slf4j:jcl-over-slf4j:${rootProject.slf4jVersion}" - providedCompile "org.slf4j:log4j-over-slf4j:${rootProject.slf4jVersion}" - providedCompile "org.slf4j:jul-to-slf4j:${rootProject.slf4jVersion}" + compile "org.slf4j:slf4j-api:${rootProject.slf4jVersion}" + compile "org.slf4j:jcl-over-slf4j:${rootProject.slf4jVersion}" + compile "org.slf4j:log4j-over-slf4j:${rootProject.slf4jVersion}" + compile "org.slf4j:jul-to-slf4j:${rootProject.slf4jVersion}" compile 'com.github.ben-manes.caffeine:caffeine:2.6.2' - - compile "org.springframework:spring-webmvc:${rootProject.springFrameworkVersion}" - compile "org.springframework:spring-context-support:${rootProject.springFrameworkVersion}" - compile "org.springframework:spring-websocket:${rootProject.springFrameworkVersion}" - - compile "org.springframework.security:spring-security-web:${rootProject.springSecurityVersion}" - compile "org.springframework.security:spring-security-config:${rootProject.springSecurityVersion}" + compile("org.springframework.boot:spring-boot-starter-cache") + compile("org.springframework.boot:spring-boot-starter-web") + compile("org.springframework.boot:spring-boot-starter-websocket") + compile("org.springframework.boot:spring-boot-starter-security") compile "javax.inject:javax.inject:1" compile 'org.imgscalr:imgscalr-lib:4.2' compile "org.apache.commons:commons-imaging:1.0-SNAPSHOT" - providedCompile "javax.servlet:javax.servlet-api:3.1.0" + runtime "commons-fileupload:commons-fileupload:1.3.3" - providedRuntime "commons-fileupload:commons-fileupload:1.3.3" + compile ('com.github.juick:com.juick.xmpp:658f8cf751') { + exclude group: 'xmlpull' + } + compile 'xpp3:xpp3:1.1.4c' testCompile "junit:junit:${rootProject.junitVersion}" testCompile "org.hamcrest:hamcrest-all:${rootProject.hamcrestVersion}" testCompile "org.mockito:mockito-core:${rootProject.mockitoVersion}" - testCompile "org.springframework:spring-test:${rootProject.springFrameworkVersion}" - testCompile "org.springframework.security:spring-security-test:${rootProject.springSecurityVersion}" + testCompile "org.springframework.boot:spring-boot-starter-test" + testCompile "org.springframework.security:spring-security-test" +} +dependencyManagement { + imports { mavenBom("org.springframework.boot:spring-boot-dependencies:${rootProject.springBootVersion}") } } compileJava.options.encoding = 'UTF-8' diff --git a/juick-server-web/src/main/java/com/juick/server/configuration/BaseWebConfiguration.java b/juick-server-web/src/main/java/com/juick/server/configuration/BaseWebConfiguration.java index 3ceee3eb..d9b842af 100644 --- a/juick-server-web/src/main/java/com/juick/server/configuration/BaseWebConfiguration.java +++ b/juick-server-web/src/main/java/com/juick/server/configuration/BaseWebConfiguration.java @@ -21,8 +21,13 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.juick.server.xmpp.JidConverter; +import com.juick.server.xmpp.s2s.BasicXmppSession; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.convert.ConversionService; +import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.scheduling.annotation.SchedulingConfigurer; @@ -31,9 +36,13 @@ import org.springframework.web.multipart.MultipartResolver; import org.springframework.web.multipart.commons.CommonsMultipartResolver; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import rocks.xmpp.core.session.Extension; +import rocks.xmpp.core.session.XmppSessionConfiguration; +import rocks.xmpp.core.session.debug.LogbackDebugger; import java.util.List; import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; /** @@ -81,4 +90,25 @@ public class BaseWebConfiguration implements WebMvcConfigurer, SchedulingConfigu public Executor taskExecutor() { return Executors.newScheduledThreadPool(100); } + @Value("${hostname:localhost}") + private String hostname; + + @Bean + public ExecutorService service() { + return Executors.newCachedThreadPool(); + } + @Bean + public BasicXmppSession session() { + XmppSessionConfiguration configuration = XmppSessionConfiguration.builder() + .extensions(Extension.of(com.juick.Message.class)) + .debugger(LogbackDebugger.class) + .build(); + return BasicXmppSession.create(hostname, configuration); + } + @Bean + public static ConversionService conversionService() { + DefaultFormattingConversionService cs = new DefaultFormattingConversionService(); + cs.addConverter(new JidConverter()); + return cs; + } } diff --git a/juick-server-web/src/main/java/com/juick/server/xmpp/JidConverter.java b/juick-server-web/src/main/java/com/juick/server/xmpp/JidConverter.java new file mode 100644 index 00000000..e9a9707e --- /dev/null +++ b/juick-server-web/src/main/java/com/juick/server/xmpp/JidConverter.java @@ -0,0 +1,13 @@ +package com.juick.server.xmpp; + +import org.springframework.core.convert.converter.Converter; +import org.springframework.lang.Nullable; +import rocks.xmpp.addr.Jid; + +public class JidConverter implements Converter { + @Nullable + @Override + public Jid convert(String jidStr) { + return Jid.of(jidStr); + } +} diff --git a/juick-server-web/src/main/java/com/juick/server/xmpp/extensions/JuickMessage.java b/juick-server-web/src/main/java/com/juick/server/xmpp/extensions/JuickMessage.java new file mode 100644 index 00000000..6956a99a --- /dev/null +++ b/juick-server-web/src/main/java/com/juick/server/xmpp/extensions/JuickMessage.java @@ -0,0 +1,162 @@ +/* + * Juick + * Copyright (C) 2008-2011, Ugnich Anton + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package com.juick.server.xmpp.extensions; + +import com.juick.Tag; +import com.juick.xmpp.StanzaChild; +import com.juick.xmpp.utils.XmlUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.text.StringEscapeUtils; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +/** + * + * @author Ugnich Anton + */ +public class JuickMessage extends com.juick.Message implements StanzaChild { + public final static String XMLNS = "http://juick.com/message"; + public final static String TagName = "juick"; + private SimpleDateFormat df; + public JuickMessage() { + df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + df.setTimeZone(TimeZone.getTimeZone("UTC")); + } + + @Override + public String getXMLNS() { + return XMLNS; + } + @Override + public JuickMessage parse(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException { + JuickMessage jmsg = new JuickMessage(); + final String sMID = parser.getAttributeValue(null, "mid"); + if (sMID != null) { + jmsg.setMid(Integer.parseInt(sMID)); + } + final String sRID = parser.getAttributeValue(null, "rid"); + if (sRID != null) { + jmsg.setRid(Integer.parseInt(sRID)); + } + final String sReplyTo = parser.getAttributeValue(null, "replyto"); + if (sReplyTo != null) { + jmsg.setReplyto(Integer.parseInt(sReplyTo)); + } + final String sPrivacy = parser.getAttributeValue(null, "privacy"); + if (sPrivacy != null) { + jmsg.setPrivacy(Integer.parseInt(sPrivacy)); + } + final String sFriendsOnly = parser.getAttributeValue(null, "friendsonly"); + if (sFriendsOnly != null) { + jmsg.FriendsOnly = true; + } + final String sReadOnly = parser.getAttributeValue(null, "readonly"); + if (sReadOnly != null) { + jmsg.ReadOnly = true; + } + jmsg.setTimestamp(df.parse(parser.getAttributeValue(null, "ts")).toInstant()); + jmsg.setAttachmentType(parser.getAttributeValue(null, "attach")); + while (parser.next() == XmlPullParser.START_TAG) { + final String tag = parser.getName(); + final String xmlns = parser.getNamespace(); + if (tag.equals("body")) { + jmsg.setText(XmlUtils.getTagText(parser)); + } else if (tag.equals(JuickUser.TagName) && xmlns != null && xmlns.equals(JuickUser.XMLNS)) { + jmsg.setUser(new JuickUser().parse(parser)); + } else if (tag.equals("tag")) { + jmsg.getTags().add(new Tag(XmlUtils.getTagText(parser))); + } else { + XmlUtils.skip(parser); + } + } + return jmsg; + } + @Override + public String toString() { + StringBuilder ret = new StringBuilder("<").append(TagName).append(" xmlns=\"").append(XMLNS).append("\""); + if (getMid() > 0) { + ret.append(" mid=\"").append(getMid()).append("\""); + } + if (getRid() > 0) { + ret.append(" rid=\"").append(getRid()).append("\""); + } + if (getReplyto() > 0) { + ret.append(" replyto=\"").append(getReplyto()).append("\""); + } + ret.append(" privacy=\"").append(getPrivacy()).append("\""); + if (FriendsOnly) { + ret.append(" friendsonly=\"1\""); + } + if (ReadOnly) { + ret.append(" readonly=\"1\""); + } + if (getTimestamp() != null) { + ret.append(" ts=\"").append(df.format(Date.from(getTimestamp()))).append("\""); + } + if (getAttachmentType() != null) { + ret.append(" attach=\"").append(getAttachmentType()).append("\""); + } + ret.append(">"); + if (getUser() != null) { + ret.append(JuickUser.toString(getUser())); + } + if (getText() != null) { + ret.append("").append(StringEscapeUtils.escapeXml10(StringUtils.defaultString(getText()))).append(""); + } + for (Tag Tag : getTags()) { + ret.append("").append(StringEscapeUtils.escapeXml10(Tag.getName())).append(""); + } + ret.append(""); + return ret.toString(); + } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof JuickMessage)) { + return false; + } + JuickMessage jmsg = (JuickMessage) obj; + return (this.getMid() == jmsg.getMid() && this.getRid() == jmsg.getRid()); + } + @Override + public int compareTo(Object obj) throws ClassCastException { + if (!(obj instanceof JuickMessage)) { + throw new ClassCastException(); + } + JuickMessage jmsg = (JuickMessage) obj; + if (this.getMid() != jmsg.getMid()) { + if (this.getMid() > jmsg.getMid()) { + return -1; + } else { + return 1; + } + } + if (this.getRid() != jmsg.getRid()) { + if (this.getRid() < jmsg.getRid()) { + return -1; + } else { + return 1; + } + } + return 0; + } +} \ No newline at end of file diff --git a/juick-server-web/src/main/java/com/juick/server/xmpp/extensions/JuickUser.java b/juick-server-web/src/main/java/com/juick/server/xmpp/extensions/JuickUser.java new file mode 100644 index 00000000..534efcc9 --- /dev/null +++ b/juick-server-web/src/main/java/com/juick/server/xmpp/extensions/JuickUser.java @@ -0,0 +1,65 @@ +/* + * Juick + * Copyright (C) 2008-2011, Ugnich Anton + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package com.juick.server.xmpp.extensions; +import com.juick.xmpp.StanzaChild; +import com.juick.xmpp.utils.XmlUtils; +import org.apache.commons.text.StringEscapeUtils; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + +import java.io.IOException; +/** + * + * @author Ugnich Anton + */ +public class JuickUser extends com.juick.User implements StanzaChild { + public final static String XMLNS = "http://juick.com/user"; + public final static String TagName = "user"; + public JuickUser() { + } + @Override + public String getXMLNS() { + return XMLNS; + } + @Override + public JuickUser parse(final XmlPullParser parser) throws XmlPullParserException, IOException { + JuickUser juser = new JuickUser(); + String strUID = parser.getAttributeValue(null, "uid"); + if (strUID != null) { + juser.setUid(Integer.parseInt(strUID)); + } + juser.setName(parser.getAttributeValue(null, "uname")); + XmlUtils.skip(parser); + return juser; + } + public static String toString(com.juick.User user) { + String str = "<" + TagName + " xmlns='" + XMLNS + "'"; + if (user.getUid() > 0) { + str += " uid='" + user.getUid() + "'"; + } + if (user.getName() != null && user.getName().length() > 0) { + str += " uname='" + StringEscapeUtils.escapeXml10(user.getName()) + "'"; + } + str += "/>"; + return str; + } + @Override + public String toString() { + return toString(this); + } +} \ No newline at end of file diff --git a/juick-server-web/src/main/java/com/juick/server/xmpp/s2s/BasicXmppSession.java b/juick-server-web/src/main/java/com/juick/server/xmpp/s2s/BasicXmppSession.java new file mode 100644 index 00000000..647f2717 --- /dev/null +++ b/juick-server-web/src/main/java/com/juick/server/xmpp/s2s/BasicXmppSession.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2008-2017, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.juick.server.xmpp.s2s; + +import rocks.xmpp.addr.Jid; +import rocks.xmpp.core.XmppException; +import rocks.xmpp.core.session.ConnectionConfiguration; +import rocks.xmpp.core.session.XmppSession; +import rocks.xmpp.core.session.XmppSessionConfiguration; +import rocks.xmpp.core.stanza.model.IQ; +import rocks.xmpp.core.stanza.model.Message; +import rocks.xmpp.core.stanza.model.Presence; +import rocks.xmpp.core.stanza.model.server.ServerIQ; +import rocks.xmpp.core.stanza.model.server.ServerMessage; +import rocks.xmpp.core.stanza.model.server.ServerPresence; +import rocks.xmpp.core.stream.model.StreamElement; + +/** + * Created by vitalyster on 06.02.2017. + */ +public class BasicXmppSession extends XmppSession { + protected BasicXmppSession(String xmppServiceDomain, XmppSessionConfiguration configuration, ConnectionConfiguration... connectionConfigurations) { + super(xmppServiceDomain, configuration, connectionConfigurations); + } + + public static BasicXmppSession create(String xmppServiceDomain, XmppSessionConfiguration configuration) { + BasicXmppSession session = new BasicXmppSession(xmppServiceDomain, configuration); + notifyCreationListeners(session); + return session; + } + + @Override + public void connect(Jid from) throws XmppException { + + } + + @Override + public Jid getConnectedResource() { + return null; + } + + @Override + protected StreamElement prepareElement(StreamElement element) { + if (element instanceof Message) { + element = ServerMessage.from((Message) element); + } else if (element instanceof Presence) { + element = ServerPresence.from((Presence) element); + } else if (element instanceof IQ) { + element = ServerIQ.from((IQ) element); + } + + return element; + } +} diff --git a/juick-server-web/src/main/java/com/juick/service/security/NotAuthorizedAuthenticationEntryPoint.java b/juick-server-web/src/main/java/com/juick/service/security/NotAuthorizedAuthenticationEntryPoint.java index 133ec3e5..b9bdcaa9 100644 --- a/juick-server-web/src/main/java/com/juick/service/security/NotAuthorizedAuthenticationEntryPoint.java +++ b/juick-server-web/src/main/java/com/juick/service/security/NotAuthorizedAuthenticationEntryPoint.java @@ -30,8 +30,7 @@ import java.io.IOException; */ public class NotAuthorizedAuthenticationEntryPoint implements AuthenticationEntryPoint { @Override - public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) - throws IOException, ServletException { + public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) { response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); } } diff --git a/juick-server/build.gradle b/juick-server/build.gradle index 06d28474..bcad2f41 100644 --- a/juick-server/build.gradle +++ b/juick-server/build.gradle @@ -6,11 +6,13 @@ buildscript { apply plugin: 'java' apply plugin: 'war' -apply plugin: 'org.akhikhl.gretty' +apply plugin: 'org.springframework.boot' +apply plugin: 'io.spring.dependency-management' dependencies { compile project(':juick-server-jdbc') compile project(':juick-server-web') + providedRuntime("org.springframework.boot:spring-boot-starter-tomcat") compile 'io.springfox:springfox-swagger2:2.8.0' compile 'io.springfox:springfox-swagger-ui:2.8.0' @@ -20,10 +22,7 @@ dependencies { compile 'org.springframework.social:spring-social-twitter:1.1.2.RELEASE' compile 'org.apache.commons:commons-email:1.5' compile 'org.imgscalr:imgscalr-lib:4.2' - compile ('com.github.juick:com.juick.xmpp:658f8cf751') { - exclude group: 'xmlpull' - } - providedCompile 'xpp3:xpp3:1.1.4c' + compile 'com.rometools:rome:1.9.0' compile 'com.rometools:rome-modules:1.9.0' @@ -31,16 +30,13 @@ dependencies { testCompile project(path: ':juick-server-web', configuration: 'testArtifacts') testCompile project(path: ':juick-server-jdbc', configuration: 'testArtifacts') - testRuntime 'org.apache.tomcat.embed:tomcat-embed-websocket:9.0.5' testRuntime 'com.jayway.jsonpath:json-path:2.4.0' } compileJava.options.encoding = 'UTF-8' -gretty { - httpPort = 8080 - contextPath = '/' - servletContainer = 'tomcat8' +bootJar { + launchScript() } configurations { diff --git a/juick-server/src/main/java/com/juick/server/ApiServer.java b/juick-server/src/main/java/com/juick/server/ApiServer.java new file mode 100644 index 00000000..b2caff40 --- /dev/null +++ b/juick-server/src/main/java/com/juick/server/ApiServer.java @@ -0,0 +1,12 @@ +package com.juick.server; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ApiServer { + + public static void main(String[] args) { + SpringApplication.run(ApiServer.class, args); + } +} diff --git a/juick-server/src/main/java/com/juick/server/XMPPConnection.java b/juick-server/src/main/java/com/juick/server/XMPPConnection.java index ef0291c0..50c84bd6 100644 --- a/juick-server/src/main/java/com/juick/server/XMPPConnection.java +++ b/juick-server/src/main/java/com/juick/server/XMPPConnection.java @@ -89,6 +89,8 @@ public class XMPPConnection implements AutoCloseable { private int componentPort; @Value("${xmpp_password:secret}") private String password; + @Value("${xmpp_disabled:false}") + private boolean isXmppDisabled; @Value("${upload_tmp_dir:#{systemEnvironment['TEMP'] ?: '/tmp'}}") private String tmpDir; @@ -241,14 +243,16 @@ public class XMPPConnection implements AutoCloseable { logger.info("component connected"); } }); - service.submit(() -> { - try { - Thread.sleep(3000); - router.connect(); - } catch (InterruptedException | XmppException e) { - logger.warn("xmpp exception", e); - } - }); + if (!isXmppDisabled) { + service.submit(() -> { + try { + Thread.sleep(3000); + router.connect(); + } catch (InterruptedException | XmppException e) { + logger.warn("xmpp exception", e); + } + }); + } } String stanzaToString(Stanza stanza) throws XMLStreamException, JAXBException { diff --git a/juick-server/src/main/java/com/juick/server/api/Notifications.java b/juick-server/src/main/java/com/juick/server/api/Notifications.java index 5f849080..16601b7f 100644 --- a/juick-server/src/main/java/com/juick/server/api/Notifications.java +++ b/juick-server/src/main/java/com/juick/server/api/Notifications.java @@ -101,7 +101,7 @@ public class Notifications { @ApiIgnore @RequestMapping(value = "/notifications", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public Status doDelete( - @RequestBody List list) throws IOException { + @RequestBody List list) { User visitor = UserUtils.getCurrentUser(); // FIXME: it is possible to delete other user's tokens if ((visitor.getUid() == 0) || !(visitor.getName().equals("juick"))) { diff --git a/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java b/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java index 146e277c..65a9d410 100644 --- a/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java +++ b/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java @@ -17,18 +17,15 @@ package com.juick.server.configuration; +import com.juick.configuration.DataConfiguration; import com.juick.server.WebsocketManager; import com.juick.server.api.rss.MessagesView; import com.juick.server.api.rss.RepliesView; import com.juick.server.component.JuickServerComponent; import com.juick.server.component.JuickServerReconnectManager; import com.juick.service.UserService; -import com.juick.server.xmpp.helpers.JidConverter; -import com.juick.server.xmpp.s2s.BasicXmppSession; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.*; -import org.springframework.core.convert.ConversionService; -import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; @@ -43,9 +40,6 @@ import org.springframework.web.socket.config.annotation.WebSocketConfigurer; import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean; import org.springframework.web.util.UriComponentsBuilder; -import rocks.xmpp.core.session.Extension; -import rocks.xmpp.core.session.XmppSessionConfiguration; -import rocks.xmpp.core.session.debug.LogbackDebugger; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.service.ApiInfo; @@ -56,19 +50,16 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; import javax.annotation.Nonnull; import javax.inject.Inject; import java.util.Collections; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; /** * Created by aalexeev on 11/12/16. */ @Configuration @EnableAsync -@EnableWebMvc @EnableSwagger2 @EnableScheduling @EnableWebSocket -@PropertySource(value = "classpath:juick.conf", ignoreResourceNotFound = true) +@Import({ApiSecurityConfig.class, DataConfiguration.class, StorageConfiguration.class}) @ComponentScan(basePackages = "com.juick.server") public class ApiAppConfiguration extends BaseWebConfiguration implements WebSocketConfigurer { @Inject @@ -132,27 +123,6 @@ public class ApiAppConfiguration extends BaseWebConfiguration implements WebSock container.setMaxBinaryMessageBufferSize(8192); return container; } - @Value("${hostname:localhost}") - private String hostname; - - @Bean - public ExecutorService service() { - return Executors.newCachedThreadPool(); - } - @Bean - public BasicXmppSession session() { - XmppSessionConfiguration configuration = XmppSessionConfiguration.builder() - .extensions(Extension.of(com.juick.Message.class)) - .debugger(LogbackDebugger.class) - .build(); - return BasicXmppSession.create(hostname, configuration); - } - @Bean - public static ConversionService conversionService() { - DefaultFormattingConversionService cs = new DefaultFormattingConversionService(); - cs.addConverter(new JidConverter()); - return cs; - } @Bean public BeanNameViewResolver beanNameViewResolver() { return new BeanNameViewResolver(); diff --git a/juick-server/src/main/java/com/juick/server/configuration/ApiInitializer.java b/juick-server/src/main/java/com/juick/server/configuration/ApiInitializer.java deleted file mode 100644 index b789fc50..00000000 --- a/juick-server/src/main/java/com/juick/server/configuration/ApiInitializer.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2008-2017, Juick - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.juick.server.configuration; - -import com.juick.configuration.DataConfiguration; -import org.apache.commons.codec.CharEncoding; -import org.springframework.web.filter.CharacterEncodingFilter; -import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; - -import javax.annotation.Nonnull; -import javax.servlet.Filter; - -/** - * Created by vt on 09/02/16. - */ -public class ApiInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { - - @Override - protected Class[] getRootConfigClasses() { - return new Class[]{ - ApiAppConfiguration.class, - ApiSecurityConfig.class, - DataConfiguration.class, - StorageConfiguration.class - }; - } - - @Override - protected Class[] getServletConfigClasses() { - return null; - } - - @Override - @Nonnull - protected String[] getServletMappings() { - return new String[]{"/"}; - } - - @Override - protected Filter[] getServletFilters() { - return new Filter[]{new CharacterEncodingFilter(CharEncoding.UTF_8)}; - } - - @Override - @Nonnull - protected String getServletName() { - return "API dispatcher servlet"; - } -} diff --git a/juick-server/src/main/java/com/juick/server/configuration/ApiSecurityInitializer.java b/juick-server/src/main/java/com/juick/server/configuration/ApiSecurityInitializer.java deleted file mode 100644 index ece023fc..00000000 --- a/juick-server/src/main/java/com/juick/server/configuration/ApiSecurityInitializer.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2008-2017, Juick - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.juick.server.configuration; - -/** - * - * Created by vitalyster on 25.11.2016. - * - - */ - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer; - -import javax.servlet.ServletContext; - -public class ApiSecurityInitializer extends AbstractSecurityWebApplicationInitializer { - private final Logger logger = LoggerFactory.getLogger(getClass()); - - @Override - protected void afterSpringSecurityFilterChain(ServletContext servletContext) { - logger.info("SpringSecurityFilterChain initialized"); - } -} \ No newline at end of file diff --git a/juick-server/src/main/java/com/juick/server/xmpp/extensions/JuickMessage.java b/juick-server/src/main/java/com/juick/server/xmpp/extensions/JuickMessage.java deleted file mode 100644 index 6956a99a..00000000 --- a/juick-server/src/main/java/com/juick/server/xmpp/extensions/JuickMessage.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Juick - * Copyright (C) 2008-2011, Ugnich Anton - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package com.juick.server.xmpp.extensions; - -import com.juick.Tag; -import com.juick.xmpp.StanzaChild; -import com.juick.xmpp.utils.XmlUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.text.StringEscapeUtils; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import java.io.IOException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; -/** - * - * @author Ugnich Anton - */ -public class JuickMessage extends com.juick.Message implements StanzaChild { - public final static String XMLNS = "http://juick.com/message"; - public final static String TagName = "juick"; - private SimpleDateFormat df; - public JuickMessage() { - df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - df.setTimeZone(TimeZone.getTimeZone("UTC")); - } - - @Override - public String getXMLNS() { - return XMLNS; - } - @Override - public JuickMessage parse(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException { - JuickMessage jmsg = new JuickMessage(); - final String sMID = parser.getAttributeValue(null, "mid"); - if (sMID != null) { - jmsg.setMid(Integer.parseInt(sMID)); - } - final String sRID = parser.getAttributeValue(null, "rid"); - if (sRID != null) { - jmsg.setRid(Integer.parseInt(sRID)); - } - final String sReplyTo = parser.getAttributeValue(null, "replyto"); - if (sReplyTo != null) { - jmsg.setReplyto(Integer.parseInt(sReplyTo)); - } - final String sPrivacy = parser.getAttributeValue(null, "privacy"); - if (sPrivacy != null) { - jmsg.setPrivacy(Integer.parseInt(sPrivacy)); - } - final String sFriendsOnly = parser.getAttributeValue(null, "friendsonly"); - if (sFriendsOnly != null) { - jmsg.FriendsOnly = true; - } - final String sReadOnly = parser.getAttributeValue(null, "readonly"); - if (sReadOnly != null) { - jmsg.ReadOnly = true; - } - jmsg.setTimestamp(df.parse(parser.getAttributeValue(null, "ts")).toInstant()); - jmsg.setAttachmentType(parser.getAttributeValue(null, "attach")); - while (parser.next() == XmlPullParser.START_TAG) { - final String tag = parser.getName(); - final String xmlns = parser.getNamespace(); - if (tag.equals("body")) { - jmsg.setText(XmlUtils.getTagText(parser)); - } else if (tag.equals(JuickUser.TagName) && xmlns != null && xmlns.equals(JuickUser.XMLNS)) { - jmsg.setUser(new JuickUser().parse(parser)); - } else if (tag.equals("tag")) { - jmsg.getTags().add(new Tag(XmlUtils.getTagText(parser))); - } else { - XmlUtils.skip(parser); - } - } - return jmsg; - } - @Override - public String toString() { - StringBuilder ret = new StringBuilder("<").append(TagName).append(" xmlns=\"").append(XMLNS).append("\""); - if (getMid() > 0) { - ret.append(" mid=\"").append(getMid()).append("\""); - } - if (getRid() > 0) { - ret.append(" rid=\"").append(getRid()).append("\""); - } - if (getReplyto() > 0) { - ret.append(" replyto=\"").append(getReplyto()).append("\""); - } - ret.append(" privacy=\"").append(getPrivacy()).append("\""); - if (FriendsOnly) { - ret.append(" friendsonly=\"1\""); - } - if (ReadOnly) { - ret.append(" readonly=\"1\""); - } - if (getTimestamp() != null) { - ret.append(" ts=\"").append(df.format(Date.from(getTimestamp()))).append("\""); - } - if (getAttachmentType() != null) { - ret.append(" attach=\"").append(getAttachmentType()).append("\""); - } - ret.append(">"); - if (getUser() != null) { - ret.append(JuickUser.toString(getUser())); - } - if (getText() != null) { - ret.append("").append(StringEscapeUtils.escapeXml10(StringUtils.defaultString(getText()))).append(""); - } - for (Tag Tag : getTags()) { - ret.append("").append(StringEscapeUtils.escapeXml10(Tag.getName())).append(""); - } - ret.append(""); - return ret.toString(); - } - @Override - public boolean equals(Object obj) { - if (!(obj instanceof JuickMessage)) { - return false; - } - JuickMessage jmsg = (JuickMessage) obj; - return (this.getMid() == jmsg.getMid() && this.getRid() == jmsg.getRid()); - } - @Override - public int compareTo(Object obj) throws ClassCastException { - if (!(obj instanceof JuickMessage)) { - throw new ClassCastException(); - } - JuickMessage jmsg = (JuickMessage) obj; - if (this.getMid() != jmsg.getMid()) { - if (this.getMid() > jmsg.getMid()) { - return -1; - } else { - return 1; - } - } - if (this.getRid() != jmsg.getRid()) { - if (this.getRid() < jmsg.getRid()) { - return -1; - } else { - return 1; - } - } - return 0; - } -} \ No newline at end of file diff --git a/juick-server/src/main/java/com/juick/server/xmpp/extensions/JuickUser.java b/juick-server/src/main/java/com/juick/server/xmpp/extensions/JuickUser.java deleted file mode 100644 index 534efcc9..00000000 --- a/juick-server/src/main/java/com/juick/server/xmpp/extensions/JuickUser.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Juick - * Copyright (C) 2008-2011, Ugnich Anton - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package com.juick.server.xmpp.extensions; -import com.juick.xmpp.StanzaChild; -import com.juick.xmpp.utils.XmlUtils; -import org.apache.commons.text.StringEscapeUtils; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import java.io.IOException; -/** - * - * @author Ugnich Anton - */ -public class JuickUser extends com.juick.User implements StanzaChild { - public final static String XMLNS = "http://juick.com/user"; - public final static String TagName = "user"; - public JuickUser() { - } - @Override - public String getXMLNS() { - return XMLNS; - } - @Override - public JuickUser parse(final XmlPullParser parser) throws XmlPullParserException, IOException { - JuickUser juser = new JuickUser(); - String strUID = parser.getAttributeValue(null, "uid"); - if (strUID != null) { - juser.setUid(Integer.parseInt(strUID)); - } - juser.setName(parser.getAttributeValue(null, "uname")); - XmlUtils.skip(parser); - return juser; - } - public static String toString(com.juick.User user) { - String str = "<" + TagName + " xmlns='" + XMLNS + "'"; - if (user.getUid() > 0) { - str += " uid='" + user.getUid() + "'"; - } - if (user.getName() != null && user.getName().length() > 0) { - str += " uname='" + StringEscapeUtils.escapeXml10(user.getName()) + "'"; - } - str += "/>"; - return str; - } - @Override - public String toString() { - return toString(this); - } -} \ No newline at end of file diff --git a/juick-server/src/main/java/com/juick/server/xmpp/helpers/JidConverter.java b/juick-server/src/main/java/com/juick/server/xmpp/helpers/JidConverter.java deleted file mode 100644 index ca25c4b8..00000000 --- a/juick-server/src/main/java/com/juick/server/xmpp/helpers/JidConverter.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.juick.server.xmpp.helpers; - -import org.springframework.core.convert.converter.Converter; -import org.springframework.lang.Nullable; -import rocks.xmpp.addr.Jid; - -public class JidConverter implements Converter { - @Nullable - @Override - public Jid convert(String jidStr) { - return Jid.of(jidStr); - } -} diff --git a/juick-server/src/main/java/com/juick/server/xmpp/s2s/BasicXmppSession.java b/juick-server/src/main/java/com/juick/server/xmpp/s2s/BasicXmppSession.java deleted file mode 100644 index 647f2717..00000000 --- a/juick-server/src/main/java/com/juick/server/xmpp/s2s/BasicXmppSession.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2008-2017, Juick - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.juick.server.xmpp.s2s; - -import rocks.xmpp.addr.Jid; -import rocks.xmpp.core.XmppException; -import rocks.xmpp.core.session.ConnectionConfiguration; -import rocks.xmpp.core.session.XmppSession; -import rocks.xmpp.core.session.XmppSessionConfiguration; -import rocks.xmpp.core.stanza.model.IQ; -import rocks.xmpp.core.stanza.model.Message; -import rocks.xmpp.core.stanza.model.Presence; -import rocks.xmpp.core.stanza.model.server.ServerIQ; -import rocks.xmpp.core.stanza.model.server.ServerMessage; -import rocks.xmpp.core.stanza.model.server.ServerPresence; -import rocks.xmpp.core.stream.model.StreamElement; - -/** - * Created by vitalyster on 06.02.2017. - */ -public class BasicXmppSession extends XmppSession { - protected BasicXmppSession(String xmppServiceDomain, XmppSessionConfiguration configuration, ConnectionConfiguration... connectionConfigurations) { - super(xmppServiceDomain, configuration, connectionConfigurations); - } - - public static BasicXmppSession create(String xmppServiceDomain, XmppSessionConfiguration configuration) { - BasicXmppSession session = new BasicXmppSession(xmppServiceDomain, configuration); - notifyCreationListeners(session); - return session; - } - - @Override - public void connect(Jid from) throws XmppException { - - } - - @Override - public Jid getConnectedResource() { - return null; - } - - @Override - protected StreamElement prepareElement(StreamElement element) { - if (element instanceof Message) { - element = ServerMessage.from((Message) element); - } else if (element instanceof Presence) { - element = ServerPresence.from((Presence) element); - } else if (element instanceof IQ) { - element = ServerIQ.from((IQ) element); - } - - return element; - } -} diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java index ecb06d45..cd1af5a4 100644 --- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java +++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java @@ -24,8 +24,6 @@ import com.juick.ExternalToken; import com.juick.Message; import com.juick.Tag; import com.juick.User; -import com.juick.configuration.DataConfiguration; -import com.juick.configuration.RepositoryConfiguration; import com.juick.server.EmailManager; import com.juick.server.XMPPBot; import com.juick.server.XMPPServer; @@ -33,18 +31,21 @@ import com.juick.server.configuration.ApiAppConfiguration; import com.juick.server.configuration.ApiSecurityConfig; import com.juick.server.helpers.TagStats; import com.juick.service.*; +import com.juick.service.security.NotAuthorizedAuthenticationEntryPoint; import com.juick.util.DateFormattersHolder; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; @@ -75,16 +76,14 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. /** * Created by vitalyster on 25.11.2016. */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {ApiAppConfiguration.class, ApiSecurityConfig.class, DataConfiguration.class, RepositoryConfiguration.class}) -@TestPropertySource(properties = {"broken_ssl_hosts=localhost,serverstorageisfull.tld"}) -@WebAppConfiguration +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) +@TestPropertySource(properties = {"broken_ssl_hosts=localhost,serverstorageisfull.tld", "xmpp_disabled=true"}) +@AutoConfigureMockMvc public class ServerTests extends AbstractJUnit4SpringContextTests { - private MockMvc mockMvc; @Inject - private WebApplicationContext webApplicationContext; - + private MockMvc mockMvc; @Inject private MessagesService messagesService; @Inject @@ -118,13 +117,9 @@ public class ServerTests extends AbstractJUnit4SpringContextTests { @Before public void setUp() { - mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext) - .apply(SecurityMockMvcConfigurers.springSecurity()) - .dispatchOptions(true) - .build(); if (!isSetUp) { ugnichName = "ugnich"; - ugnichPassword = "MyPassw0rd!"; + ugnichPassword = "secret"; freefdName = "freefd"; freefdPassword = "MyPassw0rd!"; juickName = "juick"; @@ -148,21 +143,20 @@ public class ServerTests extends AbstractJUnit4SpringContextTests { @Test public void testAllUnAuthorized() throws Exception { - mockMvc.perform(get("/")) .andExpect(status().isMovedPermanently()); mockMvc.perform(get("/auth")) - .andExpect(status().is4xxClientError()); + .andExpect(status().isUnauthorized()); mockMvc.perform(get("/home")) - .andExpect(status().is4xxClientError()); + .andExpect(status().isUnauthorized()); mockMvc.perform(get("/messages/recommended")) - .andExpect(status().is4xxClientError()); + .andExpect(status().isUnauthorized()); mockMvc.perform(get("/messages/set_privacy")) - .andExpect(status().is4xxClientError()); + .andExpect(status().isUnauthorized()); } @Test @@ -356,7 +350,7 @@ public class ServerTests extends AbstractJUnit4SpringContextTests { } @Test public void statusPageIsUp() throws Exception { - mockMvc.perform(get("http://localhost:8080/status").with(httpBasic(ugnichName, ugnichPassword))).andExpect(status().isOk()); + mockMvc.perform(get("/api/status").with(httpBasic(ugnichName, ugnichPassword))).andExpect(status().isOk()); assertThat(server.getJid(), equalTo(jid)); } @Test diff --git a/juick-www/build.gradle b/juick-www/build.gradle index e7a9dfca..defc6558 100644 --- a/juick-www/build.gradle +++ b/juick-www/build.gradle @@ -20,7 +20,8 @@ task compileFrontend(type: YarnTask) { apply plugin: 'java' apply plugin: 'war' -apply plugin: 'org.akhikhl.gretty' +apply plugin: 'org.springframework.boot' +apply plugin: 'io.spring.dependency-management' dependencies { compile project(':juick-server-web') @@ -42,10 +43,8 @@ compileFrontend.dependsOn 'yarn' processResources.dependsOn 'compileFrontend' compileJava.options.encoding = 'UTF-8' -gretty { - httpPort = 8080 - contextPath = '/' - servletContainer = 'tomcat8' +bootJar { + launchScript() } configurations { diff --git a/juick-www/src/main/java/com/juick/www/Application.java b/juick-www/src/main/java/com/juick/www/Application.java new file mode 100644 index 00000000..0e60e1d8 --- /dev/null +++ b/juick-www/src/main/java/com/juick/www/Application.java @@ -0,0 +1,12 @@ +package com.juick.www; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/juick-www/src/main/java/com/juick/www/configuration/WwwAppConfiguration.java b/juick-www/src/main/java/com/juick/www/configuration/WwwAppConfiguration.java index e04538e8..250197f7 100644 --- a/juick-www/src/main/java/com/juick/www/configuration/WwwAppConfiguration.java +++ b/juick-www/src/main/java/com/juick/www/configuration/WwwAppConfiguration.java @@ -17,6 +17,10 @@ package com.juick.www.configuration; +import com.juick.configuration.DataConfiguration; +import com.juick.configuration.SearchConfiguration; +import com.juick.server.configuration.BaseWebConfiguration; +import com.juick.server.configuration.StorageConfiguration; import com.juick.service.CloudflareCache; import com.juick.service.TagService; import com.juick.service.UserService; @@ -29,7 +33,7 @@ import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.caffeine.CaffeineCacheManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; +import org.springframework.context.annotation.Import; import javax.inject.Inject; import java.util.Collections; @@ -38,9 +42,10 @@ import java.util.Collections; * Created by aalexeev on 11/22/16. */ @Configuration -@PropertySource(value = "classpath:juick.conf", ignoreResourceNotFound = true) @EnableCaching -public class WwwAppConfiguration { +@Import({WwwServletConfiguration.class, WebSecurityConfig.class, SapeConfiguration.class, SearchConfiguration.class, + DataConfiguration.class, StorageConfiguration.class}) +public class WwwAppConfiguration extends BaseWebConfiguration { @Inject private UserService userService; @Inject diff --git a/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java b/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java deleted file mode 100644 index 26beaee4..00000000 --- a/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2008-2017, Juick - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.juick.www.configuration; - -import com.juick.configuration.DataConfiguration; -import com.juick.configuration.SearchConfiguration; -import com.juick.server.configuration.StorageConfiguration; -import org.apache.commons.codec.CharEncoding; -import org.springframework.web.filter.CharacterEncodingFilter; -import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; - -import javax.servlet.FilterRegistration; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; - -/** - * Created by aalexeev on 11/20/16. - */ -public class WwwInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { - - @Override - protected Class[] getRootConfigClasses() { - return new Class[]{ - WwwServletConfiguration.class, - WwwAppConfiguration.class, - SearchConfiguration.class, - SapeConfiguration.class, - WebSecurityConfig.class, - DataConfiguration.class, - StorageConfiguration.class - }; - } - - @Override - protected Class[] getServletConfigClasses() { - return null; - } - - @Override - protected String[] getServletMappings() { - return new String[]{"/"}; - } - - @Override - protected String getServletName() { - return "WWW-spring dispatcher servlet"; - } - - @Override - public void onStartup(ServletContext servletContext) throws ServletException { - super.onStartup(servletContext); - - FilterRegistration.Dynamic registration = servletContext.addFilter( - "encodingFilter", new CharacterEncodingFilter(CharEncoding.UTF_8, true)); - - registration.addMappingForUrlPatterns(null, true, "/*"); - } -} - diff --git a/juick-www/src/main/java/com/juick/www/configuration/WwwSecurityInitializer.java b/juick-www/src/main/java/com/juick/www/configuration/WwwSecurityInitializer.java deleted file mode 100644 index a977268f..00000000 --- a/juick-www/src/main/java/com/juick/www/configuration/WwwSecurityInitializer.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2008-2017, Juick - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.juick.www.configuration; - -/** - * Created by vitalyster on 25.11.2016. - */ - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer; - -import javax.servlet.ServletContext; - -public class WwwSecurityInitializer extends AbstractSecurityWebApplicationInitializer { - private final Logger logger = LoggerFactory.getLogger(getClass()); - - @Override - protected void afterSpringSecurityFilterChain(ServletContext servletContext) { - logger.info("SpringSecurityFilterChain initialized"); - } -} diff --git a/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java b/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java index 1654f2ac..a8dbad8b 100644 --- a/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java +++ b/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java @@ -22,14 +22,12 @@ import com.mitchellbosecke.pebble.PebbleEngine; import com.mitchellbosecke.pebble.extension.FormatterExtension; import com.mitchellbosecke.pebble.loader.ClasspathLoader; import com.mitchellbosecke.pebble.loader.Loader; -import com.mitchellbosecke.pebble.loader.ServletLoader; import com.mitchellbosecke.pebble.spring4.PebbleViewResolver; import com.mitchellbosecke.pebble.spring4.extension.SpringExtension; import org.apache.commons.codec.CharEncoding; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; import org.springframework.core.Ordered; import org.springframework.http.CacheControl; import org.springframework.web.servlet.ViewResolver; diff --git a/juick-www/src/test/java/com/juick/www/WebAppTests.java b/juick-www/src/test/java/com/juick/www/WebAppTests.java index 726a4612..73cec17a 100644 --- a/juick-www/src/test/java/com/juick/www/WebAppTests.java +++ b/juick-www/src/test/java/com/juick/www/WebAppTests.java @@ -44,14 +44,18 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.autoconfigure.web.client.AutoConfigureWebClient; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ClassPathResource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; @@ -77,16 +81,17 @@ import java.util.stream.StreamSupport; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; /** * Created by vitalyster on 12.01.2017. */ -@RunWith(SpringJUnit4ClassRunner.class) -@WebAppConfiguration +@RunWith(SpringRunner.class) +@AutoConfigureMockMvc +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) +@TestPropertySource(properties = {"xmpp_disabled=true"}) + @ContextConfiguration(classes = { DataConfiguration.class, WwwServletConfiguration.class, WwwAppConfiguration.class, SapeConfiguration.class, @@ -94,7 +99,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. }) public class WebAppTests { @Configuration - @ComponentScan(basePackages = "com.juick.www.controllers") static class Config { @Bean public ImagesService imagesService() { @@ -102,13 +106,13 @@ public class WebAppTests { } } - @Inject - private WebApplicationContext wac; @Inject private WebApp webApp; - private static MockMvc mockMvc; - private static WebClient webClient; + @Inject + private MockMvc mockMvc; + @Inject + private WebClient webClient; @Inject private UserService userService; @@ -134,21 +138,17 @@ public class WebAppTests { @Before public void setup() throws IOException { if (!isSetUp) { - mockMvc = MockMvcBuilders.webAppContextSetup(wac) - .apply(springSecurity()) - .build(); - webClient = MockMvcWebClientBuilder.mockMvcSetup(mockMvc).build(); webClient.getOptions().setJavaScriptEnabled(false); webClient.getOptions().setCssEnabled(false); webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); ugnichName = "ugnich"; - ugnichPassword = "MyPassw0rd!"; + ugnichPassword = "secret"; freefdName = "freefd"; freefdPassword = "MyPassw0rd!"; - int ugnichId = userService.createUser(ugnichName, ugnichPassword); - ugnich = userService.getUserByUID(ugnichId).orElseThrow(IllegalStateException::new); + userService.createUser(ugnichName, ugnichPassword); + ugnich = userService.getUserByName(ugnichName); int freefdId = userService.createUser(freefdName, freefdPassword); freefd = userService.getUserByUID(freefdId).orElseThrow(IllegalStateException::new); diff --git a/juick-xmpp-wip/build.gradle b/juick-xmpp-wip/build.gradle index cc69ed34..ad49cf16 100644 --- a/juick-xmpp-wip/build.gradle +++ b/juick-xmpp-wip/build.gradle @@ -1,11 +1,11 @@ apply plugin: 'java' apply plugin: 'war' -apply plugin: 'org.akhikhl.gretty' +apply plugin: 'org.springframework.boot' +apply plugin: 'io.spring.dependency-management' dependencies { compile project(':juick-server-jdbc') compile project(':juick-server-web') - compile project(':juick-server') testCompile project(path: ':juick-core', configuration: 'testArtifacts') testCompile project(path: ':juick-server', configuration: 'testArtifacts') @@ -15,12 +15,6 @@ dependencies { compileJava.options.encoding = 'UTF-8' -gretty { - httpPort = 8080 - contextPath = '/router' - servletContainer = 'tomcat8' -} - configurations { all*.exclude module: 'commons-logging' } diff --git a/juick-xmpp-wip/src/main/java/com/juick/components/XMPPBot.java b/juick-xmpp-wip/src/main/java/com/juick/components/XMPPBot.java index 2e051d32..27206a32 100644 --- a/juick-xmpp-wip/src/main/java/com/juick/components/XMPPBot.java +++ b/juick-xmpp-wip/src/main/java/com/juick/components/XMPPBot.java @@ -25,6 +25,8 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.core.env.Environment; import rocks.xmpp.addr.Jid; import rocks.xmpp.core.XmppException; @@ -41,6 +43,7 @@ import java.net.URL; /** * Created by vt on 12/11/2016. */ +@SpringBootApplication public class XMPPBot implements AutoCloseable { private static final Logger logger = LoggerFactory.getLogger(XMPPBot.class); @Inject @@ -104,4 +107,7 @@ public class XMPPBot implements AutoCloseable { logger.info("ExternalComponent on xmpp-bot destroyed"); } + public static void main(String[] args) { + SpringApplication.run(XMPPBot.class, args); + } } diff --git a/juick-xmpp-wip/src/main/java/com/juick/components/configuration/BotAppConfiguration.java b/juick-xmpp-wip/src/main/java/com/juick/components/configuration/BotAppConfiguration.java index 9825751b..7806347d 100644 --- a/juick-xmpp-wip/src/main/java/com/juick/components/configuration/BotAppConfiguration.java +++ b/juick-xmpp-wip/src/main/java/com/juick/components/configuration/BotAppConfiguration.java @@ -20,23 +20,16 @@ package com.juick.components.configuration; import com.juick.components.XMPPBot; import com.juick.server.configuration.BaseWebConfiguration; import com.juick.server.protocol.JuickProtocol; -import org.springframework.context.annotation.*; -import org.springframework.core.env.Environment; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; - -import javax.inject.Inject; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; /** * Created by aalexeev on 11/12/16. */ @Configuration @ComponentScan(basePackages = {"com.juick.components"}) -@PropertySource(value = "classpath:juick.conf", ignoreResourceNotFound = true) -@Import(BaseWebConfiguration.class) -public class BotAppConfiguration extends WebMvcConfigurationSupport { - @Inject - private Environment env; - +public class BotAppConfiguration extends BaseWebConfiguration { @Bean public XMPPBot xmpp() { return new XMPPBot(); diff --git a/juick-xmpp-wip/src/main/java/com/juick/components/configuration/BotInitializer.java b/juick-xmpp-wip/src/main/java/com/juick/components/configuration/BotInitializer.java deleted file mode 100644 index 8b8c3623..00000000 --- a/juick-xmpp-wip/src/main/java/com/juick/components/configuration/BotInitializer.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2008-2017, Juick - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.juick.components.configuration; - -import org.apache.commons.codec.CharEncoding; -import org.springframework.web.filter.CharacterEncodingFilter; -import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; - -import javax.servlet.Filter; - -/** - * Created by vt on 09/02/16. - */ -public class BotInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { - - @Override - protected Class[] getRootConfigClasses() { - return new Class[]{ }; - } - - @Override - protected Class[] getServletConfigClasses() { - return new Class[]{ BotAppConfiguration.class }; - } - - @Override - protected String[] getServletMappings() { - return new String[]{"/"}; - } - - @Override - protected Filter[] getServletFilters() { - CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(CharEncoding.UTF_8); - return new Filter[]{characterEncodingFilter}; - } - - @Override - protected String getServletName() { - return "Bot dispatcher servlet"; - } -} diff --git a/juick-xmpp-wip/src/test/java/com/juick/xmpp/XMPPTests.java b/juick-xmpp-wip/src/test/java/com/juick/xmpp/XMPPTests.java index 1193f3a2..2cad5fb4 100644 --- a/juick-xmpp-wip/src/test/java/com/juick/xmpp/XMPPTests.java +++ b/juick-xmpp-wip/src/test/java/com/juick/xmpp/XMPPTests.java @@ -21,8 +21,6 @@ import com.gargoylesoftware.htmlunit.WebClient; import com.juick.components.XMPPRouter; import com.juick.components.configuration.BotAppConfiguration; import com.juick.configuration.MockDataConfiguration; -import com.juick.server.XMPPConnection; -import com.juick.server.configuration.ApiAppConfiguration; import com.juick.service.MessengerService; import com.juick.service.PrivacyQueriesService; import com.juick.service.ShowQueriesService; @@ -60,7 +58,7 @@ import static org.hamcrest.Matchers.equalTo; public class XMPPTests { @Configuration @Import(value = { - BotAppConfiguration.class, ApiAppConfiguration.class, MockDataConfiguration.class + BotAppConfiguration.class, MockDataConfiguration.class }) static class Config { @Bean @@ -91,11 +89,9 @@ public class XMPPTests { @Inject XMPPRouter router; @Inject - XMPPConnection component; - @Inject ExecutorService service; @Test - public void routerHandshake() throws XmppException, InterruptedException { + public void routerHandshake() throws InterruptedException { XmppSessionConfiguration configuration = XmppSessionConfiguration.builder() .extensions(Extension.of(com.juick.Message.class)) .debugger(LogbackDebugger.class) @@ -108,23 +104,33 @@ public class XMPPTests { lock.countDown(); } }); + ExternalComponent routerClient2 = ExternalComponent.create("bot.localhost", + "secret", configuration, "localhost", 5347); + CountDownLatch lock2 = new CountDownLatch(1); + routerClient2.addConnectionListener(connectionEvent -> { + if (connectionEvent.equals(ConnectionEvent.Type.RECONNECTION_SUCCEEDED)) { + lock2.countDown(); + } + }); service.submit(() -> { try { Thread.sleep(3000); routerClient.connect(); + routerClient2.connect(); } catch (XmppException | InterruptedException e) { e.printStackTrace(); } lock.countDown(); + lock2.countDown(); }); lock.await(); - CountDownLatch lock2 = new CountDownLatch(2); - component.sendStanza(new Message(Jid.of("yoyo@test.localhost"), Message.Type.CHAT, "test" )); - component.sendStanza(new Message(Jid.of("yoyo@test.localhost"), Message.Type.CHAT, "test" )); + CountDownLatch lock3 = new CountDownLatch(2); + routerClient2.sendMessage(new Message(Jid.of("yoyo@test.localhost"), Message.Type.CHAT, "test" )); + routerClient2.sendMessage(new Message(Jid.of("yoyo@test.localhost"), Message.Type.CHAT, "test" )); routerClient.addInboundMessageListener(messageEvent -> { assertThat(messageEvent.getMessage().getBody(), equalTo("test")); - lock2.countDown(); + lock3.countDown(); }); - lock2.await(); + lock3.await(); } } -- cgit v1.2.3