summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--appinfo/app.php26
-rw-r--r--appinfo/info.xml4
-rw-r--r--appinfo/routes.php4
-rw-r--r--css/icons.scss8
-rw-r--r--img/facebook.svg1
-rw-r--r--img/instagram.svg1
-rw-r--r--img/license.txt6
-rw-r--r--img/mastodon.svg1
-rw-r--r--img/sync.svg3
-rw-r--r--img/tumblr.svg76
-rw-r--r--img/twitter.svg1
-rw-r--r--l10n/uk.json2
-rw-r--r--lib/AppInfo/Application.php37
-rw-r--r--lib/Controller/PageController.php14
-rw-r--r--lib/Controller/SocialApiController.php95
-rw-r--r--lib/Service/Social/CompositeSocialProvider.php95
-rw-r--r--lib/Service/Social/FacebookProvider.php99
-rw-r--r--lib/Service/Social/ISocialProvider.php45
-rw-r--r--lib/Service/Social/InstagramProvider.php87
-rw-r--r--lib/Service/Social/MastodonProvider.php78
-rw-r--r--lib/Service/Social/TumblrProvider.php57
-rw-r--r--lib/Service/Social/TwitterProvider.php95
-rw-r--r--lib/Service/SocialApiService.php185
-rw-r--r--lib/Settings/AdminSettings.php78
-rw-r--r--package-lock.json16
-rw-r--r--package.json1
-rw-r--r--src/adminSettings.js34
-rw-r--r--src/components/AdminSettings.vue35
-rw-r--r--src/components/ContactDetails.vue4
-rw-r--r--src/components/ContactDetails/ContactDetailsAvatar.vue86
-rw-r--r--src/store/contacts.js4
-rw-r--r--templates/settings/admin.php5
-rw-r--r--tests/unit/Controller/PageControllerTest.php16
-rw-r--r--tests/unit/Service/SocialApiServiceTest.php132
-rw-r--r--webpack.common.js7
36 files changed, 1413 insertions, 27 deletions
diff --git a/README.md b/README.md
index c9a8c992..4de47885 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# Nextcloud Contacts
-![Downloads](https://img.shields.io/github/downloads/nextcloud/contacts/total?style=flat-square)
+![Downloads](https://img.shields.io/github/downloads/nextcloud/contacts/total.svg?style=flat-square)
[![Codacy Badge](https://img.shields.io/codacy/grade/ea24ea9fccb942419d73ec05105938aa.svg?style=flat-square)](https://app.codacy.com/app/skjnldsv/contacts)
[![Code coverage](https://img.shields.io/codecov/c/github/nextcloud/contacts.svg?style=flat-square)](https://codecov.io/gh/nextcloud/contacts/)
[![Dependabot status](https://img.shields.io/badge/Dependabot-enabled-brightgreen.svg?longCache=true&style=flat-square&logo=dependabot)](https://dependabot.com)
diff --git a/appinfo/app.php b/appinfo/app.php
new file mode 100644
index 00000000..69901b4f
--- /dev/null
+++ b/appinfo/app.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * @copyright Copyright (c) 2020 John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ */
+
+use OCA\Contacts\AppInfo\Application;
+
+$app = \OC::$server->query(Application::class);
diff --git a/appinfo/info.xml b/appinfo/info.xml
index a3f7bdce..5fa7b3bf 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -50,4 +50,8 @@
<order>4</order>
</navigation>
</navigations>
+
+ <settings>
+ <admin>OCA\Contacts\Settings\AdminSettings</admin>
+ </settings>
</info>
diff --git a/appinfo/routes.php b/appinfo/routes.php
index e09de763..647b8f27 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -25,6 +25,8 @@ return [
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'page#index', 'url' => '/{group}', 'verb' => 'GET', 'postfix' => 'group'],
- ['name' => 'page#index', 'url' => '/{group}/{contact}', 'verb' => 'GET', 'postfix' => 'group.contact']
+ ['name' => 'page#index', 'url' => '/{group}/{contact}', 'verb' => 'GET', 'postfix' => 'group.contact'],
+ ['name' => 'social_api#update_contact', 'url' => '/api/v1/social/avatar/{network}/{addressbookId}/{contactId}', 'verb' => 'PUT'],
+ ['name' => 'social_api#set_app_config', 'url' => '/api/v1/social/config/{key}', 'verb' => 'POST'],
]
];
diff --git a/css/icons.scss b/css/icons.scss
index 0d7c99d0..0685ea09 100644
--- a/css/icons.scss
+++ b/css/icons.scss
@@ -30,6 +30,14 @@
@include icon-black-white('no-calendar', 'contacts', 1);
@include icon-black-white('language', 'contacts', 2);
@include icon-black-white('clone', 'contacts', 2);
+@include icon-black-white('sync', 'contacts', 2);
+
+// social network icons:
+@include icon-black-white('facebook', 'contacts', 2); // “facebook (fab)” by fontawesome.com is licensed under CC BY 4.0. (https://fontawesome.com/icons/facebook?style=brands)
+@include icon-black-white('instagram', 'contacts', 2); // “instagram (fab)” by fontawesome.com is licensed under CC BY 4.0. (https://fontawesome.com/icons/instagram?style=brands)
+@include icon-black-white('mastodon', 'contacts', 2); // “mastodon (fab)” by fontawesome.com is licensed under CC BY 4.0. (https://fontawesome.com/icons/mastodon?style=brands)
+@include icon-black-white('tumblr', 'contacts', 2); // “tumblr (fab)” by fontawesome.com is licensed under CC BY 4.0. (https://fontawesome.com/icons/tumblr?style=brands)
+@include icon-black-white('twitter', 'contacts', 2); // “twitter (fab)” by fontawesome.com is licensed under CC BY 4.0. (https://fontawesome.com/icons/twitter?style=brands)
.icon-up-force-white {
// using #fffffe to trick the accessibility dark theme icon invert
diff --git a/img/facebook.svg b/img/facebook.svg
new file mode 100644
index 00000000..649b4945
--- /dev/null
+++ b/img/facebook.svg
@@ -0,0 +1 @@
+<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="facebook" class="svg-inline--fa fa-facebook fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M504 256C504 119 393 8 256 8S8 119 8 256c0 123.78 90.69 226.38 209.25 245V327.69h-63V256h63v-54.64c0-62.15 37-96.48 93.67-96.48 27.14 0 55.52 4.84 55.52 4.84v61h-31.28c-30.8 0-40.41 19.12-40.41 38.73V256h68.78l-11 71.69h-57.78V501C413.31 482.38 504 379.78 504 256z"></path></svg> \ No newline at end of file
diff --git a/img/instagram.svg b/img/instagram.svg
new file mode 100644
index 00000000..53ab3119
--- /dev/null
+++ b/img/instagram.svg
@@ -0,0 +1 @@
+<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="instagram" class="svg-inline--fa fa-instagram fa-w-14" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M224.1 141c-63.6 0-114.9 51.3-114.9 114.9s51.3 114.9 114.9 114.9S339 319.5 339 255.9 287.7 141 224.1 141zm0 189.6c-41.1 0-74.7-33.5-74.7-74.7s33.5-74.7 74.7-74.7 74.7 33.5 74.7 74.7-33.6 74.7-74.7 74.7zm146.4-194.3c0 14.9-12 26.8-26.8 26.8-14.9 0-26.8-12-26.8-26.8s12-26.8 26.8-26.8 26.8 12 26.8 26.8zm76.1 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM398.8 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"></path></svg> \ No newline at end of file
diff --git a/img/license.txt b/img/license.txt
new file mode 100644
index 00000000..d4e74fdb
--- /dev/null
+++ b/img/license.txt
@@ -0,0 +1,6 @@
+# social network icons:
+* “facebook (fab)” by fontawesome.com is licensed under CC BY 4.0. (https://fontawesome.com/icons/facebook?style=brands)
+* “instagram (fab)” by fontawesome.com is licensed under CC BY 4.0. (https://fontawesome.com/icons/instagram?style=brands)
+* “mastodon (fab)” by fontawesome.com is licensed under CC BY 4.0. (https://fontawesome.com/icons/mastodon?style=brands)
+* “tumblr (fab)” by fontawesome.com is licensed under CC BY 4.0. (https://fontawesome.com/icons/tumblr?style=brands)
+* “twitter (fab)” by fontawesome.com is licensed under CC BY 4.0. (https://fontawesome.com/icons/twitter?style=brands)
diff --git a/img/mastodon.svg b/img/mastodon.svg
new file mode 100644
index 00000000..4257e7c6
--- /dev/null
+++ b/img/mastodon.svg
@@ -0,0 +1 @@
+<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="mastodon" class="svg-inline--fa fa-mastodon fa-w-14" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M433 179.11c0-97.2-63.71-125.7-63.71-125.7-62.52-28.7-228.56-28.4-290.48 0 0 0-63.72 28.5-63.72 125.7 0 115.7-6.6 259.4 105.63 289.1 40.51 10.7 75.32 13 103.33 11.4 50.81-2.8 79.32-18.1 79.32-18.1l-1.7-36.9s-36.31 11.4-77.12 10.1c-40.41-1.4-83-4.4-89.63-54a102.54 102.54 0 0 1-.9-13.9c85.63 20.9 158.65 9.1 178.75 6.7 56.12-6.7 105-41.3 111.23-72.9 9.8-49.8 9-121.5 9-121.5zm-75.12 125.2h-46.63v-114.2c0-49.7-64-51.6-64 6.9v62.5h-46.33V197c0-58.5-64-56.6-64-6.9v114.2H90.19c0-122.1-5.2-147.9 18.41-175 25.9-28.9 79.82-30.8 103.83 6.1l11.6 19.5 11.6-19.5c24.11-37.1 78.12-34.8 103.83-6.1 23.71 27.3 18.4 53 18.4 175z"></path></svg> \ No newline at end of file
diff --git a/img/sync.svg b/img/sync.svg
new file mode 100644
index 00000000..6cecc8d0
--- /dev/null
+++ b/img/sync.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24">
+ <path d="M12 .38l-4.5 4.5 4.5 4.5V6a6 6 0 014.24 10.24l1.59 1.59A8.25 8.25 0 0012 3.75zM12 23.63l4.5-4.5-4.5-4.5V18A6 6 0 017.76 7.76L6.17 6.17A8.25 8.25 0 0012 20.25z"/>
+</svg>
diff --git a/img/tumblr.svg b/img/tumblr.svg
new file mode 100644
index 00000000..763bc473
--- /dev/null
+++ b/img/tumblr.svg
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.2" width="135.5mm" height="135.5mm" viewBox="0 0 13550 13550" preserveAspectRatio="xMidYMid" fill-rule="evenodd" stroke-width="28.222" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" xmlns:ooo="http://xml.openoffice.org/svg/export" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:presentation="http://sun.com/xmlns/staroffice/presentation" xmlns:smil="http://www.w3.org/2001/SMIL20/" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xml:space="preserve">
+ <defs class="ClipPathGroup">
+ <clipPath id="presentation_clip_path" clipPathUnits="userSpaceOnUse">
+ <rect x="0" y="0" width="13550" height="13550"/>
+ </clipPath>
+ <clipPath id="presentation_clip_path_shrink" clipPathUnits="userSpaceOnUse">
+ <rect x="13" y="13" width="13523" height="13523"/>
+ </clipPath>
+ </defs>
+ <defs class="TextShapeIndex">
+ <g ooo:slide="id1" ooo:id-list="id3"/>
+ </defs>
+ <defs class="EmbeddedBulletChars">
+ <g id="bullet-char-template-57356" transform="scale(0.00048828125,-0.00048828125)">
+ <path d="M 580,1141 L 1163,571 580,0 -4,571 580,1141 Z"/>
+ </g>
+ <g id="bullet-char-template-57354" transform="scale(0.00048828125,-0.00048828125)">
+ <path d="M 8,1128 L 1137,1128 1137,0 8,0 8,1128 Z"/>
+ </g>
+ <g id="bullet-char-template-10146" transform="scale(0.00048828125,-0.00048828125)">
+ <path d="M 174,0 L 602,739 174,1481 1456,739 174,0 Z M 1358,739 L 309,1346 659,739 1358,739 Z"/>
+ </g>
+ <g id="bullet-char-template-10132" transform="scale(0.00048828125,-0.00048828125)">
+ <path d="M 2015,739 L 1276,0 717,0 1260,543 174,543 174,936 1260,936 717,1481 1274,1481 2015,739 Z"/>
+ </g>
+ <g id="bullet-char-template-10007" transform="scale(0.00048828125,-0.00048828125)">
+ <path d="M 0,-2 C -7,14 -16,27 -25,37 L 356,567 C 262,823 215,952 215,954 215,979 228,992 255,992 264,992 276,990 289,987 310,991 331,999 354,1012 L 381,999 492,748 772,1049 836,1024 860,1049 C 881,1039 901,1025 922,1006 886,937 835,863 770,784 769,783 710,716 594,584 L 774,223 C 774,196 753,168 711,139 L 727,119 C 717,90 699,76 672,76 641,76 570,178 457,381 L 164,-76 C 142,-110 111,-127 72,-127 30,-127 9,-110 8,-76 1,-67 -2,-52 -2,-32 -2,-23 -1,-13 0,-2 Z"/>
+ </g>
+ <g id="bullet-char-template-10004" transform="scale(0.00048828125,-0.00048828125)">
+ <path d="M 285,-33 C 182,-33 111,30 74,156 52,228 41,333 41,471 41,549 55,616 82,672 116,743 169,778 240,778 293,778 328,747 346,684 L 369,508 C 377,444 397,411 428,410 L 1163,1116 C 1174,1127 1196,1133 1229,1133 1271,1133 1292,1118 1292,1087 L 1292,965 C 1292,929 1282,901 1262,881 L 442,47 C 390,-6 338,-33 285,-33 Z"/>
+ </g>
+ <g id="bullet-char-template-9679" transform="scale(0.00048828125,-0.00048828125)">
+ <path d="M 813,0 C 632,0 489,54 383,161 276,268 223,411 223,592 223,773 276,916 383,1023 489,1130 632,1184 813,1184 992,1184 1136,1130 1245,1023 1353,916 1407,772 1407,592 1407,412 1353,268 1245,161 1136,54 992,0 813,0 Z"/>
+ </g>
+ <g id="bullet-char-template-8226" transform="scale(0.00048828125,-0.00048828125)">
+ <path d="M 346,457 C 273,457 209,483 155,535 101,586 74,649 74,723 74,796 101,859 155,911 209,963 273,989 346,989 419,989 480,963 531,910 582,859 608,796 608,723 608,648 583,586 532,535 482,483 420,457 346,457 Z"/>
+ </g>
+ <g id="bullet-char-template-8211" transform="scale(0.00048828125,-0.00048828125)">
+ <path d="M -4,459 L 1135,459 1135,606 -4,606 -4,459 Z"/>
+ </g>
+ <g id="bullet-char-template-61548" transform="scale(0.00048828125,-0.00048828125)">
+ <path d="M 173,740 C 173,903 231,1043 346,1159 462,1274 601,1332 765,1332 928,1332 1067,1274 1183,1159 1299,1043 1357,903 1357,740 1357,577 1299,437 1183,322 1067,206 928,148 765,148 601,148 462,206 346,322 231,437 173,577 173,740 Z"/>
+ </g>
+ </defs>
+ <g>
+ <g id="id2" class="Master_Slide">
+ <g id="bg-id2" class="Background"/>
+ <g id="bo-id2" class="BackgroundObjects"/>
+ </g>
+ </g>
+ <g class="SlideGroup">
+ <g>
+ <g id="container-id1">
+ <g id="id1" class="Slide" clip-path="url(#presentation_clip_path)">
+ <g class="Page">
+ <g class="Graphic">
+ <g id="id3">
+ <rect class="BoundingBox" stroke="none" fill="none" x="2881" y="247" width="8067" height="12907"/>
+ <defs>
+ <clipPath id="clip_path_1" clipPathUnits="userSpaceOnUse">
+ <path d="M 2881,247 L 10947,247 10947,13153 2881,13153 2881,247 Z"/>
+ </clipPath>
+ </defs>
+ <g clip-path="url(#clip_path_1)">
+ <path fill="rgb(0,0,0)" stroke="none" d="M 10690,12354 C 10347,12719 9430,13153 8235,13153 5190,13153 4529,10915 4529,9609 L 4529,5979 3332,5979 C 3194,5979 3080,5866 3080,5727 L 3080,4013 C 3080,3831 3194,3670 3365,3610 4928,3060 5419,1694 5490,658 5510,381 5654,247 5896,247 L 7683,247 C 7821,247 7935,360 7935,499 L 7935,3403 10027,3403 C 10166,3403 10279,3514 10279,3652 L 10279,5712 C 10279,5851 10166,5964 10027,5964 L 7925,5964 7925,9322 C 7925,10184 8522,10673 9639,10224 9760,10176 9866,10143 9959,10168 10047,10191 10105,10254 10145,10368 L 10700,11988 C 10745,12114 10783,12256 10690,12354 L 10690,12354 Z"/>
+ </g>
+ </g>
+ </g>
+ </g>
+ </g>
+ </g>
+ </g>
+ </g>
+</svg> \ No newline at end of file
diff --git a/img/twitter.svg b/img/twitter.svg
new file mode 100644
index 00000000..9ac9e0b9
--- /dev/null
+++ b/img/twitter.svg
@@ -0,0 +1 @@
+<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="twitter" class="svg-inline--fa fa-twitter fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"></path></svg> \ No newline at end of file
diff --git a/l10n/uk.json b/l10n/uk.json
index 493146f9..0dafc44a 100644
--- a/l10n/uk.json
+++ b/l10n/uk.json
@@ -155,4 +155,4 @@
"Your web browser is out of date" : "Ваш бразуер застарів",
"This application is not compatible with Internet Explorer" : "Застосунок не сумісний з Internet Explorer"
},"pluralForm" :"nplurals=4; plural=(n % 1 == 0 && n % 10 == 1 && n % 100 != 11 ? 0 : n % 1 == 0 && n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14) ? 1 : n % 1 == 0 && (n % 10 ==0 || (n % 10 >=5 && n % 10 <=9) || (n % 100 >=11 && n % 100 <=14 )) ? 2: 3);"
-} \ No newline at end of file
+}
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
new file mode 100644
index 00000000..565fe5b7
--- /dev/null
+++ b/lib/AppInfo/Application.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OCA\Contacts\AppInfo;
+
+use OCP\AppFramework\App;
+
+class Application extends App {
+ public const APP_ID = 'contacts';
+
+ public function __construct() {
+ parent::__construct(self::APP_ID);
+ }
+
+ public const AVAIL_SETTINGS = [
+ 'allowSocialSync' => 'yes',
+ ];
+}
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php
index 0ea64fd3..d40b74ce 100644
--- a/lib/Controller/PageController.php
+++ b/lib/Controller/PageController.php
@@ -23,10 +23,11 @@
namespace OCA\Contacts\Controller;
+use OCA\Contacts\Service\SocialApiService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
-use OCP\IInitialStateService;
use OCP\IConfig;
+use OCP\IInitialStateService;
use OCP\IRequest;
use OCP\L10N\IFactory;
use OCP\Util;
@@ -43,17 +44,22 @@ class PageController extends Controller {
/** @var IFactory */
private $languageFactory;
+ /** @var SocialApiService */
+ private $socialApiService;
+
public function __construct(string $appName,
IRequest $request,
IConfig $config,
IInitialStateService $initialStateService,
- IFactory $languageFactory) {
+ IFactory $languageFactory,
+ SocialApiService $socialApiService) {
parent::__construct($appName, $request);
$this->appName = $appName;
$this->config = $config;
$this->initialStateService = $initialStateService;
$this->languageFactory = $languageFactory;
+ $this->socialApiService = $socialApiService;
}
/**
@@ -65,10 +71,12 @@ class PageController extends Controller {
public function index(): TemplateResponse {
$locales = $this->languageFactory->findAvailableLocales();
$defaultProfile = $this->config->getAppValue($this->appName, 'defaultProfile', 'HOME');
+ $supportedNetworks = $this->socialApiService->getSupportedNetworks();
$this->initialStateService->provideInitialState($this->appName, 'locales', $locales);
$this->initialStateService->provideInitialState($this->appName, 'defaultProfile', $defaultProfile);
-
+ $this->initialStateService->provideInitialState($this->appName, 'supportedNetworks', $supportedNetworks);
+
Util::addScript($this->appName, 'contacts');
Util::addStyle($this->appName, 'contacts');
diff --git a/lib/Controller/SocialApiController.php b/lib/Controller/SocialApiController.php
new file mode 100644
index 00000000..4898d915
--- /dev/null
+++ b/lib/Controller/SocialApiController.php
@@ -0,0 +1,95 @@
+<?php
+/**
+ * @copyright Copyright (c) 2020 Matthias Heinisch <nextcloud@matthiasheinisch.de>
+ *
+ * @author Matthias Heinisch <nextcloud@matthiasheinisch.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Contacts\Controller;
+
+use OCA\Contacts\AppInfo\Application;
+use OCA\Contacts\Service\SocialApiService;
+use OCP\AppFramework\ApiController;
+use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\JSONResponse;
+use OCP\IConfig;
+use OCP\IRequest;
+
+class SocialApiController extends ApiController {
+
+ /** @var IConfig */
+ private $config;
+
+ /** @var SocialApiService */
+ private $socialApiService;
+
+ public function __construct(IRequest $request,
+ IConfig $config,
+ SocialApiService $socialApiService) {
+ parent::__construct(Application::APP_ID, $request);
+
+ $this->config = $config;
+ $this->socialApiService = $socialApiService;
+ }
+
+
+ /**
+ * update appconfig (admin setting)
+ *
+ * @param {String} key the identifier to change
+ * @param {String} allow the value to set
+ *
+ * @returns {JSONResponse} an empty JSONResponse with respective http status code
+ */
+ public function setAppConfig($key, $allow) {
+ $permittedKeys = ['allowSocialSync'];
+ if (!in_array($key, $permittedKeys)) {
+ return new JSONResponse([], Http::STATUS_FORBIDDEN);
+ }
+ $this->config->setAppValue(Application::APP_ID, $key, $allow);
+ return new JSONResponse([], Http::STATUS_OK);
+ }
+
+ /**
+ * @NoAdminRequired
+ *
+ * returns an array of supported social networks
+ *
+ * @returns {array} array of the supported social networks
+ */
+ public function getSupportedNetworks() : array {
+ return $this->socialApiService->getSupportedNetworks();
+ }
+
+
+ /**
+ * @NoAdminRequired
+ *
+ * Retrieves social profile data for a contact and updates the entry
+ *
+ * @param {String} addressbookId the addressbook identifier
+ * @param {String} contactId the contact identifier
+ * @param {String} network the social network to use (if unkown: take first match)
+ *
+ * @returns {JSONResponse} an empty JSONResponse with respective http status code
+ */
+ public function updateContact(string $addressbookId, string $contactId, string $network) : JSONResponse {
+ return $this->socialApiService->updateContact($addressbookId, $contactId, $network);
+ }
+}
diff --git a/lib/Service/Social/CompositeSocialProvider.php b/lib/Service/Social/CompositeSocialProvider.php
new file mode 100644
index 00000000..a5f6e484
--- /dev/null
+++ b/lib/Service/Social/CompositeSocialProvider.php
@@ -0,0 +1,95 @@
+<?php
+/**
+ * @copyright 2020 Matthias Heinisch <nextcloud@matthiasheinisch.de>
+ *
+ * @author Matthias Heinisch <nextcloud@matthiasheinisch.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Contacts\Service\Social;
+
+/**
+ * Composition of all social providers for easier usage
+ */
+class CompositeSocialProvider {
+
+ /** @var ISocialProvider[] */
+ private $providers;
+
+ public function __construct(InstagramProvider $instagramProvider,
+ MastodonProvider $mastodonProvider,
+ FacebookProvider $facebookProvider,
+ TwitterProvider $twitte