From 22dcf50dee2fcdf818bace3abae784fded1d34d9 Mon Sep 17 00:00:00 2001 From: vitalyster Date: Sat, 10 Oct 2020 02:43:42 +0300 Subject: [PATCH 1/5] CI: allow to publish manually (#395) --- .github/workflows/publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b79f25309..8224445e4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,7 @@ name: Publish -on: +on: + workflow_dispatch: push: branches: - master From 2d9a1a57f485c5cf8dcf342875368248d3b8a661 Mon Sep 17 00:00:00 2001 From: vitalyster Date: Thu, 22 Oct 2020 19:21:03 +0300 Subject: [PATCH 2/5] CodeQL setup (#396) --- .github/workflows/codeql-analysis.yml | 28 +++++++++++++++++++++++++++ .github/workflows/main.yml | 8 +++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000..a6b17b563 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,28 @@ +name: "CodeQL" + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: ['python', 'javascript'] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index afec53527..cf65194f9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,8 +50,14 @@ jobs: rm /usr/local/include/Swiften/Network/DummyConnectionServer.h rm /usr/local/include/Swiften/Network/DummyConnectionServerFactory.h cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=ON -DENABLE_FROTZ=OFF -DCMAKE_UNITY_BUILD=ON . - - name: Build tests + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: cpp + - name: Build run: make -j4 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 - name: Run tests run: make test From a54143a3e5dd25172e947b48cfd789b20c1d5a35 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 27 Oct 2020 07:54:20 +0300 Subject: [PATCH 3/5] prpl-eionrobb-instagram 2FA support --- backends/libpurple/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backends/libpurple/main.cpp b/backends/libpurple/main.cpp index dc731c949..9c0d25be0 100644 --- a/backends/libpurple/main.cpp +++ b/backends/libpurple/main.cpp @@ -432,6 +432,10 @@ class SpectrumNetworkPlugin : public NetworkPlugin { adminLegacyName = "telegram"; adminAlias = "telegram"; } + else if (protocol == "prpl-eionrobb-instagram") { + adminLegacyName = "instagram"; + adminAlias = "instagram"; + } if (!purple_find_prpl_wrapped(protocol.c_str())) { LOG4CXX_INFO(logger, name.c_str() << ": Invalid protocol '" << protocol << "'"); np->handleDisconnected(user, 1, "Invalid protocol " + protocol); @@ -1865,6 +1869,17 @@ void * requestInput(const char *title, const char *primary,const char *secondary np->m_inputRequests[req->mainJID] = req; return NULL; } + else if (boost::starts_with(primaryString, "Enter the six-digit code")) { + LOG4CXX_INFO(logger, "prpl-eionrobb-instagram verification request"); + np->handleMessage(np->m_accounts[account], np->adminLegacyName, std::string("Verification code: ")); + inputRequest *req = new inputRequest; + req->ok_cb = (PurpleRequestInputCb)ok_cb; + req->user_data = user_data; + req->account = account; + req->mainJID = np->m_accounts[account]; + np->m_inputRequests[req->mainJID] = req; + return NULL; + } else { LOG4CXX_WARN(logger, "Unhandled request input. primary=" << primaryString); } From ed92f4ccc117fbe133a29d145f66b580729b8c85 Mon Sep 17 00:00:00 2001 From: vitalyster Date: Tue, 27 Oct 2020 08:38:53 +0300 Subject: [PATCH 4/5] CI: bump microsoft/setup-msbuild to v1.0.2 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cf65194f9..36c0e454e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -71,7 +71,7 @@ jobs: 7z x deps32.zip shell: cmd - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.0 + uses: microsoft/setup-msbuild@v1.0.2 - name: Configure build run: | set CMAKE_PREFIX_PATH=%cd%\deps32 From f3c9e7c60965c35928932c5506be0774b1ecb133 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 25 Nov 2020 00:13:46 +0300 Subject: [PATCH 5/5] Cleanup duplicated macros --- spectrum/src/frontends/slack/SlackAPI.cpp | 36 ------------------- spectrum/src/frontends/slack/SlackAPI.h | 44 +++++++++++++++++++++++ spectrum/src/frontends/slack/SlackRTM.cpp | 36 +++---------------- 3 files changed, 48 insertions(+), 68 deletions(-) diff --git a/spectrum/src/frontends/slack/SlackAPI.cpp b/spectrum/src/frontends/slack/SlackAPI.cpp index a0c8588f2..0e076d3e8 100644 --- a/spectrum/src/frontends/slack/SlackAPI.cpp +++ b/spectrum/src/frontends/slack/SlackAPI.cpp @@ -35,42 +35,6 @@ namespace Transport { -DEFINE_LOGGER(slackAPILogger, "SlackAPI"); - -#define GET_ARRAY(FROM, NAME) Json::Value &NAME = FROM[#NAME]; \ - if (!NAME.isArray()) { \ - LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' object in the reply."); \ - return; \ - } - -#define STORE_STRING(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \ - if (!NAME##_tmp.isString()) { \ - LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' string in the reply."); \ - LOG4CXX_ERROR(slackAPILogger, data); \ - return; \ - } \ - std::string NAME = NAME##_tmp.asString(); - -#define STORE_BOOL(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \ - if (!NAME##_tmp.isBool()) { \ - LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' string in the reply."); \ - LOG4CXX_ERROR(slackAPILogger, data); \ - return; \ - } \ - bool NAME = NAME##_tmp.asBool(); - -#define GET_OBJECT(FROM, NAME) Json::Value &NAME = FROM[#NAME]; \ - if (!NAME.isObject()) { \ - LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' object in the reply."); \ - return; \ - } - -#define STORE_STRING_OPTIONAL(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \ - std::string NAME; \ - if (NAME##_tmp.isString()) { \ - NAME = NAME##_tmp.asString(); \ - } - SlackAPI::SlackAPI(Component *component, SlackIdManager *idManager, const std::string &token, const std::string &domain) : HTTPRequestQueue(component, domain) { m_component = component; m_token = token; diff --git a/spectrum/src/frontends/slack/SlackAPI.h b/spectrum/src/frontends/slack/SlackAPI.h index 61eed68c6..0dea781de 100644 --- a/spectrum/src/frontends/slack/SlackAPI.h +++ b/spectrum/src/frontends/slack/SlackAPI.h @@ -28,6 +28,50 @@ #include #include +DEFINE_LOGGER(slackAPILogger, "SlackAPI"); + +#define GET_ARRAY(FROM, NAME) Json::Value &NAME = FROM[#NAME]; \ + if (!NAME.isArray()) { \ + LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' object in the reply."); \ + return; \ + } + +#define STORE_STRING(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \ + if (!NAME##_tmp.isString()) { \ + LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' string in the reply."); \ + LOG4CXX_ERROR(slackAPILogger, data); \ + return; \ + } \ + std::string NAME = NAME##_tmp.asString(); + +#define STORE_BOOL(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \ + if (!NAME##_tmp.isBool()) { \ + LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' string in the reply."); \ + LOG4CXX_ERROR(slackAPILogger, data); \ + return; \ + } \ + bool NAME = NAME##_tmp.asBool(); + +#define GET_OBJECT(FROM, NAME) Json::Value &NAME = FROM[#NAME]; \ + if (!NAME.isObject()) { \ + LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' object in the reply."); \ + return; \ + } + +#define STORE_STRING_OPTIONAL(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \ + std::string NAME; \ + if (NAME##_tmp.isString()) { \ + NAME = NAME##_tmp.asString(); \ + } + +#define STORE_INT(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \ + if (!NAME##_tmp.isInt()) { \ + LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' number in the reply."); \ + LOG4CXX_ERROR(slackAPILogger, data); \ + return; \ + } \ + int NAME = NAME##_tmp.asInt(); + namespace Transport { class Component; diff --git a/spectrum/src/frontends/slack/SlackRTM.cpp b/spectrum/src/frontends/slack/SlackRTM.cpp index df7aff203..0fcbc04e2 100644 --- a/spectrum/src/frontends/slack/SlackRTM.cpp +++ b/spectrum/src/frontends/slack/SlackRTM.cpp @@ -72,41 +72,13 @@ void SlackRTM::start() { req->execute(); } -#define STORE_STRING(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \ - if (!NAME##_tmp.isString()) { \ - LOG4CXX_ERROR(slackRTMLogger, "No '" << #NAME << "' string in the reply."); \ - LOG4CXX_ERROR(slackRTMLogger, payload); \ - return; \ - } \ - std::string NAME = NAME##_tmp.asString(); - -#define STORE_STRING_OPTIONAL(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \ - std::string NAME; \ - if (NAME##_tmp.isString()) { \ - NAME = NAME##_tmp.asString(); \ - } - -#define GET_OBJECT(FROM, NAME) Json::Value &NAME = FROM[#NAME]; \ - if (!NAME.isObject()) { \ - LOG4CXX_ERROR(slackRTMLogger, "No '" << #NAME << "' object in the reply."); \ - return; \ - } - -#define STORE_INT(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \ - if (!NAME##_tmp.isInt()) { \ - LOG4CXX_ERROR(slackRTMLogger, "No '" << #NAME << "' number in the reply."); \ - LOG4CXX_ERROR(slackRTMLogger, payload); \ - return; \ - } \ - int NAME = NAME##_tmp.asInt(); - -void SlackRTM::handlePayloadReceived(const std::string &payload) { +void SlackRTM::handlePayloadReceived(const std::string &data) { Json::Value d; Json::CharReaderBuilder rbuilder; std::shared_ptr const reader(rbuilder.newCharReader()); - if (!reader->parse(payload.c_str(), payload.c_str() + payload.size(), &d, NULL)) { + if (!reader->parse(data.c_str(), data.c_str() + data.size(), &d, NULL)) { LOG4CXX_ERROR(slackRTMLogger, "Error while parsing JSON"); - LOG4CXX_ERROR(slackRTMLogger, payload); + LOG4CXX_ERROR(slackRTMLogger, data); return; } @@ -152,7 +124,7 @@ void SlackRTM::handlePayloadReceived(const std::string &payload) { else if (type == "channel_joined" || type == "channel_created") { std::map &channels = m_idManager->getChannels(); - SlackAPI::getSlackChannelInfo(NULL, true, d, payload, channels); + SlackAPI::getSlackChannelInfo(NULL, true, d, data, channels); } else if (type == "error") { GET_OBJECT(d, error);