summaryrefslogtreecommitdiffstats
path: root/src/services
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2020-07-02 17:49:42 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2020-08-21 09:56:08 +0200
commitf44028131344636e45c5158cc13ccbe4edd19097 (patch)
tree12023f8c4d62c6ba173e572f89e15c1565799446 /src/services
parent63b2aff43903d51fc382a7c6cb0019845363c183 (diff)
Add PatchPlugin
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/services')
-rw-r--r--src/services/appendContactToGroup.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/services/appendContactToGroup.js b/src/services/appendContactToGroup.js
new file mode 100644
index 00000000..b00cecc5
--- /dev/null
+++ b/src/services/appendContactToGroup.js
@@ -0,0 +1,41 @@
+/**
+ * @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/>.
+ *
+ */
+import axios from '@nextcloud/axios'
+
+/**
+ * Append a group to a contact
+ * @param {Contact} contact the contact model
+ * @param {string} groupName the group name
+ */
+const appendContactToGroup = async function(contact, groupName) {
+ const groups = contact.groups
+ groups.push(groupName)
+
+ return axios.patch(contact.url, {}, {
+ headers: {
+ 'X-PROPERTY': 'CATEGORIES',
+ 'X-PROPERTY-REPLACE': groups.join(','),
+ },
+ })
+}
+
+export default appendContactToGroup