Compare commits
81 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 109ca703ef | |||
| 794746e20d | |||
| 85848c2d6c | |||
| 86d4681fcd | |||
| 0a14a29ac6 | |||
| df07b4b672 | |||
| 7bd151ad62 | |||
| ddc867ad06 | |||
| a111f5b5e9 | |||
| 1897805483 | |||
| 8919db6fc3 | |||
| d69b26af51 | |||
| a8dae85f42 | |||
| d3bc62f810 | |||
| 13683adfba | |||
| e183b62aba | |||
| ce9d72b50d | |||
| 92358a673b | |||
| 99308cd7a4 | |||
| 561ba24090 | |||
| 3e1cb9a500 | |||
| 5ae8e3e001 | |||
| faea3637e0 | |||
| 79eaa5217d | |||
| 0e0891f1a8 | |||
| 33aaf666ae | |||
| a634938799 | |||
| 14ff4ab2f1 | |||
| b3de21e7d1 | |||
| 72a373b17c | |||
| bc290f3bed | |||
| a4704ad267 | |||
| d1762ad5df | |||
| df1467c518 | |||
| 7cdd97ca59 | |||
| 5b36d10b04 | |||
| 56699fdd4d | |||
| fcf1cc41c8 | |||
| b8640ccb1d | |||
| 4b51e2dd9a | |||
| e068e14004 | |||
| 941fd4c6cd | |||
| f2021d478e | |||
| 900ceb2bb5 | |||
| 9b498e6786 | |||
| ca06298e64 | |||
| dc8d7d59d4 | |||
| 55d2123c33 | |||
| 274c1f34af | |||
| 75c878507e | |||
| f1ea8ead74 | |||
| 23de84610e | |||
| 0cb24b4759 | |||
| 7fa97231a1 | |||
| 2291db32c5 | |||
| 491bd3b858 | |||
| 064d5e3ab1 | |||
| c512829cd4 | |||
| 69c728cd5a | |||
| fca6d4f25f | |||
| b668e1d4ed | |||
| 5b760a1b74 | |||
| 1f8dccf898 | |||
| b9d8eb3950 | |||
| 053fe2d52c | |||
| b3846fa633 | |||
| a8ef4cfb77 | |||
| 58317cd205 | |||
| 642e2bffe7 | |||
| d6d423b946 | |||
| e92a963088 | |||
| f3a8246e34 | |||
| f65d261598 | |||
| c9f50e452b | |||
| c820d015e7 | |||
| 78cbd1f370 | |||
| 70d2bab52d | |||
| 166a6366f8 | |||
| ac8a64c4c1 | |||
| 2ee8a5e286 | |||
| 9d2620faea |
@@ -1,26 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<mokoplatform xmlns="https://standards.mokoconsulting.tech/mokoplatform/1.0" schema-version="1.0">
|
|
||||||
<identity>
|
|
||||||
<name>MokoSuiteCross</name>
|
|
||||||
<display-name>Package - MokoSuiteCross</display-name>
|
|
||||||
<org>MokoConsulting</org>
|
|
||||||
<description>Cross-posting Joomla content to social media, email marketing, and chat platforms</description>
|
|
||||||
<version>01.05.00</version>
|
|
||||||
<license spdx="GPL-3.0-or-later">GNU General Public License v3</license>
|
|
||||||
</identity>
|
|
||||||
<governance>
|
|
||||||
<platform>joomla</platform>
|
|
||||||
<standards-version>05.00.00</standards-version>
|
|
||||||
<standards-source>https://git.mokoconsulting.tech/MokoConsulting/mokoplatform</standards-source>
|
|
||||||
</governance>
|
|
||||||
<build>
|
|
||||||
<language>PHP</language>
|
|
||||||
<package-type>joomla-extension</package-type>
|
|
||||||
<entry-point>source/</entry-point>
|
|
||||||
</build>
|
|
||||||
<licensing>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
<dlid>true</dlid>
|
|
||||||
<update-server>https://git.mokoconsulting.tech/{org}/{repo}/updates.xml</update-server>
|
|
||||||
</licensing>
|
|
||||||
</mokoplatform>
|
|
||||||
@@ -164,6 +164,75 @@ jobs:
|
|||||||
echo "**Manifest validation passed.**" >> $GITHUB_STEP_SUMMARY
|
echo "**Manifest validation passed.**" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Update server & packaging checks
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
echo "### Update Server & Packaging" >> $GITHUB_STEP_SUMMARY
|
||||||
|
WARNINGS=0
|
||||||
|
|
||||||
|
# Find the extension manifest
|
||||||
|
MANIFEST=""
|
||||||
|
for XML_FILE in $(find . -maxdepth 2 -name "*.xml" -not -path "./.git/*" -not -path "./vendor/*"); do
|
||||||
|
if grep -q "<extension" "$XML_FILE" 2>/dev/null; then
|
||||||
|
MANIFEST="$XML_FILE"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$MANIFEST" ]; then
|
||||||
|
echo "No manifest found — skipping." >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
EXT_TYPE=$(grep -oP '<extension[^>]*\btype="\K[^"]+' "$MANIFEST" | head -1)
|
||||||
|
|
||||||
|
# 1. Check <updateservers> exists and uses MokoGitea update server
|
||||||
|
if ! grep -q '<updateservers>' "$MANIFEST" 2>/dev/null; then
|
||||||
|
echo "::warning file=${MANIFEST}::Missing \`<updateservers>\` tag — extension will not receive OTA updates"
|
||||||
|
echo "- **Missing** \`<updateservers>\` — extension will not receive OTA updates" >> $GITHUB_STEP_SUMMARY
|
||||||
|
WARNINGS=$((WARNINGS + 1))
|
||||||
|
else
|
||||||
|
SERVER_URL=$(grep -oP '<server[^>]*>\K[^<]+' "$MANIFEST" 2>/dev/null | head -1)
|
||||||
|
if [ -z "$SERVER_URL" ]; then
|
||||||
|
echo "::warning file=${MANIFEST}::\`<updateservers>\` is empty — no server URL defined"
|
||||||
|
echo "- **Empty** \`<updateservers>\` — no server URL defined" >> $GITHUB_STEP_SUMMARY
|
||||||
|
WARNINGS=$((WARNINGS + 1))
|
||||||
|
elif ! echo "$SERVER_URL" | grep -q 'git\.mokoconsulting\.tech'; then
|
||||||
|
echo "::warning file=${MANIFEST}::Update server does not use MokoGitea engine: ${SERVER_URL}"
|
||||||
|
echo "- **Non-MokoGitea update server:** \`${SERVER_URL}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo " Expected: \`https://git.mokoconsulting.tech/{org}/{repo}/updates.xml\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
WARNINGS=$((WARNINGS + 1))
|
||||||
|
else
|
||||||
|
echo "- \`<updateservers>\`: MokoGitea engine ✓" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2. Check <dlid> tag exists
|
||||||
|
if ! grep -q '<dlid' "$MANIFEST" 2>/dev/null; then
|
||||||
|
echo "::warning file=${MANIFEST}::Missing \`<dlid>\` tag — download ID authentication is not configured"
|
||||||
|
echo "- **Missing** \`<dlid>\` — download ID authentication not configured" >> $GITHUB_STEP_SUMMARY
|
||||||
|
WARNINGS=$((WARNINGS + 1))
|
||||||
|
else
|
||||||
|
echo "- \`<dlid>\`: present ✓" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3. For packages: check <childuninstall> tag
|
||||||
|
if [ "$EXT_TYPE" = "package" ]; then
|
||||||
|
if ! grep -q '<childuninstall>' "$MANIFEST" 2>/dev/null; then
|
||||||
|
echo "::warning file=${MANIFEST}::Package is missing \`<childuninstall>\` — child extensions will not be removed on uninstall"
|
||||||
|
echo "- **Missing** \`<childuninstall>\` — child extensions will remain when package is uninstalled" >> $GITHUB_STEP_SUMMARY
|
||||||
|
WARNINGS=$((WARNINGS + 1))
|
||||||
|
else
|
||||||
|
echo "- \`<childuninstall>\`: present ✓" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
if [ "$WARNINGS" -gt 0 ]; then
|
||||||
|
echo "**${WARNINGS} packaging warning(s).** These won't block CI but should be addressed." >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
echo "**Update server & packaging checks passed.**" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Check language files referenced in manifest
|
- name: Check language files referenced in manifest
|
||||||
run: |
|
run: |
|
||||||
echo "### Language File Check" >> $GITHUB_STEP_SUMMARY
|
echo "### Language File Check" >> $GITHUB_STEP_SUMMARY
|
||||||
@@ -647,6 +716,268 @@ jobs:
|
|||||||
echo "**Service provider check passed.**" >> $GITHUB_STEP_SUMMARY
|
echo "**Service provider check passed.**" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Script file reference check
|
||||||
|
run: |
|
||||||
|
echo "### Script File Reference" >> $GITHUB_STEP_SUMMARY
|
||||||
|
ERRORS=0
|
||||||
|
|
||||||
|
MANIFEST=""
|
||||||
|
for XML_FILE in $(find . -maxdepth 2 -name "*.xml" -not -path "./.git/*" -not -path "./vendor/*"); do
|
||||||
|
if grep -q "<extension" "$XML_FILE" 2>/dev/null; then
|
||||||
|
MANIFEST="$XML_FILE"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$MANIFEST" ]; then
|
||||||
|
echo "No manifest found — skipping." >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
MANIFEST_DIR=$(dirname "$MANIFEST")
|
||||||
|
SCRIPT_FILE=$(grep -oP '<scriptfile>\K[^<]+' "$MANIFEST" 2>/dev/null | head -1)
|
||||||
|
if [ -z "$SCRIPT_FILE" ]; then
|
||||||
|
echo "No \`<scriptfile>\` referenced — skipping." >> $GITHUB_STEP_SUMMARY
|
||||||
|
elif [ ! -f "${MANIFEST_DIR}/${SCRIPT_FILE}" ]; then
|
||||||
|
echo "::error file=${MANIFEST}::Manifest references \`<scriptfile>${SCRIPT_FILE}</scriptfile>\` but file does not exist"
|
||||||
|
echo "- **Missing** \`${SCRIPT_FILE}\` — referenced in \`<scriptfile>\` but not found" >> $GITHUB_STEP_SUMMARY
|
||||||
|
ERRORS=$((ERRORS + 1))
|
||||||
|
else
|
||||||
|
echo "- \`${SCRIPT_FILE}\`: present ✓" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
if [ "${ERRORS}" -gt 0 ]; then
|
||||||
|
echo "**${ERRORS} script file issue(s).**" >> $GITHUB_STEP_SUMMARY
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "**Script file reference check passed.**" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Media folder validation
|
||||||
|
run: |
|
||||||
|
echo "### Media Folder Validation" >> $GITHUB_STEP_SUMMARY
|
||||||
|
ERRORS=0
|
||||||
|
|
||||||
|
MANIFEST=""
|
||||||
|
for XML_FILE in $(find . -maxdepth 2 -name "*.xml" -not -path "./.git/*" -not -path "./vendor/*"); do
|
||||||
|
if grep -q "<extension" "$XML_FILE" 2>/dev/null; then
|
||||||
|
MANIFEST="$XML_FILE"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$MANIFEST" ]; then
|
||||||
|
echo "No manifest found — skipping." >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
MANIFEST_DIR=$(dirname "$MANIFEST")
|
||||||
|
|
||||||
|
# Check <media> tag and its folder/filename children
|
||||||
|
MEDIA_DEST=$(grep -oP '<media[^>]*\bdestination="\K[^"]+' "$MANIFEST" 2>/dev/null | head -1)
|
||||||
|
MEDIA_FOLDER=$(grep -oP '<media[^>]*\bfolder="\K[^"]+' "$MANIFEST" 2>/dev/null | head -1)
|
||||||
|
|
||||||
|
if [ -z "$MEDIA_DEST" ] && [ -z "$MEDIA_FOLDER" ]; then
|
||||||
|
echo "No \`<media>\` tag found — skipping." >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
if [ -n "$MEDIA_FOLDER" ] && [ ! -d "${MANIFEST_DIR}/${MEDIA_FOLDER}" ]; then
|
||||||
|
echo "::error file=${MANIFEST}::\`<media folder=\"${MEDIA_FOLDER}\">\` references missing directory"
|
||||||
|
echo "- **Missing** media folder \`${MEDIA_FOLDER}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
ERRORS=$((ERRORS + 1))
|
||||||
|
else
|
||||||
|
echo "- Media folder \`${MEDIA_FOLDER:-(inline)}\`: present ✓" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
# Check child references inside <media> block
|
||||||
|
if [ -n "$MEDIA_FOLDER" ]; then
|
||||||
|
MEDIA_FOLDERS=$(sed -n '/<media /,/<\/media>/p' "$MANIFEST" | grep -oP '<folder>\K[^<]+' 2>/dev/null || true)
|
||||||
|
for F in $MEDIA_FOLDERS; do
|
||||||
|
if [ ! -d "${MANIFEST_DIR}/${MEDIA_FOLDER}/${F}" ]; then
|
||||||
|
echo "- **Missing** media subfolder \`${MEDIA_FOLDER}/${F}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
ERRORS=$((ERRORS + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
MEDIA_FILES=$(sed -n '/<media /,/<\/media>/p' "$MANIFEST" | grep -oP '<filename>\K[^<]+' 2>/dev/null || true)
|
||||||
|
for F in $MEDIA_FILES; do
|
||||||
|
if [ ! -f "${MANIFEST_DIR}/${MEDIA_FOLDER}/${F}" ]; then
|
||||||
|
echo "- **Missing** media file \`${MEDIA_FOLDER}/${F}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
ERRORS=$((ERRORS + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
if [ "${ERRORS}" -gt 0 ]; then
|
||||||
|
echo "**${ERRORS} media reference issue(s).**" >> $GITHUB_STEP_SUMMARY
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "**Media folder validation passed.**" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Target platform check
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
echo "### Target Platform Check" >> $GITHUB_STEP_SUMMARY
|
||||||
|
WARNINGS=0
|
||||||
|
|
||||||
|
MANIFEST=""
|
||||||
|
for XML_FILE in $(find . -maxdepth 2 -name "*.xml" -not -path "./.git/*" -not -path "./vendor/*"); do
|
||||||
|
if grep -q "<extension" "$XML_FILE" 2>/dev/null; then
|
||||||
|
MANIFEST="$XML_FILE"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$MANIFEST" ]; then
|
||||||
|
echo "No manifest found — skipping." >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
# Check updates.xml for targetplatform if it exists
|
||||||
|
if [ -f "updates.xml" ]; then
|
||||||
|
if ! grep -q '<targetplatform' "updates.xml" 2>/dev/null; then
|
||||||
|
echo "::warning file=updates.xml::No \`<targetplatform>\` found — Joomla updater cannot filter by compatible version"
|
||||||
|
echo "- **Missing** \`<targetplatform>\` in updates.xml" >> $GITHUB_STEP_SUMMARY
|
||||||
|
WARNINGS=$((WARNINGS + 1))
|
||||||
|
else
|
||||||
|
echo "- \`<targetplatform>\` in updates.xml: present ✓" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check manifest for minimum PHP/Joomla version hints
|
||||||
|
if ! grep -qP '<php_minimum>|targetplatform|joomla.*version' "$MANIFEST" 2>/dev/null; then
|
||||||
|
echo "::warning file=${MANIFEST}::No minimum Joomla or PHP version constraint found in manifest"
|
||||||
|
echo "- **Missing** version constraints (\`<php_minimum>\` or \`<targetplatform>\`)" >> $GITHUB_STEP_SUMMARY
|
||||||
|
WARNINGS=$((WARNINGS + 1))
|
||||||
|
else
|
||||||
|
echo "- Version constraints in manifest: present ✓" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
if [ "$WARNINGS" -gt 0 ]; then
|
||||||
|
echo "**${WARNINGS} target platform warning(s).**" >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
echo "**Target platform check passed.**" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Changelog URL check
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
echo "### Changelog URL Check" >> $GITHUB_STEP_SUMMARY
|
||||||
|
WARNINGS=0
|
||||||
|
|
||||||
|
MANIFEST=""
|
||||||
|
for XML_FILE in $(find . -maxdepth 2 -name "*.xml" -not -path "./.git/*" -not -path "./vendor/*"); do
|
||||||
|
if grep -q "<extension" "$XML_FILE" 2>/dev/null; then
|
||||||
|
MANIFEST="$XML_FILE"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$MANIFEST" ]; then
|
||||||
|
echo "No manifest found — skipping." >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
if ! grep -q '<changelogurl>' "$MANIFEST" 2>/dev/null; then
|
||||||
|
echo "::warning file=${MANIFEST}::Missing \`<changelogurl>\` — Joomla updater will not display changelogs"
|
||||||
|
echo "- **Missing** \`<changelogurl>\` — Joomla 4+ shows changelogs in the update manager when this is set" >> $GITHUB_STEP_SUMMARY
|
||||||
|
WARNINGS=$((WARNINGS + 1))
|
||||||
|
else
|
||||||
|
CHANGELOG_URL=$(grep -oP '<changelogurl>\K[^<]+' "$MANIFEST" | head -1)
|
||||||
|
echo "- \`<changelogurl>\`: \`${CHANGELOG_URL}\` ✓" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
if [ "$WARNINGS" -gt 0 ]; then
|
||||||
|
echo "**${WARNINGS} changelog URL warning(s).**" >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
echo "**Changelog URL check passed.**" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Duplicate file references check
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
echo "### Duplicate File References" >> $GITHUB_STEP_SUMMARY
|
||||||
|
WARNINGS=0
|
||||||
|
|
||||||
|
MANIFEST=""
|
||||||
|
for XML_FILE in $(find . -maxdepth 2 -name "*.xml" -not -path "./.git/*" -not -path "./vendor/*"); do
|
||||||
|
if grep -q "<extension" "$XML_FILE" 2>/dev/null; then
|
||||||
|
MANIFEST="$XML_FILE"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$MANIFEST" ]; then
|
||||||
|
echo "No manifest found — skipping." >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
# Extract all <filename> and <folder> references
|
||||||
|
ALL_REFS=$(grep -oP '<(filename|folder)[^>]*>\K[^<]+' "$MANIFEST" 2>/dev/null | sort || true)
|
||||||
|
if [ -z "$ALL_REFS" ]; then
|
||||||
|
echo "No file/folder references found — skipping." >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
DUPES=$(echo "$ALL_REFS" | uniq -d)
|
||||||
|
if [ -n "$DUPES" ]; then
|
||||||
|
while IFS= read -r DUP; do
|
||||||
|
COUNT=$(echo "$ALL_REFS" | grep -cx "$DUP")
|
||||||
|
echo "::warning file=${MANIFEST}::Duplicate reference: \`${DUP}\` appears ${COUNT} times (may be valid if in different sections)"
|
||||||
|
echo "- **Duplicate:** \`${DUP}\` (${COUNT}x) — check if cross-section" >> $GITHUB_STEP_SUMMARY
|
||||||
|
WARNINGS=$((WARNINGS + 1))
|
||||||
|
done <<< "$DUPES"
|
||||||
|
else
|
||||||
|
TOTAL=$(echo "$ALL_REFS" | wc -l)
|
||||||
|
echo "All ${TOTAL} file/folder references are unique." >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
if [ "$WARNINGS" -gt 0 ]; then
|
||||||
|
echo "**${WARNINGS} duplicate reference(s) found.** Review for cross-section validity." >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
echo "**Duplicate file references check passed.**" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Empty language keys check
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
echo "### Empty Language Keys" >> $GITHUB_STEP_SUMMARY
|
||||||
|
WARNINGS=0
|
||||||
|
|
||||||
|
LANG_FILES=$(find . -name "*.ini" -not -path "./.git/*" -not -path "./vendor/*" 2>/dev/null)
|
||||||
|
if [ -z "$LANG_FILES" ]; then
|
||||||
|
echo "No .ini language files found — skipping." >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
TOTAL_FILES=0
|
||||||
|
for FILE in $LANG_FILES; do
|
||||||
|
TOTAL_FILES=$((TOTAL_FILES + 1))
|
||||||
|
# Find lines with KEY= but no value (empty or whitespace-only after =)
|
||||||
|
EMPTY_KEYS=$(grep -nP '^[A-Z_]+=\s*$' "$FILE" 2>/dev/null || true)
|
||||||
|
if [ -n "$EMPTY_KEYS" ]; then
|
||||||
|
COUNT=$(echo "$EMPTY_KEYS" | wc -l)
|
||||||
|
echo "::warning file=${FILE}::${COUNT} empty language key(s)"
|
||||||
|
echo "- \`${FILE}\`: ${COUNT} empty key(s)" >> $GITHUB_STEP_SUMMARY
|
||||||
|
while IFS= read -r LINE; do
|
||||||
|
LINE_NUM=$(echo "$LINE" | cut -d: -f1)
|
||||||
|
KEY=$(echo "$LINE" | cut -d: -f2 | cut -d= -f1)
|
||||||
|
echo " - Line ${LINE_NUM}: \`${KEY}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
done <<< "$EMPTY_KEYS"
|
||||||
|
WARNINGS=$((WARNINGS + COUNT))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$WARNINGS" -eq 0 ]; then
|
||||||
|
echo "All ${TOTAL_FILES} language file(s) have populated keys." >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
if [ "$WARNINGS" -gt 0 ]; then
|
||||||
|
echo "**${WARNINGS} empty language key(s) across ${TOTAL_FILES} file(s).**" >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
echo "**Empty language keys check passed.**" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
|
||||||
release-readiness:
|
release-readiness:
|
||||||
name: Release Readiness Check
|
name: Release Readiness Check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
name: "Publish to Composer"
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
- '[0-9]*.[0-9]*.[0-9]*'
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
env:
|
|
||||||
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
name: Publish Package
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: >-
|
|
||||||
!contains(github.event.head_commit.message, '[skip ci]') &&
|
|
||||||
!contains(github.event.head_commit.message, '[skip publish]')
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup PHP
|
|
||||||
run: |
|
|
||||||
if ! command -v php &> /dev/null; then
|
|
||||||
sudo apt-get update -qq
|
|
||||||
sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: composer install --no-dev --no-interaction --prefer-dist --quiet
|
|
||||||
|
|
||||||
- name: Determine version
|
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
VERSION=$(php -r "echo json_decode(file_get_contents('composer.json'))->version;")
|
|
||||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "Package version: ${VERSION}"
|
|
||||||
|
|
||||||
# Gitea Composer Registry — auto-publishes from tags
|
|
||||||
# The tag push itself registers the package at:
|
|
||||||
# https://git.mokoconsulting.tech/api/packages/MokoConsulting/composer
|
|
||||||
- name: Verify Gitea registry
|
|
||||||
run: |
|
|
||||||
echo "Gitea Composer registry auto-publishes from tags."
|
|
||||||
echo "Package available at: ${GITEA_URL}/api/packages/MokoConsulting/composer"
|
|
||||||
echo "Install: composer require mokoconsulting/mokocli"
|
|
||||||
|
|
||||||
# Packagist — notify of new version
|
|
||||||
- name: Notify Packagist
|
|
||||||
if: secrets.PACKAGIST_TOKEN != ''
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.version.outputs.version }}"
|
|
||||||
echo "Notifying Packagist of version ${VERSION}..."
|
|
||||||
curl -sf -X POST \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"repository":{"url":"https://git.mokoconsulting.tech/MokoConsulting/mokocli"}}' \
|
|
||||||
"https://packagist.org/api/update-package?username=mokoconsulting&apiToken=${{ secrets.PACKAGIST_TOKEN }}" \
|
|
||||||
&& echo "Packagist notified" \
|
|
||||||
|| echo "::warning::Packagist notification failed (package may not be registered yet)"
|
|
||||||
|
|
||||||
- name: Summary
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.version.outputs.version }}"
|
|
||||||
echo "## Composer Package Published" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Registry | Status |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "|----------|--------|" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Gitea | \`composer require mokoconsulting/mokocli:${VERSION}\` |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Packagist | \`composer require mokoconsulting/mokocli\` |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# FILE INFORMATION
|
|
||||||
# DEFGROUP: Gitea.Workflow
|
|
||||||
# INGROUP: MokoStandards.Deploy
|
|
||||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards-API
|
|
||||||
# PATH: /templates/workflows/joomla/deploy-manual.yml.template
|
|
||||||
# VERSION: 04.07.00
|
|
||||||
# BRIEF: Manual SFTP deploy to dev server for Joomla repos
|
|
||||||
|
|
||||||
name: "Universal: Deploy to Dev (Manual)"
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
clear_remote:
|
|
||||||
description: 'Delete all remote files before uploading'
|
|
||||||
required: false
|
|
||||||
default: 'false'
|
|
||||||
type: boolean
|
|
||||||
|
|
||||||
env:
|
|
||||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
deploy:
|
|
||||||
name: SFTP Deploy to Dev
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
||||||
|
|
||||||
- name: Setup PHP
|
|
||||||
run: |
|
|
||||||
php -v && composer --version
|
|
||||||
|
|
||||||
- name: Setup MokoStandards tools
|
|
||||||
env:
|
|
||||||
GA_TOKEN: ${{ secrets.GA_TOKEN || secrets.GA_TOKEN || github.token }}
|
|
||||||
MOKO_CLONE_TOKEN: ${{ secrets.GA_TOKEN || secrets.GA_TOKEN || github.token }}
|
|
||||||
MOKO_CLONE_HOST: ${{ secrets.GA_TOKEN && 'git.mokoconsulting.tech/MokoConsulting' || 'github.com/mokoconsulting-tech' }}
|
|
||||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GA_TOKEN || github.token }}"}}'
|
|
||||||
run: |
|
|
||||||
git clone --depth 1 --branch main --quiet \
|
|
||||||
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/MokoStandards-API.git" \
|
|
||||||
/tmp/mokostandards-api 2>/dev/null || true
|
|
||||||
if [ -d "/tmp/mokostandards-api" ] && [ -f "/tmp/mokostandards-api/composer.json" ]; then
|
|
||||||
cd /tmp/mokostandards-api && composer install --no-dev --no-interaction --quiet 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Check FTP configuration
|
|
||||||
id: check
|
|
||||||
env:
|
|
||||||
HOST: ${{ vars.DEV_FTP_HOST }}
|
|
||||||
PATH_VAR: ${{ vars.DEV_FTP_PATH }}
|
|
||||||
PORT: ${{ vars.DEV_FTP_PORT }}
|
|
||||||
run: |
|
|
||||||
if [ -z "$HOST" ] || [ -z "$PATH_VAR" ]; then
|
|
||||||
echo "DEV_FTP_HOST or DEV_FTP_PATH not configured -- cannot deploy"
|
|
||||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "skip=false" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "host=$HOST" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
REMOTE="${PATH_VAR%/}"
|
|
||||||
echo "remote=$REMOTE" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
[ -z "$PORT" ] && PORT="22"
|
|
||||||
echo "port=$PORT" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Deploy via SFTP
|
|
||||||
if: steps.check.outputs.skip != 'true'
|
|
||||||
env:
|
|
||||||
SFTP_KEY: ${{ secrets.DEV_FTP_KEY }}
|
|
||||||
SFTP_PASS: ${{ secrets.DEV_FTP_PASSWORD }}
|
|
||||||
SFTP_USER: ${{ vars.DEV_FTP_USERNAME }}
|
|
||||||
run: |
|
|
||||||
SOURCE_DIR="src"
|
|
||||||
[ ! -d "$SOURCE_DIR" ] && SOURCE_DIR="htdocs"
|
|
||||||
[ ! -d "$SOURCE_DIR" ] && { echo "No src/ or htdocs/ -- nothing to deploy"; exit 0; }
|
|
||||||
|
|
||||||
printf '{"host":"%s","port":%s,"username":"%s","remotePath":"%s"' \
|
|
||||||
"${{ steps.check.outputs.host }}" "${{ steps.check.outputs.port }}" "$SFTP_USER" "${{ steps.check.outputs.remote }}" \
|
|
||||||
> /tmp/sftp-config.json
|
|
||||||
|
|
||||||
if [ -n "$SFTP_KEY" ]; then
|
|
||||||
echo "$SFTP_KEY" > /tmp/deploy_key
|
|
||||||
chmod 600 /tmp/deploy_key
|
|
||||||
printf ',"privateKeyPath":"/tmp/deploy_key"}' >> /tmp/sftp-config.json
|
|
||||||
else
|
|
||||||
printf ',"password":"%s"}' "$SFTP_PASS" >> /tmp/sftp-config.json
|
|
||||||
fi
|
|
||||||
|
|
||||||
DEPLOY_ARGS=(--path . --src-dir "$SOURCE_DIR" --config /tmp/sftp-config.json)
|
|
||||||
[ "${{ inputs.clear_remote }}" = "true" ] && DEPLOY_ARGS+=(--clear-remote)
|
|
||||||
|
|
||||||
PLATFORM=$(php /tmp/mokostandards-api/cli/platform_detect.php --path . 2>/dev/null || true)
|
|
||||||
if [ "$PLATFORM" = "waas-component" ] && [ -f "/tmp/mokostandards-api/deploy/deploy-joomla.php" ]; then
|
|
||||||
php /tmp/mokostandards-api/deploy/deploy-joomla.php "${DEPLOY_ARGS[@]}"
|
|
||||||
else
|
|
||||||
php /tmp/mokostandards-api/deploy/deploy-sftp.php "${DEPLOY_ARGS[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -f /tmp/deploy_key /tmp/sftp-config.json
|
|
||||||
|
|
||||||
- name: Summary
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
if [ "${{ steps.check.outputs.skip }}" = "true" ]; then
|
|
||||||
echo "### Deploy Skipped -- FTP not configured" >> $GITHUB_STEP_SUMMARY
|
|
||||||
else
|
|
||||||
echo "### Manual Dev Deploy Complete" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Host | \`${{ steps.check.outputs.host }}\` |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Remote | \`${{ steps.check.outputs.remote }}\` |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Clear | ${{ inputs.clear_remote }} |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
fi
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
# FILE INFORMATION
|
# FILE INFORMATION
|
||||||
# DEFGROUP: Gitea.Workflow
|
# DEFGROUP: Gitea.Workflow
|
||||||
# INGROUP: mokocli.Automation
|
# INGROUP: mokocli.Automation
|
||||||
# VERSION: 01.05.00
|
# VERSION: 01.08.17
|
||||||
# BRIEF: Auto-create feature branch when an issue is opened
|
# BRIEF: Auto-create feature branch when an issue is opened
|
||||||
|
|
||||||
name: "Universal: Issue Branch"
|
name: "Universal: Issue Branch"
|
||||||
|
|||||||
@@ -88,8 +88,20 @@ jobs:
|
|||||||
php ${MOKO_CLI}/platform_detect.php --path . --github-output 2>/dev/null || true
|
php ${MOKO_CLI}/platform_detect.php --path . --github-output 2>/dev/null || true
|
||||||
php ${MOKO_CLI}/manifest_read.php --path . --github-output
|
php ${MOKO_CLI}/manifest_read.php --path . --github-output
|
||||||
|
|
||||||
|
- name: Check platform eligibility (Joomla only)
|
||||||
|
id: eligibility
|
||||||
|
run: |
|
||||||
|
PLATFORM="${{ steps.platform.outputs.platform }}"
|
||||||
|
if [[ "$PLATFORM" == joomla* ]] || [[ "$PLATFORM" == "joomla" ]]; then
|
||||||
|
echo "proceed=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "proceed=false" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "::notice::Platform '$PLATFORM' — non-Joomla, skipping pre-release auto-bump"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Resolve metadata and bump version
|
- name: Resolve metadata and bump version
|
||||||
id: meta
|
id: meta
|
||||||
|
if: steps.eligibility.outputs.proceed == 'true'
|
||||||
run: |
|
run: |
|
||||||
# Auto-detect stability from branch name on push, or use input on dispatch
|
# Auto-detect stability from branch name on push, or use input on dispatch
|
||||||
if [ "${{ github.event_name }}" = "push" ]; then
|
if [ "${{ github.event_name }}" = "push" ]; then
|
||||||
@@ -166,6 +178,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
id: release
|
id: release
|
||||||
|
if: steps.eligibility.outputs.proceed == 'true'
|
||||||
run: |
|
run: |
|
||||||
TAG="${{ steps.meta.outputs.tag }}"
|
TAG="${{ steps.meta.outputs.tag }}"
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
@@ -176,6 +189,7 @@ jobs:
|
|||||||
--repo "${GITEA_REPO}" --branch "${{ github.ref_name }}" --prerelease
|
--repo "${GITEA_REPO}" --branch "${{ github.ref_name }}" --prerelease
|
||||||
|
|
||||||
- name: Update release notes from CHANGELOG.md
|
- name: Update release notes from CHANGELOG.md
|
||||||
|
if: steps.eligibility.outputs.proceed == 'true'
|
||||||
run: |
|
run: |
|
||||||
TAG="${{ steps.meta.outputs.tag }}"
|
TAG="${{ steps.meta.outputs.tag }}"
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
@@ -212,6 +226,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build package and upload
|
- name: Build package and upload
|
||||||
id: package
|
id: package
|
||||||
|
if: steps.eligibility.outputs.proceed == 'true'
|
||||||
run: |
|
run: |
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
TAG="${{ steps.meta.outputs.tag }}"
|
TAG="${{ steps.meta.outputs.tag }}"
|
||||||
@@ -225,6 +240,7 @@ jobs:
|
|||||||
# No need to build, commit, or sync updates.xml from workflows
|
# No need to build, commit, or sync updates.xml from workflows
|
||||||
|
|
||||||
- name: "Delete lesser pre-release channels (cascade)"
|
- name: "Delete lesser pre-release channels (cascade)"
|
||||||
|
if: steps.eligibility.outputs.proceed == 'true'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# FILE INFORMATION
|
|
||||||
# DEFGROUP: Gitea.Workflow
|
|
||||||
# INGROUP: MokoStandards.Security
|
|
||||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards
|
|
||||||
# PATH: /.gitea/workflows/security-audit.yml
|
|
||||||
# VERSION: 01.00.00
|
|
||||||
# BRIEF: Dependency vulnerability scanning for composer and npm packages
|
|
||||||
|
|
||||||
name: "Universal: Security Audit"
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 6 * * 1' # Weekly on Monday at 06:00 UTC
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths:
|
|
||||||
- 'composer.json'
|
|
||||||
- 'composer.lock'
|
|
||||||
- 'package.json'
|
|
||||||
- 'package-lock.json'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
env:
|
|
||||||
NTFY_URL: ${{ vars.NTFY_URL || 'https://ntfy.mokoconsulting.tech' }}
|
|
||||||
NTFY_TOPIC: ${{ vars.NTFY_TOPIC || 'gitea-security' }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
audit:
|
|
||||||
name: Dependency Audit
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Composer audit
|
|
||||||
if: hashFiles('composer.lock') != ''
|
|
||||||
run: |
|
|
||||||
echo "=== Composer Security Audit ==="
|
|
||||||
if ! command -v composer &> /dev/null; then
|
|
||||||
sudo apt-get update -qq
|
|
||||||
sudo apt-get install -y -qq php-cli composer >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
composer audit --format=plain 2>&1 | tee /tmp/composer-audit.txt
|
|
||||||
RESULT=$?
|
|
||||||
if [ $RESULT -ne 0 ]; then
|
|
||||||
echo "::warning::Composer vulnerabilities found"
|
|
||||||
echo "composer_vulnerable=true" >> "$GITHUB_ENV"
|
|
||||||
else
|
|
||||||
echo "No known vulnerabilities in composer dependencies"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: NPM audit
|
|
||||||
if: hashFiles('package-lock.json') != ''
|
|
||||||
run: |
|
|
||||||
echo "=== NPM Security Audit ==="
|
|
||||||
npm audit --production 2>&1 | tee /tmp/npm-audit.txt || true
|
|
||||||
if npm audit --production 2>&1 | grep -q "found 0 vulnerabilities"; then
|
|
||||||
echo "No known vulnerabilities in npm dependencies"
|
|
||||||
else
|
|
||||||
echo "::warning::NPM vulnerabilities found"
|
|
||||||
echo "npm_vulnerable=true" >> "$GITHUB_ENV"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Notify on vulnerabilities
|
|
||||||
if: env.composer_vulnerable == 'true' || env.npm_vulnerable == 'true'
|
|
||||||
run: |
|
|
||||||
REPO="${{ github.event.repository.name }}"
|
|
||||||
curl -sS \
|
|
||||||
-H "Title: ${REPO} has vulnerable dependencies" \
|
|
||||||
-H "Tags: lock,warning" \
|
|
||||||
-H "Priority: high" \
|
|
||||||
-d "Security audit found vulnerabilities. Review dependency updates." \
|
|
||||||
"${NTFY_URL}/${NTFY_TOPIC}" || true
|
|
||||||
@@ -1,312 +0,0 @@
|
|||||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# FILE INFORMATION
|
|
||||||
# DEFGROUP: Gitea.Workflow
|
|
||||||
# INGROUP: moko-platform.Universal
|
|
||||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
|
||||||
# PATH: /templates/workflows/update-server.yml
|
|
||||||
# VERSION: 05.00.00
|
|
||||||
# BRIEF: Pre-release build + update server XML for dev/alpha/beta/rc branches
|
|
||||||
#
|
|
||||||
# Thin wrapper around moko-platform CLI tools.
|
|
||||||
# Builds packages, updates updates.xml, and optionally deploys via SFTP.
|
|
||||||
#
|
|
||||||
# Joomla filters update entries by the user's "Minimum Stability" setting.
|
|
||||||
|
|
||||||
name: "Update Server"
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'dev'
|
|
||||||
- 'dev/**'
|
|
||||||
- 'alpha/**'
|
|
||||||
- 'beta/**'
|
|
||||||
- 'rc/**'
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'htdocs/**'
|
|
||||||
pull_request:
|
|
||||||
types: [closed]
|
|
||||||
branches:
|
|
||||||
- 'dev'
|
|
||||||
- 'dev/**'
|
|
||||||
- 'alpha/**'
|
|
||||||
- 'beta/**'
|
|
||||||
- 'rc/**'
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'htdocs/**'
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
stability:
|
|
||||||
description: 'Stability tag'
|
|
||||||
required: true
|
|
||||||
default: 'development'
|
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- development
|
|
||||||
- alpha
|
|
||||||
- beta
|
|
||||||
- rc
|
|
||||||
- stable
|
|
||||||
|
|
||||||
env:
|
|
||||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
||||||
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
|
||||||
GITEA_ORG: ${{ vars.GITEA_ORG || github.repository_owner }}
|
|
||||||
GITEA_REPO: ${{ vars.GITEA_REPO || github.event.repository.name }}
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
update-xml:
|
|
||||||
name: Update Server
|
|
||||||
runs-on: release
|
|
||||||
if: >-
|
|
||||||
github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' || github.event_name == 'push'
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.MOKOGITEA_TOKEN }}
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Setup moko-platform tools
|
|
||||||
env:
|
|
||||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
|
||||||
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
|
||||||
COMPOSER_AUTH: '{"http-basic":{"git.mokoconsulting.tech":{"username":"token","password":"${{ secrets.MOKOGITEA_TOKEN }}"}}}'
|
|
||||||
run: |
|
|
||||||
if ! command -v composer &> /dev/null; then
|
|
||||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
# Always fetch latest CLI tools — never use stale cache from previous runs
|
|
||||||
rm -rf /tmp/moko-platform
|
|
||||||
git clone --depth 1 --branch main --quiet \
|
|
||||||
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git" \
|
|
||||||
/tmp/moko-platform 2>/dev/null || true
|
|
||||||
if [ -d "/tmp/moko-platform" ] && [ -f "/tmp/moko-platform/composer.json" ]; then
|
|
||||||
cd /tmp/moko-platform && composer install --no-dev --no-interaction --quiet 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
echo "MOKO_CLI=/tmp/moko-platform/cli" >> "$GITHUB_ENV"
|
|
||||||
|
|
||||||
- name: Detect platform
|
|
||||||
id: platform
|
|
||||||
run: php ${MOKO_CLI}/manifest_read.php --path . --github-output
|
|
||||||
|
|
||||||
- name: Resolve stability and bump version
|
|
||||||
id: meta
|
|
||||||
run: |
|
|
||||||
BRANCH="${{ github.ref_name }}"
|
|
||||||
|
|
||||||
# Configure git for bot pushes
|
|
||||||
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
|
||||||
git config --local user.name "gitea-actions[bot]"
|
|
||||||
git remote set-url origin "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
|
||||||
|
|
||||||
# Auto-bump patch version
|
|
||||||
php ${MOKO_CLI}/version_bump.php --path . 2>/dev/null || true
|
|
||||||
|
|
||||||
VERSION=$(php ${MOKO_CLI}/version_read.php --path . 2>/dev/null || echo "0.0.0")
|
|
||||||
|
|
||||||
# Strip any existing suffix before applying stability
|
|
||||||
VERSION=$(echo "$VERSION" | sed 's/-\(dev\|alpha\|beta\|rc\)$//')
|
|
||||||
|
|
||||||
# Determine stability from branch or manual input
|
|
||||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
||||||
STABILITY="${{ inputs.stability }}"
|
|
||||||
elif [[ "$BRANCH" == rc/* ]]; then
|
|
||||||
STABILITY="rc"
|
|
||||||
elif [[ "$BRANCH" == beta/* ]]; then
|
|
||||||
STABILITY="beta"
|
|
||||||
elif [[ "$BRANCH" == alpha/* ]]; then
|
|
||||||
STABILITY="alpha"
|
|
||||||
else
|
|
||||||
STABILITY="development"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Version suffix per stability stream
|
|
||||||
case "$STABILITY" in
|
|
||||||
development) SUFFIX="-dev"; TAG="development" ;;
|
|
||||||
alpha) SUFFIX="-alpha"; TAG="alpha" ;;
|
|
||||||
beta) SUFFIX="-beta"; TAG="beta" ;;
|
|
||||||
rc) SUFFIX="-rc"; TAG="release-candidate" ;;
|
|
||||||
*) SUFFIX=""; TAG="stable" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Propagate version with stability suffix to all manifest files
|
|
||||||
php ${MOKO_CLI}/version_set_platform.php \
|
|
||||||
--path . --version "$VERSION" --branch "$BRANCH" --stability "$STABILITY" 2>/dev/null || true
|
|
||||||
php ${MOKO_CLI}/version_check.php --path . --fix 2>/dev/null || true
|
|
||||||
|
|
||||||
# Re-read version (now includes suffix from version_set_platform)
|
|
||||||
if [ -n "$SUFFIX" ]; then
|
|
||||||
VERSION="${VERSION}${SUFFIX}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "stability=${STABILITY}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "suffix=${SUFFIX}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "display_version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
# Commit version bump if changed
|
|
||||||
git add -A
|
|
||||||
git diff --cached --quiet || {
|
|
||||||
git commit -m "chore(version): auto-bump ${VERSION} [skip ci]" \
|
|
||||||
--author="gitea-actions[bot] <gitea-actions[bot]@mokoconsulting.tech>"
|
|
||||||
git push
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Create release and upload package
|
|
||||||
id: package
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
|
||||||
TAG="${{ steps.meta.outputs.tag }}"
|
|
||||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
|
||||||
|
|
||||||
# Create or update Gitea release
|
|
||||||
php ${MOKO_CLI}/release_create.php \
|
|
||||||
--path . --version "$VERSION" --tag "$TAG" \
|
|
||||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
|
||||||
--repo "${GITEA_REPO}" --branch "${{ github.ref_name }}" --prerelease
|
|
||||||
|
|
||||||
# Build package and upload
|
|
||||||
php ${MOKO_CLI}/release_package.php \
|
|
||||||
--path . --version "$VERSION" --tag "$TAG" \
|
|
||||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
|
||||||
--repo "${GITEA_REPO}" --output /tmp || true
|
|
||||||
|
|
||||||
- name: Update updates.xml
|
|
||||||
if: steps.platform.outputs.platform == 'joomla'
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
|
||||||
STABILITY="${{ steps.meta.outputs.stability }}"
|
|
||||||
SHA256="${{ steps.package.outputs.sha256_zip }}"
|
|
||||||
|
|
||||||
if [ ! -f "updates.xml" ]; then
|
|
||||||
echo "No updates.xml — skipping"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
SHA_FLAG=""
|
|
||||||
[ -n "$SHA256" ] && SHA_FLAG="--sha ${SHA256}"
|
|
||||||
|
|
||||||
php ${MOKO_CLI}/updates_xml_build.php \
|
|
||||||
--path . --version "${VERSION}" --stability "${STABILITY}" \
|
|
||||||
--gitea-url "${GITEA_URL}" --org "${GITEA_ORG}" --repo "${GITEA_REPO}" \
|
|
||||||
${SHA_FLAG}
|
|
||||||
|
|
||||||
# Commit and push updates.xml
|
|
||||||
git add updates.xml
|
|
||||||
git diff --cached --quiet || {
|
|
||||||
git commit -m "chore: update ${STABILITY} channel ${VERSION} [skip ci]"
|
|
||||||
git push
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Sync updates.xml to main
|
|
||||||
if: github.ref_name != 'main' && steps.platform.outputs.platform == 'joomla'
|
|
||||||
run: |
|
|
||||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
|
||||||
GITEA_TOKEN="${{ secrets.MOKOGITEA_TOKEN }}"
|
|
||||||
|
|
||||||
FILE_SHA=$(curl -sf -H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
"${API_BASE}/contents/updates.xml?ref=main" | python3 -c "import sys,json; print(json.load(sys.stdin).get('sha',''))" 2>/dev/null || true)
|
|
||||||
|
|
||||||
if [ -n "$FILE_SHA" ] && [ -f "updates.xml" ]; then
|
|
||||||
python3 -c "
|
|
||||||
import base64, json, urllib.request, sys
|
|
||||||
with open('updates.xml', 'rb') as f:
|
|
||||||
content = base64.b64encode(f.read()).decode()
|
|
||||||
payload = json.dumps({
|
|
||||||
'content': content,
|
|
||||||
'sha': '${FILE_SHA}',
|
|
||||||
'message': 'chore: sync updates.xml from ${{ steps.meta.outputs.stability }} [skip ci]',
|
|
||||||
'branch': 'main'
|
|
||||||
}).encode()
|
|
||||||
req = urllib.request.Request(
|
|
||||||
'${API_BASE}/contents/updates.xml',
|
|
||||||
data=payload, method='PUT',
|
|
||||||
headers={
|
|
||||||
'Authorization': 'token ${GITEA_TOKEN}',
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
})
|
|
||||||
try:
|
|
||||||
urllib.request.urlopen(req)
|
|
||||||
print('updates.xml synced to main')
|
|
||||||
except Exception as e:
|
|
||||||
print(f'WARNING: sync to main failed: {e}', file=sys.stderr)
|
|
||||||
"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: SFTP deploy to dev server
|
|
||||||
if: contains(github.ref, 'dev/') || github.ref == 'refs/heads/dev'
|
|
||||||
env:
|
|
||||||
DEV_HOST: ${{ vars.DEV_FTP_HOST }}
|
|
||||||
DEV_PATH: ${{ vars.DEV_FTP_PATH }}
|
|
||||||
DEV_SUFFIX: ${{ vars.DEV_FTP_SUFFIX }}
|
|
||||||
DEV_USER: ${{ vars.DEV_FTP_USERNAME }}
|
|
||||||
DEV_PORT: ${{ vars.DEV_FTP_PORT }}
|
|
||||||
DEV_KEY: ${{ secrets.DEV_FTP_KEY }}
|
|
||||||
DEV_PASS: ${{ secrets.DEV_FTP_PASSWORD }}
|
|
||||||
run: |
|
|
||||||
# Permission check: admin or maintain role required
|
|
||||||
ACTOR="${{ github.actor }}"
|
|
||||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
|
||||||
|
|
||||||
PERMISSION=$(curl -sf -H "Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}" \
|
|
||||||
"${API_BASE}/collaborators/${ACTOR}/permission" 2>/dev/null | \
|
|
||||||
python3 -c "import sys,json; print(json.load(sys.stdin).get('permission','read'))" 2>/dev/null || echo "read")
|
|
||||||
case "$PERMISSION" in
|
|
||||||
admin|maintain|write) ;;
|
|
||||||
*)
|
|
||||||
echo "Deploy denied: ${ACTOR} has '${PERMISSION}' — requires admin, maintain, or write"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
[ -z "$DEV_HOST" ] || [ -z "$DEV_PATH" ] && { echo "DEV FTP not configured — skipping SFTP"; exit 0; }
|
|
||||||
|
|
||||||
SOURCE_DIR="src"
|
|
||||||
[ ! -d "$SOURCE_DIR" ] && SOURCE_DIR="htdocs"
|
|
||||||
[ ! -d "$SOURCE_DIR" ] && exit 0
|
|
||||||
|
|
||||||
PORT="${DEV_PORT:-22}"
|
|
||||||
REMOTE="${DEV_PATH%/}"
|
|
||||||
[ -n "$DEV_SUFFIX" ] && REMOTE="${REMOTE}/${DEV_SUFFIX#/}"
|
|
||||||
|
|
||||||
printf '{"host":"%s","port":%s,"username":"%s","remotePath":"%s"' \
|
|
||||||
"$DEV_HOST" "$PORT" "$DEV_USER" "$REMOTE" > /tmp/sftp-config.json
|
|
||||||
if [ -n "$DEV_KEY" ]; then
|
|
||||||
echo "$DEV_KEY" > /tmp/deploy_key && chmod 600 /tmp/deploy_key
|
|
||||||
printf ',"privateKeyPath":"/tmp/deploy_key"}' >> /tmp/sftp-config.json
|
|
||||||
else
|
|
||||||
printf ',"password":"%s"}' "$DEV_PASS" >> /tmp/sftp-config.json
|
|
||||||
fi
|
|
||||||
|
|
||||||
PLATFORM=$(php ${MOKO_CLI}/platform_detect.php --path . 2>/dev/null || true)
|
|
||||||
if [ "$PLATFORM" = "waas-component" ] && [ -f "${MOKO_CLI}/../deploy/deploy-joomla.php" ]; then
|
|
||||||
php ${MOKO_CLI}/../deploy/deploy-joomla.php --path . --src-dir "$SOURCE_DIR" --config /tmp/sftp-config.json
|
|
||||||
elif [ -f "${MOKO_CLI}/../deploy/deploy-sftp.php" ]; then
|
|
||||||
php ${MOKO_CLI}/../deploy/deploy-sftp.php --path . --src-dir "$SOURCE_DIR" --config /tmp/sftp-config.json
|
|
||||||
fi
|
|
||||||
rm -f /tmp/deploy_key /tmp/sftp-config.json
|
|
||||||
echo "SFTP deploy to dev complete" >> $GITHUB_STEP_SUMMARY
|
|
||||||
|
|
||||||
- name: Summary
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
|
||||||
STABILITY="${{ steps.meta.outputs.stability }}"
|
|
||||||
DISPLAY="${{ steps.meta.outputs.display_version }}"
|
|
||||||
echo "## Update Server" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Stability | \`${STABILITY}\` |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Version | \`${DISPLAY}\` |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
#
|
||||||
|
# FILE INFORMATION
|
||||||
|
# DEFGROUP: Gitea.Workflow.Template
|
||||||
|
# INGROUP: MokoStandards.CI
|
||||||
|
# REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Joomla
|
||||||
|
# PATH: /.mokogitea/workflows/version-set.yml
|
||||||
|
# VERSION: 01.00.00
|
||||||
|
# BRIEF: Set or reset the extension version across all version-bearing files
|
||||||
|
|
||||||
|
name: "Joomla: Set Version"
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: "Version number (e.g. 01.00.00)"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
branch:
|
||||||
|
description: "Branch to update (default: current)"
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
set-version:
|
||||||
|
name: Set Version to ${{ inputs.version }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Validate version format
|
||||||
|
run: |
|
||||||
|
VERSION="${{ inputs.version }}"
|
||||||
|
if ! echo "$VERSION" | grep -qP '^\d{2}\.\d{2}\.\d{2}$'; then
|
||||||
|
echo "::error::Invalid version format '${VERSION}' — expected XX.YY.ZZ (e.g. 01.00.00)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.MOKOGITEA_TOKEN || secrets.GA_TOKEN || github.token }}
|
||||||
|
ref: ${{ inputs.branch || github.ref }}
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Update manifest version
|
||||||
|
run: |
|
||||||
|
MANIFEST=""
|
||||||
|
for XML_FILE in $(find . -maxdepth 3 -name "*.xml" -not -path "./.git/*" -not -path "./vendor/*"); do
|
||||||
|
if grep -q "<extension" "$XML_FILE" 2>/dev/null; then
|
||||||
|
MANIFEST="$XML_FILE"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$MANIFEST" ]; then
|
||||||
|
echo "::warning::No Joomla extension manifest found — skipping manifest update"
|
||||||
|
else
|
||||||
|
OLD_VER=$(grep -oP '<version>\K[^<]+' "$MANIFEST" | head -1)
|
||||||
|
sed -i "s|<version>${OLD_VER}</version>|<version>${VERSION}</version>|" "$MANIFEST"
|
||||||
|
echo "Manifest: ${OLD_VER} → ${VERSION} (${MANIFEST})"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Update README.md version
|
||||||
|
run: |
|
||||||
|
if [ -f "README.md" ]; then
|
||||||
|
if grep -qP '^\s*VERSION:\s*\d' README.md; then
|
||||||
|
sed -i -E "s/(VERSION:\s*)[0-9]{2}\.[0-9]{2}\.[0-9]{2}/\1${VERSION}/" README.md
|
||||||
|
echo "README.md version updated to ${VERSION}"
|
||||||
|
else
|
||||||
|
echo "::warning::No VERSION line found in README.md — skipping"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Update CHANGELOG.md
|
||||||
|
run: |
|
||||||
|
if [ -f "CHANGELOG.md" ]; then
|
||||||
|
DATE=$(date +%Y-%m-%d)
|
||||||
|
# Check if this version already has an entry
|
||||||
|
if grep -q "^\#\# \[${VERSION}\]" CHANGELOG.md; then
|
||||||
|
echo "CHANGELOG.md already has entry for ${VERSION} — skipping"
|
||||||
|
else
|
||||||
|
# Insert new version entry after [Unreleased] or at the top after header
|
||||||
|
if grep -q '^\#\# \[Unreleased\]' CHANGELOG.md; then
|
||||||
|
sed -i "/^\#\# \[Unreleased\]/a\\\\n## [${VERSION}] --- ${DATE}" CHANGELOG.md
|
||||||
|
else
|
||||||
|
sed -i "/^\# Changelog/a\\\\n## [Unreleased]\n\n## [${VERSION}] --- ${DATE}" CHANGELOG.md
|
||||||
|
fi
|
||||||
|
echo "CHANGELOG.md: added entry for ${VERSION}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "::warning::No CHANGELOG.md found — skipping"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Update FILE INFORMATION blocks
|
||||||
|
run: |
|
||||||
|
# Update VERSION in file header blocks (# VERSION: XX.YY.ZZ)
|
||||||
|
find . -maxdepth 1 -type f \( -name "*.yml" -o -name "*.yaml" -o -name "*.php" -o -name "*.md" \) \
|
||||||
|
-not -path "./.git/*" -not -path "./vendor/*" -print0 2>/dev/null | \
|
||||||
|
while IFS= read -r -d '' FILE; do
|
||||||
|
if head -20 "$FILE" | grep -qP '^\s*#?\s*VERSION:\s*\d{2}\.\d{2}\.\d{2}'; then
|
||||||
|
sed -i -E "s/(#?\s*VERSION:\s*)[0-9]{2}\.[0-9]{2}\.[0-9]{2}/\1${VERSION}/" "$FILE"
|
||||||
|
echo "Updated FILE INFORMATION VERSION in ${FILE}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Commit and push
|
||||||
|
run: |
|
||||||
|
git config user.name "Moko Consulting [bot]"
|
||||||
|
git config user.email "hello@mokoconsulting.tech"
|
||||||
|
git add -A
|
||||||
|
if git diff --cached --quiet; then
|
||||||
|
echo "No version changes detected — nothing to commit"
|
||||||
|
else
|
||||||
|
git commit -m "chore: set version to ${VERSION} [skip bump]
|
||||||
|
|
||||||
|
Authored-by: Moko Consulting"
|
||||||
|
git push
|
||||||
|
echo "### Version Set" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "Version updated to \`${VERSION}\` on branch \`${GITHUB_REF_NAME}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
+32
-1
@@ -1,6 +1,36 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- **Instagram carousel**: Multi-image/video posts via Meta carousel container flow (up to 10 items)
|
||||||
|
- **Instagram Reels**: Short-form video publishing via REELS media type
|
||||||
|
- **Instagram Stories**: Image and video story publishing via STORIES media type
|
||||||
|
- **Instagram alt text**: Alt text support for image containers
|
||||||
|
- **Nostr plugin**: Full NIP-01 WebSocket relay publishing with BIP-340 Schnorr signatures (pure PHP, requires ext-gmp)
|
||||||
|
- **Nostr**: Publishes kind-1 text note events to multiple relays with automatic failover
|
||||||
|
- **Nostr**: Raw WebSocket client using stream_socket_client (no external dependencies)
|
||||||
|
- **Nostr**: Public key derivation and event signing via secp256k1 elliptic curve math
|
||||||
|
- **Threads carousel**: Support up to 20-item carousel posts via Threads API multi-container flow
|
||||||
|
- **Threads polls**: Poll creation support via poll_options parameter (2-4 options)
|
||||||
|
- **Threads spoiler tags**: Content warning / spoiler flag support for Threads posts
|
||||||
|
- **Threads text-only optimization**: Simplified single-step flow for text-only posts without media
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Webservices plugin Joomla 6 compatibility — `onBeforeApiRoute` receives `BeforeApiRouteEvent` object, extract router via `$event->getRouter()`
|
||||||
|
|
||||||
|
## [01.07.00] --- 2026-06-23
|
||||||
|
|
||||||
|
## [01.07.00] --- 2026-06-23
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- **Full ACL system**: 12 granular permissions in access.xml with permissions fieldset in config.xml
|
||||||
|
- **ACL enforcement**: All controllers and views check permissions before allowing actions
|
||||||
|
- **MokoSuiteCrossHelper::getActions()**: Centralized ACL helper for toolbar and view logic
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- **License warning**: Removed duplicate from system plugin (install script already shows it)
|
||||||
|
- **Content plugin**: Fixed func_get_arg crash when non-article content is saved (e.g. update sites, installer)
|
||||||
|
|
||||||
## [01.05.00] --- 2026-06-23
|
## [01.05.00] --- 2026-06-23
|
||||||
|
|
||||||
## [01.05.00] --- 2026-06-23
|
## [01.05.00] --- 2026-06-23
|
||||||
@@ -35,6 +65,7 @@
|
|||||||
- **Medium**: Fixed getUserId() returning array instead of string on error
|
- **Medium**: Fixed getUserId() returning array instead of string on error
|
||||||
- **Bluesky**: Replaced md5() with hash('sha256', ...) for cache key
|
- **Bluesky**: Replaced md5() with hash('sha256', ...) for cache key
|
||||||
- **ServiceController**: Exception details no longer exposed to client
|
- **ServiceController**: Exception details no longer exposed to client
|
||||||
|
- **License warning**: Removed duplicate from system plugin -- install script already shows it with direct edit link
|
||||||
|
|
||||||
## [01.04.01] --- 2026-06-21
|
## [01.04.01] --- 2026-06-21
|
||||||
|
|
||||||
@@ -51,7 +82,7 @@
|
|||||||
## [01.03.00] --- 2026-06-21
|
## [01.03.00] --- 2026-06-21
|
||||||
|
|
||||||
|
|
||||||
<!-- VERSION: 01.05.00 -->
|
<!-- VERSION: 01.08.17 -->
|
||||||
|
|
||||||
All notable changes to MokoSuiteCross will be documented in this file.
|
All notable changes to MokoSuiteCross will be documented in this file.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# MokoSuiteCross
|
# MokoSuiteCross
|
||||||
|
|
||||||
<!-- VERSION: 01.05.00 -->
|
<!-- VERSION: 01.08.17 -->
|
||||||
|
|
||||||
Cross-posting Joomla content to social media, email marketing, and chat platforms for Joomla 5/6.
|
Cross-posting Joomla content to social media, email marketing, and chat platforms for Joomla 5/6.
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
; License: GPL-3.0-or-later
|
; License: GPL-3.0-or-later
|
||||||
|
|
||||||
PKG_MOKOSUITECROSS="MokoSuiteCross"
|
PKG_MOKOSUITECROSS="MokoSuiteCross"
|
||||||
PKG_MOKOSUITECROSS_DESCRIPTION="Cross-posting Joomla content to social media, email marketing, and chat platforms. Automatically publish articles to Facebook, X/Twitter, LinkedIn, Mastodon, Bluesky, Mailchimp, Telegram, Discord, and Slack."
|
PKG_MOKOSUITECROSS_DESCRIPTION="Cross-post Joomla articles to 38 platforms including Facebook, Instagram, X/Twitter, LinkedIn, Threads, Mastodon, Bluesky, Nostr, TikTok, YouTube, Pinterest, Reddit, Medium, Telegram, Discord, Slack, Teams, Mailchimp, SendGrid, Brevo, and more. Features scheduled posting, template placeholders, UTM tagging, link shortening, caption rotation, and per-article service selection."
|
||||||
PKG_MOKOSUITECROSS_PHP_VERSION_ERROR="MokoSuiteCross requires PHP %s or later."
|
PKG_MOKOSUITECROSS_PHP_VERSION_ERROR="MokoSuiteCross requires PHP %s or later."
|
||||||
PKG_MOKOSUITECROSS_MIGRATION_DETECTED="Perfect Publisher Pro detected! Navigate to Components → MokoSuiteCross → Dashboard to migrate your settings."
|
PKG_MOKOSUITECROSS_MIGRATION_DETECTED="Perfect Publisher Pro detected! Navigate to Components → MokoSuiteCross → Dashboard to migrate your settings."
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<access component="com_mokosuitecross">
|
<access component="com_mokosuitecross">
|
||||||
<section name="component">
|
<section name="component">
|
||||||
|
<!-- Joomla core actions -->
|
||||||
<action name="core.admin" title="JACTION_ADMIN" />
|
<action name="core.admin" title="JACTION_ADMIN" />
|
||||||
<action name="core.options" title="JACTION_OPTIONS" />
|
<action name="core.options" title="JACTION_OPTIONS" />
|
||||||
<action name="core.manage" title="JACTION_MANAGE" />
|
<action name="core.manage" title="JACTION_MANAGE" />
|
||||||
@@ -8,7 +9,18 @@
|
|||||||
<action name="core.delete" title="JACTION_DELETE" />
|
<action name="core.delete" title="JACTION_DELETE" />
|
||||||
<action name="core.edit" title="JACTION_EDIT" />
|
<action name="core.edit" title="JACTION_EDIT" />
|
||||||
<action name="core.edit.state" title="JACTION_EDITSTATE" />
|
<action name="core.edit.state" title="JACTION_EDITSTATE" />
|
||||||
|
<!-- Component-specific actions -->
|
||||||
<action name="mokosuitecross.crosspost" title="COM_MOKOSUITECROSS_ACTION_CROSSPOST" />
|
<action name="mokosuitecross.crosspost" title="COM_MOKOSUITECROSS_ACTION_CROSSPOST" />
|
||||||
|
<action name="mokosuitecross.crosspost.manual" title="COM_MOKOSUITECROSS_ACTION_CROSSPOST_MANUAL" />
|
||||||
|
<action name="mokosuitecross.delete.remote" title="COM_MOKOSUITECROSS_ACTION_DELETE_REMOTE" />
|
||||||
|
<action name="mokosuitecross.services.manage" title="COM_MOKOSUITECROSS_ACTION_SERVICES_MANAGE" />
|
||||||
|
<action name="mokosuitecross.services.credentials" title="COM_MOKOSUITECROSS_ACTION_SERVICES_CREDENTIALS" />
|
||||||
|
<action name="mokosuitecross.templates.manage" title="COM_MOKOSUITECROSS_ACTION_TEMPLATES_MANAGE" />
|
||||||
|
<action name="mokosuitecross.logs.view" title="COM_MOKOSUITECROSS_ACTION_LOGS_VIEW" />
|
||||||
|
<action name="mokosuitecross.logs.purge" title="COM_MOKOSUITECROSS_ACTION_LOGS_PURGE" />
|
||||||
|
<action name="mokosuitecross.queue.manage" title="COM_MOKOSUITECROSS_ACTION_QUEUE_MANAGE" />
|
||||||
|
<action name="mokosuitecross.queue.export" title="COM_MOKOSUITECROSS_ACTION_QUEUE_EXPORT" />
|
||||||
|
<action name="mokosuitecross.dispatch" title="COM_MOKOSUITECROSS_ACTION_DISPATCH" />
|
||||||
<action name="mokosuitecross.migrate" title="COM_MOKOSUITECROSS_ACTION_MIGRATE" />
|
<action name="mokosuitecross.migrate" title="COM_MOKOSUITECROSS_ACTION_MIGRATE" />
|
||||||
</section>
|
</section>
|
||||||
</access>
|
</access>
|
||||||
|
|||||||
@@ -199,4 +199,19 @@
|
|||||||
description="COM_MOKOSUITECROSS_CONFIG_CATEGORY_RULES_NOTE_DESC"
|
description="COM_MOKOSUITECROSS_CONFIG_CATEGORY_RULES_NOTE_DESC"
|
||||||
/>
|
/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset
|
||||||
|
name="permissions"
|
||||||
|
label="JCONFIG_PERMISSIONS_LABEL"
|
||||||
|
description="JCONFIG_PERMISSIONS_DESC">
|
||||||
|
<field
|
||||||
|
name="rules"
|
||||||
|
type="rules"
|
||||||
|
label="JCONFIG_PERMISSIONS_LABEL"
|
||||||
|
component="com_mokosuitecross"
|
||||||
|
filter="rules"
|
||||||
|
validate="rules"
|
||||||
|
section="component"
|
||||||
|
/>
|
||||||
|
</fieldset>
|
||||||
</config>
|
</config>
|
||||||
|
|||||||
@@ -5,6 +5,20 @@
|
|||||||
COM_MOKOSUITECROSS="MokoSuiteCross"
|
COM_MOKOSUITECROSS="MokoSuiteCross"
|
||||||
COM_MOKOSUITECROSS_DESCRIPTION="Cross-posting Joomla content to social media, email marketing, and chat platforms"
|
COM_MOKOSUITECROSS_DESCRIPTION="Cross-posting Joomla content to social media, email marketing, and chat platforms"
|
||||||
|
|
||||||
|
; ACL Actions
|
||||||
|
COM_MOKOSUITECROSS_ACTION_CROSSPOST="Cross-Post Articles"
|
||||||
|
COM_MOKOSUITECROSS_ACTION_CROSSPOST_MANUAL="Manually Create Posts"
|
||||||
|
COM_MOKOSUITECROSS_ACTION_DELETE_REMOTE="Delete from Remote Platforms"
|
||||||
|
COM_MOKOSUITECROSS_ACTION_SERVICES_MANAGE="Manage Services"
|
||||||
|
COM_MOKOSUITECROSS_ACTION_SERVICES_CREDENTIALS="View Service Credentials"
|
||||||
|
COM_MOKOSUITECROSS_ACTION_TEMPLATES_MANAGE="Manage Templates"
|
||||||
|
COM_MOKOSUITECROSS_ACTION_LOGS_VIEW="View Activity Logs"
|
||||||
|
COM_MOKOSUITECROSS_ACTION_LOGS_PURGE="Purge Activity Logs"
|
||||||
|
COM_MOKOSUITECROSS_ACTION_QUEUE_MANAGE="Manage Post Queue"
|
||||||
|
COM_MOKOSUITECROSS_ACTION_QUEUE_EXPORT="Export Post Queue"
|
||||||
|
COM_MOKOSUITECROSS_ACTION_DISPATCH="Trigger API Dispatch"
|
||||||
|
COM_MOKOSUITECROSS_ACTION_MIGRATE="Run Migration"
|
||||||
|
|
||||||
; Submenu
|
; Submenu
|
||||||
COM_MOKOSUITECROSS_SUBMENU_DASHBOARD="Dashboard"
|
COM_MOKOSUITECROSS_SUBMENU_DASHBOARD="Dashboard"
|
||||||
COM_MOKOSUITECROSS_SUBMENU_POSTS="Post Queue"
|
COM_MOKOSUITECROSS_SUBMENU_POSTS="Post Queue"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="component" method="upgrade">
|
<extension type="component" method="upgrade">
|
||||||
<name>com_mokosuitecross</name>
|
<name>com_mokosuitecross</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
/* 01.08.05 — no schema changes */
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/* 01.08.07 — no schema changes */
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/* 01.08.08 — no schema changes */
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/* 01.08.09 — no schema changes */
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/* 01.08.10 — no schema changes */
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/* 01.08.11 — no schema changes */
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/* 01.08.12 — no schema changes */
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/* 01.08.13 — no schema changes */
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/* 01.08.14 — no schema changes */
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/* 01.08.15 — no schema changes */
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/* 01.08.16 — no schema changes */
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/* 01.08.17 — no schema changes */
|
||||||
@@ -56,7 +56,7 @@ class DispatchController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ACL check — require core.manage on the component
|
// ACL check — require core.manage on the component
|
||||||
if (!Factory::getApplication()->getIdentity()->authorise('core.manage', 'com_mokosuitecross')) {
|
if (!Factory::getApplication()->getIdentity()->authorise('mokosuitecross.dispatch', 'com_mokosuitecross')) {
|
||||||
$this->sendJsonResponse(['error' => 'Forbidden'], 403);
|
$this->sendJsonResponse(['error' => 'Forbidden'], 403);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace Joomla\Component\MokoSuiteCross\Administrator\Controller;
|
|||||||
|
|
||||||
defined('_JEXEC') or die;
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
use Joomla\CMS\MVC\Controller\BaseController;
|
use Joomla\CMS\MVC\Controller\BaseController;
|
||||||
|
|
||||||
class DisplayController extends BaseController
|
class DisplayController extends BaseController
|
||||||
@@ -23,4 +24,13 @@ class DisplayController extends BaseController
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $default_view = 'dashboard';
|
protected $default_view = 'dashboard';
|
||||||
|
|
||||||
|
public function display($cachable = false, $urlparams = [])
|
||||||
|
{
|
||||||
|
if (!$this->app->getIdentity()->authorise('core.manage', 'com_mokosuitecross')) {
|
||||||
|
throw new \Joomla\CMS\Access\Exception\NotAllowed(Text::_('JERROR_ALERTNOAUTHOR'), 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::display($cachable, $urlparams);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ class PostsController extends AdminController
|
|||||||
{
|
{
|
||||||
$this->checkToken('get');
|
$this->checkToken('get');
|
||||||
|
|
||||||
if (!$this->app->getIdentity()->authorise('core.manage', 'com_mokosuitecross')) {
|
if (!$this->app->getIdentity()->authorise('mokosuitecross.queue.export', 'com_mokosuitecross')) {
|
||||||
throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
|
throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class ServiceController extends FormController
|
|||||||
{
|
{
|
||||||
$this->checkToken();
|
$this->checkToken();
|
||||||
|
|
||||||
if (!$this->app->getIdentity()->authorise('core.manage', 'com_mokosuitecross')) {
|
if (!$this->app->getIdentity()->authorise('mokosuitecross.services.manage', 'com_mokosuitecross')) {
|
||||||
throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
|
throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,4 +21,22 @@ class ServicesController extends AdminController
|
|||||||
{
|
{
|
||||||
return parent::getModel($name, $prefix, $config);
|
return parent::getModel($name, $prefix, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function publish(): void
|
||||||
|
{
|
||||||
|
if (!$this->app->getIdentity()->authorise('core.edit.state', 'com_mokosuitecross')) {
|
||||||
|
throw new \Joomla\CMS\Access\Exception\NotAllowed(\Joomla\CMS\Language\Text::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::publish();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(): void
|
||||||
|
{
|
||||||
|
if (!$this->app->getIdentity()->authorise('core.delete', 'com_mokosuitecross')) {
|
||||||
|
throw new \Joomla\CMS\Access\Exception\NotAllowed(\Joomla\CMS\Language\Text::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,4 +21,22 @@ class TemplatesController extends AdminController
|
|||||||
{
|
{
|
||||||
return parent::getModel($name, $prefix, $config);
|
return parent::getModel($name, $prefix, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function publish(): void
|
||||||
|
{
|
||||||
|
if (!$this->app->getIdentity()->authorise('mokosuitecross.templates.manage', 'com_mokosuitecross')) {
|
||||||
|
throw new \Joomla\CMS\Access\Exception\NotAllowed(\Joomla\CMS\Language\Text::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::publish();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(): void
|
||||||
|
{
|
||||||
|
if (!$this->app->getIdentity()->authorise('mokosuitecross.templates.manage', 'com_mokosuitecross')) {
|
||||||
|
throw new \Joomla\CMS\Access\Exception\NotAllowed(\Joomla\CMS\Language\Text::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,4 +71,26 @@ class MokoSuiteCrossHelper
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of ACL actions for the component.
|
||||||
|
*
|
||||||
|
* @return \Joomla\CMS\Object\CMSObject
|
||||||
|
*/
|
||||||
|
public static function getActions(): \Joomla\CMS\Object\CMSObject
|
||||||
|
{
|
||||||
|
$user = \Joomla\CMS\Factory::getApplication()->getIdentity();
|
||||||
|
$result = new \Joomla\CMS\Object\CMSObject();
|
||||||
|
|
||||||
|
$actions = \Joomla\CMS\Access\Access::getActionsFromFile(
|
||||||
|
JPATH_ADMINISTRATOR . '/components/com_mokosuitecross/access.xml',
|
||||||
|
'/access/section[@name="component"]/'
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($actions as $action) {
|
||||||
|
$result->set($action->name, $user->authorise($action->name, 'com_mokosuitecross'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,11 @@ class HtmlView extends BaseHtmlView
|
|||||||
|
|
||||||
protected function addToolbar(): void
|
protected function addToolbar(): void
|
||||||
{
|
{
|
||||||
|
$canDo = MokoSuiteCrossHelper::getActions();
|
||||||
|
|
||||||
ToolbarHelper::title('MokoSuiteCross — Dashboard', 'share-alt');
|
ToolbarHelper::title('MokoSuiteCross — Dashboard', 'share-alt');
|
||||||
ToolbarHelper::preferences('com_mokosuitecross');
|
if ($canDo->get('core.admin')) {
|
||||||
|
ToolbarHelper::preferences('com_mokosuitecross');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ class HtmlView extends BaseHtmlView
|
|||||||
|
|
||||||
protected function addToolbar(): void
|
protected function addToolbar(): void
|
||||||
{
|
{
|
||||||
|
$canDo = MokoSuiteCrossHelper::getActions();
|
||||||
|
|
||||||
ToolbarHelper::title('MokoSuiteCross — Activity Logs', 'share-alt');
|
ToolbarHelper::title('MokoSuiteCross — Activity Logs', 'share-alt');
|
||||||
ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'logs.delete', 'JTOOLBAR_DELETE');
|
ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'logs.delete', 'JTOOLBAR_DELETE');
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
|||||||
use Joomla\CMS\Router\Route;
|
use Joomla\CMS\Router\Route;
|
||||||
use Joomla\CMS\Toolbar\Toolbar;
|
use Joomla\CMS\Toolbar\Toolbar;
|
||||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||||
|
use Joomla\Component\MokoSuiteCross\Administrator\Helper\MokoSuiteCrossHelper;
|
||||||
|
|
||||||
class HtmlView extends BaseHtmlView
|
class HtmlView extends BaseHtmlView
|
||||||
{
|
{
|
||||||
@@ -37,14 +38,17 @@ class HtmlView extends BaseHtmlView
|
|||||||
protected function addToolbar(): void
|
protected function addToolbar(): void
|
||||||
{
|
{
|
||||||
$isNew = empty($this->item->id);
|
$isNew = empty($this->item->id);
|
||||||
|
$canDo = MokoSuiteCrossHelper::getActions();
|
||||||
|
|
||||||
ToolbarHelper::title(
|
ToolbarHelper::title(
|
||||||
'MokoSuiteCross — ' . ($isNew ? Text::_('COM_MOKOSUITECROSS_NEW_POST') : Text::_('COM_MOKOSUITECROSS_EDIT_POST')),
|
'MokoSuiteCross — ' . ($isNew ? Text::_('COM_MOKOSUITECROSS_NEW_POST') : Text::_('COM_MOKOSUITECROSS_EDIT_POST')),
|
||||||
'share-alt'
|
'share-alt'
|
||||||
);
|
);
|
||||||
|
|
||||||
ToolbarHelper::apply('post.apply');
|
if ($canDo->get('mokosuitecross.queue.manage')) {
|
||||||
ToolbarHelper::save('post.save');
|
ToolbarHelper::apply('post.apply');
|
||||||
|
ToolbarHelper::save('post.save');
|
||||||
|
}
|
||||||
|
|
||||||
$toolbar = Toolbar::getInstance('toolbar');
|
$toolbar = Toolbar::getInstance('toolbar');
|
||||||
$toolbar->appendButton(
|
$toolbar->appendButton(
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ class HtmlView extends BaseHtmlView
|
|||||||
|
|
||||||
protected function addToolbar(): void
|
protected function addToolbar(): void
|
||||||
{
|
{
|
||||||
|
$canDo = MokoSuiteCrossHelper::getActions();
|
||||||
|
|
||||||
ToolbarHelper::title('MokoSuiteCross — Post Queue', 'share-alt');
|
ToolbarHelper::title('MokoSuiteCross — Post Queue', 'share-alt');
|
||||||
ToolbarHelper::addNew('post.add');
|
ToolbarHelper::addNew('post.add');
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
|||||||
use Joomla\CMS\Router\Route;
|
use Joomla\CMS\Router\Route;
|
||||||
use Joomla\CMS\Toolbar\Toolbar;
|
use Joomla\CMS\Toolbar\Toolbar;
|
||||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||||
|
use Joomla\Component\MokoSuiteCross\Administrator\Helper\MokoSuiteCrossHelper;
|
||||||
|
|
||||||
class HtmlView extends BaseHtmlView
|
class HtmlView extends BaseHtmlView
|
||||||
{
|
{
|
||||||
@@ -38,14 +39,17 @@ class HtmlView extends BaseHtmlView
|
|||||||
protected function addToolbar(): void
|
protected function addToolbar(): void
|
||||||
{
|
{
|
||||||
$isNew = empty($this->item->id);
|
$isNew = empty($this->item->id);
|
||||||
|
$canDo = MokoSuiteCrossHelper::getActions();
|
||||||
|
|
||||||
ToolbarHelper::title(
|
ToolbarHelper::title(
|
||||||
'MokoSuiteCross — ' . ($isNew ? Text::_('COM_MOKOSUITECROSS_NEW_SERVICE') : Text::_('COM_MOKOSUITECROSS_EDIT_SERVICE')),
|
'MokoSuiteCross — ' . ($isNew ? Text::_('COM_MOKOSUITECROSS_NEW_SERVICE') : Text::_('COM_MOKOSUITECROSS_EDIT_SERVICE')),
|
||||||
'share-alt'
|
'share-alt'
|
||||||
);
|
);
|
||||||
|
|
||||||
ToolbarHelper::apply('service.apply');
|
if ($canDo->get('mokosuitecross.services.manage')) {
|
||||||
ToolbarHelper::save('service.save');
|
ToolbarHelper::apply('service.apply');
|
||||||
|
ToolbarHelper::save('service.save');
|
||||||
|
}
|
||||||
|
|
||||||
// Dashboard button in toolbar
|
// Dashboard button in toolbar
|
||||||
$toolbar = Toolbar::getInstance('toolbar');
|
$toolbar = Toolbar::getInstance('toolbar');
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ class HtmlView extends BaseHtmlView
|
|||||||
|
|
||||||
protected function addToolbar(): void
|
protected function addToolbar(): void
|
||||||
{
|
{
|
||||||
|
$canDo = MokoSuiteCrossHelper::getActions();
|
||||||
|
|
||||||
ToolbarHelper::title('MokoSuiteCross — Services', 'share-alt');
|
ToolbarHelper::title('MokoSuiteCross — Services', 'share-alt');
|
||||||
ToolbarHelper::addNew('service.add');
|
ToolbarHelper::addNew('service.add');
|
||||||
ToolbarHelper::editList('service.edit');
|
ToolbarHelper::editList('service.edit');
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
|||||||
use Joomla\CMS\Router\Route;
|
use Joomla\CMS\Router\Route;
|
||||||
use Joomla\CMS\Toolbar\Toolbar;
|
use Joomla\CMS\Toolbar\Toolbar;
|
||||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||||
|
use Joomla\Component\MokoSuiteCross\Administrator\Helper\MokoSuiteCrossHelper;
|
||||||
|
|
||||||
class HtmlView extends BaseHtmlView
|
class HtmlView extends BaseHtmlView
|
||||||
{
|
{
|
||||||
@@ -36,13 +37,17 @@ class HtmlView extends BaseHtmlView
|
|||||||
protected function addToolbar(): void
|
protected function addToolbar(): void
|
||||||
{
|
{
|
||||||
$isNew = empty($this->item->id);
|
$isNew = empty($this->item->id);
|
||||||
|
$canDo = MokoSuiteCrossHelper::getActions();
|
||||||
|
|
||||||
ToolbarHelper::title(
|
ToolbarHelper::title(
|
||||||
'MokoSuiteCross — ' . ($isNew ? 'New Template' : 'Edit Template'),
|
'MokoSuiteCross — ' . ($isNew ? 'New Template' : 'Edit Template'),
|
||||||
'share-alt'
|
'share-alt'
|
||||||
);
|
);
|
||||||
ToolbarHelper::apply('template.apply');
|
|
||||||
ToolbarHelper::save('template.save');
|
if ($canDo->get('mokosuitecross.templates.manage')) {
|
||||||
|
ToolbarHelper::apply('template.apply');
|
||||||
|
ToolbarHelper::save('template.save');
|
||||||
|
}
|
||||||
ToolbarHelper::cancel('template.cancel');
|
ToolbarHelper::cancel('template.cancel');
|
||||||
|
|
||||||
// Dashboard link in toolbar
|
// Dashboard link in toolbar
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ class HtmlView extends BaseHtmlView
|
|||||||
|
|
||||||
protected function addToolbar(): void
|
protected function addToolbar(): void
|
||||||
{
|
{
|
||||||
|
$canDo = MokoSuiteCrossHelper::getActions();
|
||||||
|
|
||||||
ToolbarHelper::title('MokoSuiteCross — Message Templates', 'share-alt');
|
ToolbarHelper::title('MokoSuiteCross — Message Templates', 'share-alt');
|
||||||
ToolbarHelper::addNew('template.add');
|
ToolbarHelper::addNew('template.add');
|
||||||
ToolbarHelper::editList('template.edit');
|
ToolbarHelper::editList('template.edit');
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="content" method="upgrade">
|
<extension type="plugin" group="content" method="upgrade">
|
||||||
<name>Content - MokoSuiteCross</name>
|
<name>Content - MokoSuiteCross</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
+13
-42
@@ -270,25 +270,11 @@ XML;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add cross-post status badges before article content in admin.
|
* Add cross-post status badges before article content in admin.
|
||||||
*
|
|
||||||
* Joomla 5/6 compatible — accepts both BeforeDisplayEvent and legacy parameters.
|
|
||||||
*/
|
*/
|
||||||
public function onContentBeforeDisplay($event): string
|
public function onContentBeforeDisplay(\Joomla\CMS\Event\Content\BeforeDisplayEvent $event): string
|
||||||
{
|
{
|
||||||
// Joomla 5/6 compatibility
|
$context = $event->getContext();
|
||||||
if ($event instanceof \Joomla\CMS\Event\Content\BeforeDisplayEvent) {
|
$article = $event->getItem();
|
||||||
$context = $event->getContext();
|
|
||||||
$article = $event->getItem();
|
|
||||||
} elseif (is_string($event)) {
|
|
||||||
$context = $event;
|
|
||||||
$article = func_get_arg(1);
|
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($context !== 'com_content.article') {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$app = $this->getApplication();
|
$app = $this->getApplication();
|
||||||
|
|
||||||
@@ -330,26 +316,18 @@ XML;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatch cross-post when an article is saved and published.
|
* Dispatch cross-post when an article is saved and published.
|
||||||
*
|
|
||||||
* Joomla 5/6 compatible — accepts both AfterSaveEvent and legacy parameters.
|
|
||||||
*/
|
*/
|
||||||
public function onContentAfterSave($event): void
|
public function onContentAfterSave(\Joomla\CMS\Event\Content\AfterSaveEvent $event): void
|
||||||
{
|
{
|
||||||
// Joomla 5/6 compatibility
|
$context = $event->getContext();
|
||||||
if ($event instanceof \Joomla\CMS\Event\Content\AfterSaveEvent) {
|
|
||||||
$context = $event->getContext();
|
|
||||||
$article = $event->getItem();
|
|
||||||
$isNew = $event->getIsNew();
|
|
||||||
} else {
|
|
||||||
$context = $event;
|
|
||||||
$article = func_get_arg(1);
|
|
||||||
$isNew = func_get_arg(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($context !== 'com_content.article') {
|
if ($context !== 'com_content.article') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$article = $event->getItem();
|
||||||
|
$isNew = $event->getIsNew();
|
||||||
|
|
||||||
if ((int) ($article->state ?? 0) !== 1) {
|
if ((int) ($article->state ?? 0) !== 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -375,25 +353,18 @@ XML;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatch cross-post when article state changes to published.
|
* Dispatch cross-post when article state changes to published.
|
||||||
*
|
|
||||||
* Joomla 5/6 compatible — accepts both ContentChangeStateEvent and legacy parameters.
|
|
||||||
*/
|
*/
|
||||||
public function onContentChangeState($event): void
|
public function onContentChangeState(\Joomla\CMS\Event\Content\ContentChangeStateEvent $event): void
|
||||||
{
|
{
|
||||||
if ($event instanceof \Joomla\CMS\Event\Content\ContentChangeStateEvent) {
|
$context = $event->getContext();
|
||||||
$context = $event->getContext();
|
|
||||||
$pks = $event->getPks();
|
|
||||||
$value = $event->getValue();
|
|
||||||
} else {
|
|
||||||
$context = $event;
|
|
||||||
$pks = func_get_arg(1);
|
|
||||||
$value = func_get_arg(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($context !== 'com_content.article') {
|
if ($context !== 'com_content.article') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pks = $event->getPks();
|
||||||
|
$value = $event->getValue();
|
||||||
|
|
||||||
$params = ComponentHelper::getParams('com_mokosuitecross');
|
$params = ComponentHelper::getParams('com_mokosuitecross');
|
||||||
|
|
||||||
// Unpublish/trash: delete from platforms if configured
|
// Unpublish/trash: delete from platforms if configured
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - ActivityPub (Fediverse)</name>
|
<name>MokoSuiteCross - ActivityPub (Fediverse)</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Google Blogger</name>
|
<name>MokoSuiteCross - Google Blogger</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Bluesky</name>
|
<name>MokoSuiteCross - Bluesky</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Brevo (Sendinblue)</name>
|
<name>MokoSuiteCross - Brevo (Sendinblue)</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Constant Contact</name>
|
<name>MokoSuiteCross - Constant Contact</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - ConvertKit</name>
|
<name>MokoSuiteCross - ConvertKit</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Dev.to</name>
|
<name>MokoSuiteCross - Dev.to</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Discord</name>
|
<name>MokoSuiteCross - Discord</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Facebook / Meta</name>
|
<name>MokoSuiteCross - Facebook / Meta</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Ghost</name>
|
<name>MokoSuiteCross - Ghost</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Google Business Profile</name>
|
<name>MokoSuiteCross - Google Business Profile</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Google Chat</name>
|
<name>MokoSuiteCross - Google Chat</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Hashnode</name>
|
<name>MokoSuiteCross - Hashnode</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Instagram</name>
|
<name>MokoSuiteCross - Instagram</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-06-23</creationDate>
|
<creationDate>2026-06-23</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use Joomla\Event\SubscriberInterface;
|
|||||||
/**
|
/**
|
||||||
* Instagram service plugin for MokoSuiteCross.
|
* Instagram service plugin for MokoSuiteCross.
|
||||||
*
|
*
|
||||||
* Uses the Meta Content Publishing API — a 2-step flow:
|
* Uses the Meta Content Publishing API -- a 2-step flow:
|
||||||
* 1. Create a media container via POST /{ig_user_id}/media
|
* 1. Create a media container via POST /{ig_user_id}/media
|
||||||
* 2. Publish the container via POST /{ig_user_id}/media_publish
|
* 2. Publish the container via POST /{ig_user_id}/media_publish
|
||||||
*/
|
*/
|
||||||
@@ -50,24 +50,128 @@ class InstagramService extends CMSPlugin implements SubscriberInterface, MokoSui
|
|||||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Missing access token or Instagram account ID.']];
|
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Missing access token or Instagram account ID.']];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 1: Create media container
|
if (empty($media)) {
|
||||||
$containerUrl = 'https://graph.facebook.com/v19.0/' . urlencode($accountId) . '/media';
|
|
||||||
$containerData = [
|
|
||||||
'caption' => mb_substr($message, 0, 2200),
|
|
||||||
'access_token' => $token,
|
|
||||||
];
|
|
||||||
|
|
||||||
// Attach image if provided
|
|
||||||
if (!empty($media[0])) {
|
|
||||||
$containerData['image_url'] = $media[0];
|
|
||||||
} else {
|
|
||||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Instagram requires at least one image or video.']];
|
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Instagram requires at least one image or video.']];
|
||||||
}
|
}
|
||||||
|
|
||||||
$ch = curl_init($containerUrl);
|
$caption = mb_substr($message, 0, 2200);
|
||||||
|
$mediaType = $params['media_type'] ?? '';
|
||||||
|
$altText = $params['alt_text'] ?? '';
|
||||||
|
|
||||||
|
if ($mediaType === 'reels') {
|
||||||
|
return $this->publishReels($accountId, $token, $caption, $media[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($mediaType === 'stories') {
|
||||||
|
return $this->publishStories($accountId, $token, $media[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (\count($media) > 1) {
|
||||||
|
return $this->publishCarousel($accountId, $token, $caption, $media, $altText);
|
||||||
|
}
|
||||||
|
|
||||||
|
$fields = [
|
||||||
|
'caption' => $caption,
|
||||||
|
'image_url' => $media[0],
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($altText !== '') {
|
||||||
|
$fields['alt_text'] = $altText;
|
||||||
|
}
|
||||||
|
|
||||||
|
$container = $this->createContainer($accountId, $token, $fields);
|
||||||
|
|
||||||
|
if (!$container['success']) {
|
||||||
|
return ['success' => false, 'platform_post_id' => '', 'response' => $container['data'] ?? ['error' => $container['error']]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->publishContainer($accountId, $token, $container['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function publishCarousel(string $accountId, string $token, string $caption, array $media, string $altText): array
|
||||||
|
{
|
||||||
|
$media = \array_slice($media, 0, 10);
|
||||||
|
$childIds = [];
|
||||||
|
|
||||||
|
foreach ($media as $url) {
|
||||||
|
$fields = ['is_carousel_item' => 'true'];
|
||||||
|
|
||||||
|
if ($this->isVideoUrl($url)) {
|
||||||
|
$fields['video_url'] = $url;
|
||||||
|
} else {
|
||||||
|
$fields['image_url'] = $url;
|
||||||
|
|
||||||
|
if ($altText !== '') {
|
||||||
|
$fields['alt_text'] = $altText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$child = $this->createContainer($accountId, $token, $fields);
|
||||||
|
|
||||||
|
if (!$child['success']) {
|
||||||
|
return ['success' => false, 'platform_post_id' => '', 'response' => $child['data'] ?? ['error' => $child['error']]];
|
||||||
|
}
|
||||||
|
|
||||||
|
$childIds[] = $child['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$carousel = $this->createContainer($accountId, $token, [
|
||||||
|
'media_type' => 'CAROUSEL',
|
||||||
|
'caption' => $caption,
|
||||||
|
'children' => implode(',', $childIds),
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!$carousel['success']) {
|
||||||
|
return ['success' => false, 'platform_post_id' => '', 'response' => $carousel['data'] ?? ['error' => $carousel['error']]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->publishContainer($accountId, $token, $carousel['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function publishReels(string $accountId, string $token, string $caption, string $videoUrl): array
|
||||||
|
{
|
||||||
|
$container = $this->createContainer($accountId, $token, [
|
||||||
|
'media_type' => 'REELS',
|
||||||
|
'video_url' => $videoUrl,
|
||||||
|
'caption' => $caption,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!$container['success']) {
|
||||||
|
return ['success' => false, 'platform_post_id' => '', 'response' => $container['data'] ?? ['error' => $container['error']]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->publishContainer($accountId, $token, $container['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function publishStories(string $accountId, string $token, string $mediaUrl): array
|
||||||
|
{
|
||||||
|
$fields = ['media_type' => 'STORIES'];
|
||||||
|
|
||||||
|
if ($this->isVideoUrl($mediaUrl)) {
|
||||||
|
$fields['video_url'] = $mediaUrl;
|
||||||
|
} else {
|
||||||
|
$fields['image_url'] = $mediaUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
$container = $this->createContainer($accountId, $token, $fields);
|
||||||
|
|
||||||
|
if (!$container['success']) {
|
||||||
|
return ['success' => false, 'platform_post_id' => '', 'response' => $container['data'] ?? ['error' => $container['error']]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->publishContainer($accountId, $token, $container['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createContainer(string $accountId, string $token, array $fields): array
|
||||||
|
{
|
||||||
|
$url = 'https://graph.facebook.com/v19.0/' . urlencode($accountId) . '/media';
|
||||||
|
|
||||||
|
$fields['access_token'] = $token;
|
||||||
|
|
||||||
|
$ch = curl_init($url);
|
||||||
curl_setopt_array($ch, [
|
curl_setopt_array($ch, [
|
||||||
CURLOPT_POST => true,
|
CURLOPT_POST => true,
|
||||||
CURLOPT_POSTFIELDS => http_build_query($containerData),
|
CURLOPT_POSTFIELDS => http_build_query($fields),
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_TIMEOUT => 30,
|
CURLOPT_TIMEOUT => 30,
|
||||||
]);
|
]);
|
||||||
@@ -75,36 +179,34 @@ class InstagramService extends CMSPlugin implements SubscriberInterface, MokoSui
|
|||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
|
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
|
|
||||||
$curlError = curl_error($ch);
|
$curlError = curl_error($ch);
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
return ['success' => false, 'error' => 'Connection error: ' . $curlError];
|
||||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Connection error: ' . $curlError]];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
$data = json_decode($response, true) ?: [];
|
$data = json_decode($response, true) ?: [];
|
||||||
|
|
||||||
if ($httpCode < 200 || $httpCode >= 300 || empty($data['id'])) {
|
if ($httpCode < 200 || $httpCode >= 300 || empty($data['id'])) {
|
||||||
return ['success' => false, 'platform_post_id' => '', 'response' => $data];
|
return ['success' => false, 'error' => $data['error']['message'] ?? 'Container creation failed', 'data' => $data];
|
||||||
}
|
}
|
||||||
|
|
||||||
$containerId = $data['id'];
|
return ['success' => true, 'id' => $data['id'], 'data' => $data];
|
||||||
|
}
|
||||||
|
|
||||||
// Step 2: Publish the container
|
private function publishContainer(string $accountId, string $token, string $containerId): array
|
||||||
$publishUrl = 'https://graph.facebook.com/v19.0/' . urlencode($accountId) . '/media_publish';
|
{
|
||||||
$publishData = [
|
$url = 'https://graph.facebook.com/v19.0/' . urlencode($accountId) . '/media_publish';
|
||||||
'creation_id' => $containerId,
|
|
||||||
'access_token' => $token,
|
|
||||||
];
|
|
||||||
|
|
||||||
$ch = curl_init($publishUrl);
|
$ch = curl_init($url);
|
||||||
curl_setopt_array($ch, [
|
curl_setopt_array($ch, [
|
||||||
CURLOPT_POST => true,
|
CURLOPT_POST => true,
|
||||||
CURLOPT_POSTFIELDS => http_build_query($publishData),
|
CURLOPT_POSTFIELDS => http_build_query([
|
||||||
|
'creation_id' => $containerId,
|
||||||
|
'access_token' => $token,
|
||||||
|
]),
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_TIMEOUT => 30,
|
CURLOPT_TIMEOUT => 30,
|
||||||
]);
|
]);
|
||||||
@@ -112,14 +214,11 @@ class InstagramService extends CMSPlugin implements SubscriberInterface, MokoSui
|
|||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
|
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
|
|
||||||
$curlError = curl_error($ch);
|
$curlError = curl_error($ch);
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Connection error: ' . $curlError]];
|
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Connection error: ' . $curlError]];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
@@ -132,6 +231,11 @@ class InstagramService extends CMSPlugin implements SubscriberInterface, MokoSui
|
|||||||
return ['success' => false, 'platform_post_id' => '', 'response' => $data];
|
return ['success' => false, 'platform_post_id' => '', 'response' => $data];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function isVideoUrl(string $url): bool
|
||||||
|
{
|
||||||
|
return (bool) preg_match('/\.(mp4|mov|avi|wmv|webm)(\?|$)/i', $url);
|
||||||
|
}
|
||||||
|
|
||||||
public function validateCredentials(array $credentials): array
|
public function validateCredentials(array $credentials): array
|
||||||
{
|
{
|
||||||
$token = $this->resolveCredential($credentials, 'access_token');
|
$token = $this->resolveCredential($credentials, 'access_token');
|
||||||
@@ -150,13 +254,9 @@ class InstagramService extends CMSPlugin implements SubscriberInterface, MokoSui
|
|||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
|
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
|
|
||||||
$curlError = curl_error($ch);
|
$curlError = curl_error($ch);
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
return ['valid' => false, 'message' => 'Connection error: ' . $curlError, 'account_name' => ''];
|
return ['valid' => false, 'message' => 'Connection error: ' . $curlError, 'account_name' => ''];
|
||||||
|
|
||||||
}
|
}
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
@@ -183,6 +283,6 @@ class InstagramService extends CMSPlugin implements SubscriberInterface, MokoSui
|
|||||||
|
|
||||||
public function getSupportedMediaTypes(): array
|
public function getSupportedMediaTypes(): array
|
||||||
{
|
{
|
||||||
return ['image', 'video'];
|
return ['image', 'video', 'carousel', 'reels', 'stories'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - LinkedIn</name>
|
<name>MokoSuiteCross - LinkedIn</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Mailchimp</name>
|
<name>MokoSuiteCross - Mailchimp</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Mastodon</name>
|
<name>MokoSuiteCross - Mastodon</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Matrix / Element</name>
|
<name>MokoSuiteCross - Matrix / Element</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Medium</name>
|
<name>MokoSuiteCross - Medium</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - MokoSuiteCalendar Events</name>
|
<name>MokoSuiteCross - MokoSuiteCalendar Events</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - MokoSuiteGallery</name>
|
<name>MokoSuiteCross - MokoSuiteGallery</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
PLG_MOKOSUITECROSS_NOSTR="MokoSuiteCross - Nostr"
|
PLG_MOKOSUITECROSS_NOSTR="MokoSuiteCross - Nostr"
|
||||||
PLG_MOKOSUITECROSS_NOSTR_DESCRIPTION="Cross-post Joomla articles to Nostr."
|
PLG_MOKOSUITECROSS_NOSTR_DESCRIPTION="Cross-post Joomla articles to Nostr relays via NIP-01 WebSocket protocol. Requires PHP ext-gmp for secp256k1 Schnorr signing."
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Nostr</name>
|
<name>MokoSuiteCross - Nostr</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -20,12 +20,18 @@ use Joomla\Event\SubscriberInterface;
|
|||||||
/**
|
/**
|
||||||
* Nostr service plugin for MokoSuiteCross.
|
* Nostr service plugin for MokoSuiteCross.
|
||||||
*
|
*
|
||||||
* Nostr uses NIP-01 WebSocket relays for event publishing.
|
* Publishes kind-1 text note events to NIP-01 WebSocket relays.
|
||||||
* This is a stub — full WebSocket implementation is deferred.
|
* Uses BIP-340 Schnorr signatures over secp256k1 (requires ext-gmp).
|
||||||
* Events are signed with the private key and sent to configured relays.
|
*
|
||||||
|
* Credentials: private_key (64-char hex nsec), relays (comma-separated wss:// URLs)
|
||||||
*/
|
*/
|
||||||
class NostrService extends CMSPlugin implements SubscriberInterface, MokoSuiteCrossServiceInterface
|
class NostrService extends CMSPlugin implements SubscriberInterface, MokoSuiteCrossServiceInterface
|
||||||
{
|
{
|
||||||
|
private const SECP256K1_P = 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F';
|
||||||
|
private const SECP256K1_N = 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141';
|
||||||
|
private const SECP256K1_GX = '79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798';
|
||||||
|
private const SECP256K1_GY = '483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8';
|
||||||
|
|
||||||
public static function getSubscribedEvents(): array
|
public static function getSubscribedEvents(): array
|
||||||
{
|
{
|
||||||
return ['onMokoSuiteCrossGetServices' => 'onMokoSuiteCrossGetServices'];
|
return ['onMokoSuiteCrossGetServices' => 'onMokoSuiteCrossGetServices'];
|
||||||
@@ -43,6 +49,10 @@ class NostrService extends CMSPlugin implements SubscriberInterface, MokoSuiteCr
|
|||||||
|
|
||||||
public function publish(string $message, array $media, array $credentials, array $params): array
|
public function publish(string $message, array $media, array $credentials, array $params): array
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('gmp')) {
|
||||||
|
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'PHP ext-gmp is required for Nostr signing.']];
|
||||||
|
}
|
||||||
|
|
||||||
$privateKey = $credentials['private_key'] ?? '';
|
$privateKey = $credentials['private_key'] ?? '';
|
||||||
$relays = $credentials['relays'] ?? '';
|
$relays = $credentials['relays'] ?? '';
|
||||||
|
|
||||||
@@ -50,48 +60,393 @@ class NostrService extends CMSPlugin implements SubscriberInterface, MokoSuiteCr
|
|||||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Missing private key or relay URLs.']];
|
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Missing private key or relay URLs.']];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nostr requires WebSocket connections to relays (wss://).
|
$privateKey = strtolower(trim($privateKey));
|
||||||
// Full NIP-01 event signing and relay publishing is not yet implemented.
|
|
||||||
|
if (!preg_match('/^[0-9a-f]{64}$/', $privateKey)) {
|
||||||
|
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Private key must be 64 hex characters.']];
|
||||||
|
}
|
||||||
|
|
||||||
|
$pubkey = $this->getPublicKey($privateKey);
|
||||||
|
|
||||||
|
$event = $this->createEvent($pubkey, $message);
|
||||||
|
$event['sig'] = $this->schnorrSign($event['id'], $privateKey);
|
||||||
|
|
||||||
|
$relayList = array_filter(array_map('trim', explode(',', $relays)));
|
||||||
|
$lastError = '';
|
||||||
|
$published = false;
|
||||||
|
|
||||||
|
foreach ($relayList as $relayUrl) {
|
||||||
|
$result = $this->publishToRelay($relayUrl, $event);
|
||||||
|
|
||||||
|
if ($result['success']) {
|
||||||
|
$published = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$lastError = $result['error'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$published) {
|
||||||
|
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'All relays failed. Last: ' . $lastError]];
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'success' => false,
|
'success' => true,
|
||||||
'platform_post_id' => '',
|
'platform_post_id' => $event['id'],
|
||||||
'response' => ['error' => 'Nostr WebSocket relay publishing is not yet implemented. This service will be available in a future release.'],
|
'response' => ['event_id' => $event['id'], 'relay' => $relayUrl ?? ''],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateCredentials(array $credentials): array
|
public function validateCredentials(array $credentials): array
|
||||||
{
|
{
|
||||||
$privateKey = $credentials['private_key'] ?? '';
|
if (!extension_loaded('gmp')) {
|
||||||
|
return ['valid' => false, 'message' => 'PHP ext-gmp is required for Nostr.', 'account_name' => ''];
|
||||||
|
}
|
||||||
|
|
||||||
|
$privateKey = strtolower(trim($credentials['private_key'] ?? ''));
|
||||||
$relays = $credentials['relays'] ?? '';
|
$relays = $credentials['relays'] ?? '';
|
||||||
|
|
||||||
if (empty($privateKey)) {
|
if (empty($privateKey)) {
|
||||||
return ['valid' => false, 'message' => 'Private key is required.', 'account_name' => ''];
|
return ['valid' => false, 'message' => 'Private key is required.', 'account_name' => ''];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!preg_match('/^[0-9a-f]{64}$/', $privateKey)) {
|
||||||
|
return ['valid' => false, 'message' => 'Private key must be 64 hex characters.', 'account_name' => ''];
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($relays)) {
|
if (empty($relays)) {
|
||||||
return ['valid' => false, 'message' => 'At least one relay URL is required.', 'account_name' => ''];
|
return ['valid' => false, 'message' => 'At least one relay URL is required.', 'account_name' => ''];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate that relay URLs look like WebSocket URLs
|
|
||||||
$relayList = array_filter(array_map('trim', explode(',', $relays)));
|
$relayList = array_filter(array_map('trim', explode(',', $relays)));
|
||||||
$valid = true;
|
|
||||||
|
|
||||||
foreach ($relayList as $relay) {
|
foreach ($relayList as $relay) {
|
||||||
if (!str_starts_with($relay, 'wss://') && !str_starts_with($relay, 'ws://')) {
|
if (!str_starts_with($relay, 'wss://') && !str_starts_with($relay, 'ws://')) {
|
||||||
$valid = false;
|
return ['valid' => false, 'message' => 'Relay URLs must start with wss:// or ws://.', 'account_name' => ''];
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$valid) {
|
$pubkey = $this->getPublicKey($privateKey);
|
||||||
return ['valid' => false, 'message' => 'Relay URLs must start with wss:// or ws://.', 'account_name' => ''];
|
$npub = substr($pubkey, 0, 16) . '...';
|
||||||
}
|
|
||||||
|
|
||||||
return ['valid' => true, 'message' => 'Credentials configured (' . count($relayList) . ' relay(s))', 'account_name' => 'Nostr'];
|
return ['valid' => true, 'message' => count($relayList) . ' relay(s) configured', 'account_name' => 'npub:' . $npub];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportedMediaTypes(): array
|
public function getSupportedMediaTypes(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- NIP-01 event creation --
|
||||||
|
|
||||||
|
private function createEvent(string $pubkey, string $content, int $kind = 1, array $tags = []): array
|
||||||
|
{
|
||||||
|
$createdAt = time();
|
||||||
|
$serialized = json_encode([0, $pubkey, $createdAt, $kind, $tags, $content], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
|
$id = hash('sha256', $serialized);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => $id,
|
||||||
|
'pubkey' => $pubkey,
|
||||||
|
'created_at' => $createdAt,
|
||||||
|
'kind' => $kind,
|
||||||
|
'tags' => $tags,
|
||||||
|
'content' => $content,
|
||||||
|
'sig' => '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- WebSocket relay publishing --
|
||||||
|
|
||||||
|
private function publishToRelay(string $relayUrl, array $event): array
|
||||||
|
{
|
||||||
|
$parsed = parse_url($relayUrl);
|
||||||
|
|
||||||
|
if (!$parsed || !isset($parsed['host'])) {
|
||||||
|
return ['success' => false, 'error' => 'Invalid relay URL'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$scheme = $parsed['scheme'] ?? 'wss';
|
||||||
|
$host = $parsed['host'];
|
||||||
|
$port = $parsed['port'] ?? ($scheme === 'wss' ? 443 : 80);
|
||||||
|
$path = $parsed['path'] ?? '/';
|
||||||
|
$useTls = ($scheme === 'wss');
|
||||||
|
|
||||||
|
$address = ($useTls ? 'tls://' : 'tcp://') . $host . ':' . $port;
|
||||||
|
$context = stream_context_create(['ssl' => ['verify_peer' => true, 'verify_peer_name' => true]]);
|
||||||
|
|
||||||
|
$socket = @stream_socket_client($address, $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $context);
|
||||||
|
|
||||||
|
if (!$socket) {
|
||||||
|
return ['success' => false, 'error' => "Connection failed: {$errstr} ({$errno})"];
|
||||||
|
}
|
||||||
|
|
||||||
|
stream_set_timeout($socket, 10);
|
||||||
|
|
||||||
|
// WebSocket upgrade handshake
|
||||||
|
$wsKey = base64_encode(random_bytes(16));
|
||||||
|
$handshake = "GET {$path} HTTP/1.1\r\n"
|
||||||
|
. "Host: {$host}\r\n"
|
||||||
|
. "Upgrade: websocket\r\n"
|
||||||
|
. "Connection: Upgrade\r\n"
|
||||||
|
. "Sec-WebSocket-Key: {$wsKey}\r\n"
|
||||||
|
. "Sec-WebSocket-Version: 13\r\n"
|
||||||
|
. "\r\n";
|
||||||
|
|
||||||
|
fwrite($socket, $handshake);
|
||||||
|
|
||||||
|
$response = '';
|
||||||
|
|
||||||
|
while (($line = fgets($socket)) !== false) {
|
||||||
|
$response .= $line;
|
||||||
|
|
||||||
|
if (trim($line) === '') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($response, '101') === false) {
|
||||||
|
fclose($socket);
|
||||||
|
|
||||||
|
return ['success' => false, 'error' => 'WebSocket upgrade failed'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send EVENT message
|
||||||
|
$payload = json_encode(['EVENT', $event], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
|
$this->wsWrite($socket, $payload);
|
||||||
|
|
||||||
|
// Read OK response (with timeout)
|
||||||
|
$reply = $this->wsRead($socket);
|
||||||
|
fclose($socket);
|
||||||
|
|
||||||
|
if ($reply === null) {
|
||||||
|
return ['success' => false, 'error' => 'No response from relay'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$decoded = json_decode($reply, true);
|
||||||
|
|
||||||
|
if (!is_array($decoded) || ($decoded[0] ?? '') !== 'OK') {
|
||||||
|
$msg = is_array($decoded) ? ($decoded[3] ?? $decoded[2] ?? 'Unknown error') : 'Invalid response';
|
||||||
|
|
||||||
|
return ['success' => false, 'error' => (string) $msg];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ["OK", event_id, true/false, message]
|
||||||
|
$accepted = $decoded[2] ?? false;
|
||||||
|
|
||||||
|
if (!$accepted) {
|
||||||
|
return ['success' => false, 'error' => $decoded[3] ?? 'Relay rejected event'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['success' => true, 'error' => ''];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function wsWrite($socket, string $data): void
|
||||||
|
{
|
||||||
|
$len = strlen($data);
|
||||||
|
$frame = chr(0x81); // text frame, FIN bit set
|
||||||
|
$mask = random_bytes(4);
|
||||||
|
|
||||||
|
if ($len < 126) {
|
||||||
|
$frame .= chr($len | 0x80); // mask bit set
|
||||||
|
} elseif ($len < 65536) {
|
||||||
|
$frame .= chr(126 | 0x80) . pack('n', $len);
|
||||||
|
} else {
|
||||||
|
$frame .= chr(127 | 0x80) . pack('J', $len);
|
||||||
|
}
|
||||||
|
|
||||||
|
$frame .= $mask;
|
||||||
|
|
||||||
|
for ($i = 0; $i < $len; $i++) {
|
||||||
|
$frame .= $data[$i] ^ $mask[$i % 4];
|
||||||
|
}
|
||||||
|
|
||||||
|
fwrite($socket, $frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function wsRead($socket): ?string
|
||||||
|
{
|
||||||
|
$header = fread($socket, 2);
|
||||||
|
|
||||||
|
if ($header === false || strlen($header) < 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$len = ord($header[1]) & 0x7F;
|
||||||
|
|
||||||
|
if ($len === 126) {
|
||||||
|
$ext = fread($socket, 2);
|
||||||
|
$len = unpack('n', $ext)[1];
|
||||||
|
} elseif ($len === 127) {
|
||||||
|
$ext = fread($socket, 8);
|
||||||
|
$len = unpack('J', $ext)[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$masked = (ord($header[1]) & 0x80) !== 0;
|
||||||
|
$mask = $masked ? fread($socket, 4) : '';
|
||||||
|
$data = '';
|
||||||
|
|
||||||
|
while (strlen($data) < $len) {
|
||||||
|
$chunk = fread($socket, $len - strlen($data));
|
||||||
|
|
||||||
|
if ($chunk === false) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data .= $chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($masked) {
|
||||||
|
for ($i = 0; $i < strlen($data); $i++) {
|
||||||
|
$data[$i] = $data[$i] ^ $mask[$i % 4];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- BIP-340 Schnorr signature over secp256k1 --
|
||||||
|
|
||||||
|
private function getPublicKey(string $privateKeyHex): string
|
||||||
|
{
|
||||||
|
$d = gmp_init($privateKeyHex, 16);
|
||||||
|
$G = [gmp_init(self::SECP256K1_GX, 16), gmp_init(self::SECP256K1_GY, 16)];
|
||||||
|
|
||||||
|
$point = $this->ecMultiply($G, $d);
|
||||||
|
|
||||||
|
return str_pad(gmp_strval($point[0], 16), 64, '0', STR_PAD_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function schnorrSign(string $messageHex, string $privateKeyHex): string
|
||||||
|
{
|
||||||
|
$p = gmp_init(self::SECP256K1_P, 16);
|
||||||
|
$n = gmp_init(self::SECP256K1_N, 16);
|
||||||
|
$G = [gmp_init(self::SECP256K1_GX, 16), gmp_init(self::SECP256K1_GY, 16)];
|
||||||
|
|
||||||
|
$d = gmp_init($privateKeyHex, 16);
|
||||||
|
$P = $this->ecMultiply($G, $d);
|
||||||
|
$px = str_pad(gmp_strval($P[0], 16), 64, '0', STR_PAD_LEFT);
|
||||||
|
|
||||||
|
// BIP-340: if P.y is odd, negate d
|
||||||
|
if (gmp_testbit($P[1], 0)) {
|
||||||
|
$d = gmp_sub($n, $d);
|
||||||
|
}
|
||||||
|
|
||||||
|
$dBytes = hex2bin(str_pad(gmp_strval($d, 16), 64, '0', STR_PAD_LEFT));
|
||||||
|
$auxRand = random_bytes(32);
|
||||||
|
$t = $dBytes ^ $this->taggedHash('BIP0340/aux', $auxRand);
|
||||||
|
$pxBytes = hex2bin($px);
|
||||||
|
$msgBytes = hex2bin($messageHex);
|
||||||
|
|
||||||
|
$rand = $this->taggedHash('BIP0340/nonce', $t . $pxBytes . $msgBytes);
|
||||||
|
$k0 = gmp_mod(gmp_init(bin2hex($rand), 16), $n);
|
||||||
|
|
||||||
|
if (gmp_cmp($k0, 0) === 0) {
|
||||||
|
return str_repeat('00', 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
$R = $this->ecMultiply($G, $k0);
|
||||||
|
$k = gmp_testbit($R[1], 0) ? gmp_sub($n, $k0) : $k0;
|
||||||
|
|
||||||
|
$rx = str_pad(gmp_strval($R[0], 16), 64, '0', STR_PAD_LEFT);
|
||||||
|
$rxBytes = hex2bin($rx);
|
||||||
|
|
||||||
|
$eHash = $this->taggedHash('BIP0340/challenge', $rxBytes . $pxBytes . $msgBytes);
|
||||||
|
$e = gmp_mod(gmp_init(bin2hex($eHash), 16), $n);
|
||||||
|
|
||||||
|
$s = gmp_mod(gmp_add($k, gmp_mul($e, $d)), $n);
|
||||||
|
|
||||||
|
return $rx . str_pad(gmp_strval($s, 16), 64, '0', STR_PAD_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function taggedHash(string $tag, string $data): string
|
||||||
|
{
|
||||||
|
$tagHash = hash('sha256', $tag, true);
|
||||||
|
|
||||||
|
return hash('sha256', $tagHash . $tagHash . $data, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- secp256k1 elliptic curve arithmetic --
|
||||||
|
|
||||||
|
private function ecMultiply(array $point, \GMP $scalar): array
|
||||||
|
{
|
||||||
|
$result = null;
|
||||||
|
$addend = $point;
|
||||||
|
$n = gmp_init(self::SECP256K1_N, 16);
|
||||||
|
|
||||||
|
$scalar = gmp_mod($scalar, $n);
|
||||||
|
|
||||||
|
while (gmp_cmp($scalar, 0) > 0) {
|
||||||
|
if (gmp_testbit($scalar, 0)) {
|
||||||
|
$result = $result === null ? $addend : $this->ecAdd($result, $addend);
|
||||||
|
}
|
||||||
|
|
||||||
|
$addend = $this->ecDouble($addend);
|
||||||
|
$scalar = gmp_div_q($scalar, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function ecAdd(array $p1, array $p2): array
|
||||||
|
{
|
||||||
|
$prime = gmp_init(self::SECP256K1_P, 16);
|
||||||
|
|
||||||
|
if (gmp_cmp($p1[0], $p2[0]) === 0 && gmp_cmp($p1[1], $p2[1]) === 0) {
|
||||||
|
return $this->ecDouble($p1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$dx = gmp_mod(gmp_sub($p2[0], $p1[0]), $prime);
|
||||||
|
|
||||||
|
if (gmp_cmp($dx, 0) < 0) {
|
||||||
|
$dx = gmp_add($dx, $prime);
|
||||||
|
}
|
||||||
|
|
||||||
|
$dy = gmp_mod(gmp_sub($p2[1], $p1[1]), $prime);
|
||||||
|
|
||||||
|
if (gmp_cmp($dy, 0) < 0) {
|
||||||
|
$dy = gmp_add($dy, $prime);
|
||||||
|
}
|
||||||
|
|
||||||
|
$slope = gmp_mod(gmp_mul($dy, gmp_invert($dx, $prime)), $prime);
|
||||||
|
$x3 = gmp_mod(gmp_sub(gmp_sub(gmp_mul($slope, $slope), $p1[0]), $p2[0]), $prime);
|
||||||
|
$y3 = gmp_mod(gmp_sub(gmp_mul($slope, gmp_sub($p1[0], $x3)), $p1[1]), $prime);
|
||||||
|
|
||||||
|
if (gmp_cmp($x3, 0) < 0) {
|
||||||
|
$x3 = gmp_add($x3, $prime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gmp_cmp($y3, 0) < 0) {
|
||||||
|
$y3 = gmp_add($y3, $prime);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$x3, $y3];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function ecDouble(array $point): array
|
||||||
|
{
|
||||||
|
$prime = gmp_init(self::SECP256K1_P, 16);
|
||||||
|
|
||||||
|
// secp256k1 has a=0, so slope = 3*x^2 / (2*y)
|
||||||
|
$num = gmp_mod(gmp_mul(3, gmp_mul($point[0], $point[0])), $prime);
|
||||||
|
$denom = gmp_mod(gmp_mul(2, $point[1]), $prime);
|
||||||
|
|
||||||
|
if (gmp_cmp($denom, 0) < 0) {
|
||||||
|
$denom = gmp_add($denom, $prime);
|
||||||
|
}
|
||||||
|
|
||||||
|
$slope = gmp_mod(gmp_mul($num, gmp_invert($denom, $prime)), $prime);
|
||||||
|
$x3 = gmp_mod(gmp_sub(gmp_mul($slope, $slope), gmp_mul(2, $point[0])), $prime);
|
||||||
|
$y3 = gmp_mod(gmp_sub(gmp_mul($slope, gmp_sub($point[0], $x3)), $point[1]), $prime);
|
||||||
|
|
||||||
|
if (gmp_cmp($x3, 0) < 0) {
|
||||||
|
$x3 = gmp_add($x3, $prime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gmp_cmp($y3, 0) < 0) {
|
||||||
|
$y3 = gmp_add($y3, $prime);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$x3, $y3];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Ntfy Push Notifications</name>
|
<name>MokoSuiteCross - Ntfy Push Notifications</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Pinterest</name>
|
<name>MokoSuiteCross - Pinterest</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Reddit</name>
|
<name>MokoSuiteCross - Reddit</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - RSS Feed</name>
|
<name>MokoSuiteCross - RSS Feed</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - SendGrid</name>
|
<name>MokoSuiteCross - SendGrid</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Slack</name>
|
<name>MokoSuiteCross - Slack</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Microsoft Teams</name>
|
<name>MokoSuiteCross - Microsoft Teams</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Telegram</name>
|
<name>MokoSuiteCross - Telegram</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -17,15 +17,13 @@ use Joomla\CMS\Plugin\CMSPlugin;
|
|||||||
use Joomla\Component\MokoSuiteCross\Administrator\Service\MokoSuiteCrossServiceInterface;
|
use Joomla\Component\MokoSuiteCross\Administrator\Service\MokoSuiteCrossServiceInterface;
|
||||||
use Joomla\Event\SubscriberInterface;
|
use Joomla\Event\SubscriberInterface;
|
||||||
|
|
||||||
/**
|
|
||||||
* Threads (Meta) service plugin for MokoSuiteCross.
|
|
||||||
*
|
|
||||||
* Uses the Threads Publishing API — a 2-step flow:
|
|
||||||
* 1. Create a media container via POST /{user_id}/threads
|
|
||||||
* 2. Publish the container via POST /{user_id}/threads_publish
|
|
||||||
*/
|
|
||||||
class ThreadsService extends CMSPlugin implements SubscriberInterface, MokoSuiteCrossServiceInterface
|
class ThreadsService extends CMSPlugin implements SubscriberInterface, MokoSuiteCrossServiceInterface
|
||||||
{
|
{
|
||||||
|
private const API_BASE = 'https://graph.threads.net/v1.0/';
|
||||||
|
private const MAX_CAROUSEL_ITEMS = 20;
|
||||||
|
private const MAX_POLL_OPTIONS = 4;
|
||||||
|
private const MIN_POLL_OPTIONS = 2;
|
||||||
|
|
||||||
public static function getSubscribedEvents(): array
|
public static function getSubscribedEvents(): array
|
||||||
{
|
{
|
||||||
return ['onMokoSuiteCrossGetServices' => 'onMokoSuiteCrossGetServices'];
|
return ['onMokoSuiteCrossGetServices' => 'onMokoSuiteCrossGetServices'];
|
||||||
@@ -50,62 +48,104 @@ class ThreadsService extends CMSPlugin implements SubscriberInterface, MokoSuite
|
|||||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Missing access token or user ID.']];
|
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Missing access token or user ID.']];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 1: Create media container
|
$text = mb_substr($message, 0, 500);
|
||||||
$containerUrl = 'https://graph.threads.net/v1.0/' . urlencode($userId) . '/threads';
|
$media = array_filter($media);
|
||||||
|
|
||||||
|
if (\count($media) > 1) {
|
||||||
|
return $this->publishCarousel($text, $media, $userId, $token, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->publishSinglePost($text, $media, $userId, $token, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function publishSinglePost(string $text, array $media, string $userId, string $token, array $params): array
|
||||||
|
{
|
||||||
|
$containerUrl = self::API_BASE . urlencode($userId) . '/threads';
|
||||||
$containerData = [
|
$containerData = [
|
||||||
'text' => mb_substr($message, 0, 500),
|
'text' => $text,
|
||||||
'access_token' => $token,
|
'access_token' => $token,
|
||||||
];
|
];
|
||||||
|
|
||||||
// Attach image if provided
|
|
||||||
if (!empty($media[0])) {
|
if (!empty($media[0])) {
|
||||||
$containerData['media_type'] = 'IMAGE';
|
$mediaType = $this->detectMediaType($media[0]);
|
||||||
$containerData['image_url'] = $media[0];
|
$containerData['media_type'] = $mediaType;
|
||||||
|
$containerData[$mediaType === 'VIDEO' ? 'video_url' : 'image_url'] = $media[0];
|
||||||
} else {
|
} else {
|
||||||
$containerData['media_type'] = 'TEXT';
|
$containerData['media_type'] = 'TEXT';
|
||||||
}
|
}
|
||||||
|
|
||||||
$ch = curl_init($containerUrl);
|
$this->applyPollOptions($containerData, $params);
|
||||||
curl_setopt_array($ch, [
|
$this->applySpoilerFlag($containerData, $params);
|
||||||
CURLOPT_POST => true,
|
|
||||||
CURLOPT_POSTFIELDS => http_build_query($containerData),
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_TIMEOUT => 30,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
$result = $this->apiPost($containerUrl, $containerData);
|
||||||
|
|
||||||
if ($response === false) {
|
if (!$result['success']) {
|
||||||
|
return $result;
|
||||||
$curlError = curl_error($ch);
|
|
||||||
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Connection error: ' . $curlError]];
|
|
||||||
|
|
||||||
}
|
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
$data = json_decode($response, true) ?: [];
|
|
||||||
|
|
||||||
if ($httpCode < 200 || $httpCode >= 300 || empty($data['id'])) {
|
|
||||||
return ['success' => false, 'platform_post_id' => '', 'response' => $data];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$containerId = $data['id'];
|
return $this->publishContainer($userId, $token, $result['response']['id']);
|
||||||
|
}
|
||||||
|
|
||||||
// Step 2: Publish the container
|
private function publishCarousel(string $text, array $media, string $userId, string $token, array $params): array
|
||||||
$publishUrl = 'https://graph.threads.net/v1.0/' . urlencode($userId) . '/threads_publish';
|
{
|
||||||
|
$items = \array_slice($media, 0, self::MAX_CAROUSEL_ITEMS);
|
||||||
|
$childIds = [];
|
||||||
|
|
||||||
|
foreach ($items as $url) {
|
||||||
|
$mediaType = $this->detectMediaType($url);
|
||||||
|
$childData = [
|
||||||
|
'is_carousel_item' => 'true',
|
||||||
|
'media_type' => $mediaType,
|
||||||
|
'access_token' => $token,
|
||||||
|
];
|
||||||
|
$childData[$mediaType === 'VIDEO' ? 'video_url' : 'image_url'] = $url;
|
||||||
|
|
||||||
|
$childUrl = self::API_BASE . urlencode($userId) . '/threads';
|
||||||
|
$result = $this->apiPost($childUrl, $childData);
|
||||||
|
|
||||||
|
if (!$result['success']) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
$childIds[] = $result['response']['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$carouselData = [
|
||||||
|
'media_type' => 'CAROUSEL',
|
||||||
|
'children' => implode(',', $childIds),
|
||||||
|
'text' => $text,
|
||||||
|
'access_token' => $token,
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->applySpoilerFlag($carouselData, $params);
|
||||||
|
|
||||||
|
$carouselUrl = self::API_BASE . urlencode($userId) . '/threads';
|
||||||
|
$result = $this->apiPost($carouselUrl, $carouselData);
|
||||||
|
|
||||||
|
if (!$result['success']) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->publishContainer($userId, $token, $result['response']['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function publishContainer(string $userId, string $token, string $containerId): array
|
||||||
|
{
|
||||||
|
$publishUrl = self::API_BASE . urlencode($userId) . '/threads_publish';
|
||||||
$publishData = [
|
$publishData = [
|
||||||
'creation_id' => $containerId,
|
'creation_id' => $containerId,
|
||||||
'access_token' => $token,
|
'access_token' => $token,
|
||||||
];
|
];
|
||||||
|
|
||||||
$ch = curl_init($publishUrl);
|
return $this->apiPost($publishUrl, $publishData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function apiPost(string $url, array $data): array
|
||||||
|
{
|
||||||
|
$ch = curl_init($url);
|
||||||
curl_setopt_array($ch, [
|
curl_setopt_array($ch, [
|
||||||
CURLOPT_POST => true,
|
CURLOPT_POST => true,
|
||||||
CURLOPT_POSTFIELDS => http_build_query($publishData),
|
CURLOPT_POSTFIELDS => http_build_query($data),
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_TIMEOUT => 30,
|
CURLOPT_TIMEOUT => 30,
|
||||||
]);
|
]);
|
||||||
@@ -113,24 +153,60 @@ class ThreadsService extends CMSPlugin implements SubscriberInterface, MokoSuite
|
|||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
|
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
|
|
||||||
$curlError = curl_error($ch);
|
$curlError = curl_error($ch);
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Connection error: ' . $curlError]];
|
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Connection error: ' . $curlError]];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
$data = json_decode($response, true) ?: [];
|
$responseData = json_decode($response, true) ?: [];
|
||||||
|
|
||||||
if ($httpCode >= 200 && $httpCode < 300 && !empty($data['id'])) {
|
if ($httpCode >= 200 && $httpCode < 300 && !empty($responseData['id'])) {
|
||||||
return ['success' => true, 'platform_post_id' => (string) $data['id'], 'response' => $data];
|
return ['success' => true, 'platform_post_id' => (string) $responseData['id'], 'response' => $responseData];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['success' => false, 'platform_post_id' => '', 'response' => $data];
|
return ['success' => false, 'platform_post_id' => '', 'response' => $responseData];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function applyPollOptions(array &$data, array $params): void
|
||||||
|
{
|
||||||
|
$options = $params['poll_options'] ?? [];
|
||||||
|
|
||||||
|
if (empty($options) || !\is_array($options)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = \array_slice($options, 0, self::MAX_POLL_OPTIONS);
|
||||||
|
|
||||||
|
if (\count($options) < self::MIN_POLL_OPTIONS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['poll'] = json_encode(['options' => array_values($options)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function applySpoilerFlag(array &$data, array $params): void
|
||||||
|
{
|
||||||
|
if (!empty($params['spoiler'])) {
|
||||||
|
$data['spoiler'] = 'true';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function detectMediaType(string $url): string
|
||||||
|
{
|
||||||
|
$path = strtolower(parse_url($url, PHP_URL_PATH) ?? '');
|
||||||
|
$videoExtensions = ['.mp4', '.mov', '.avi', '.wmv', '.webm'];
|
||||||
|
|
||||||
|
foreach ($videoExtensions as $ext) {
|
||||||
|
if (str_ends_with($path, $ext)) {
|
||||||
|
return 'VIDEO';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'IMAGE';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateCredentials(array $credentials): array
|
public function validateCredentials(array $credentials): array
|
||||||
@@ -142,7 +218,7 @@ class ThreadsService extends CMSPlugin implements SubscriberInterface, MokoSuite
|
|||||||
return ['valid' => false, 'message' => 'Access token and user ID are required.', 'account_name' => ''];
|
return ['valid' => false, 'message' => 'Access token and user ID are required.', 'account_name' => ''];
|
||||||
}
|
}
|
||||||
|
|
||||||
$ch = curl_init('https://graph.threads.net/v1.0/' . urlencode($userId) . '?fields=username&access_token=' . urlencode($token));
|
$ch = curl_init(self::API_BASE . urlencode($userId) . '?fields=username&access_token=' . urlencode($token));
|
||||||
curl_setopt_array($ch, [
|
curl_setopt_array($ch, [
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_TIMEOUT => 10,
|
CURLOPT_TIMEOUT => 10,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Threads (Meta)</name>
|
<name>MokoSuiteCross - Threads (Meta)</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - TikTok</name>
|
<name>MokoSuiteCross - TikTok</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Tumblr</name>
|
<name>MokoSuiteCross - Tumblr</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - X / Twitter</name>
|
<name>MokoSuiteCross - X / Twitter</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Generic Webhook</name>
|
<name>MokoSuiteCross - Generic Webhook</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - WhatsApp Business</name>
|
<name>MokoSuiteCross - WhatsApp Business</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - WordPress</name>
|
<name>MokoSuiteCross - WordPress</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||||
<name>MokoSuiteCross - Youtube</name>
|
<name>MokoSuiteCross - Youtube</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-06-23</creationDate>
|
<creationDate>2026-06-23</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="system" method="upgrade">
|
<extension type="plugin" group="system" method="upgrade">
|
||||||
<name>System - MokoSuiteCross</name>
|
<name>System - MokoSuiteCross</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -34,20 +34,10 @@ class MokoSuiteCross extends CMSPlugin implements SubscriberInterface
|
|||||||
public static function getSubscribedEvents(): array
|
public static function getSubscribedEvents(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'onAfterRoute' => 'onAfterRoute',
|
|
||||||
'onAfterRender' => 'onAfterRender',
|
'onAfterRender' => 'onAfterRender',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onAfterRoute(): void
|
|
||||||
{
|
|
||||||
$app = $this->getApplication();
|
|
||||||
|
|
||||||
if ($app->isClient('administrator')) {
|
|
||||||
$this->warnMissingLicenseKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process queued posts on page load (backend and/or frontend).
|
* Process queued posts on page load (backend and/or frontend).
|
||||||
*
|
*
|
||||||
@@ -93,59 +83,6 @@ class MokoSuiteCross extends CMSPlugin implements SubscriberInterface
|
|||||||
\Joomla\Component\MokoSuiteCross\Administrator\Helper\QueueProcessor::processQueue(5);
|
\Joomla\Component\MokoSuiteCross\Administrator\Helper\QueueProcessor::processQueue(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Warn administrators once per session when no license key is configured.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private function warnMissingLicenseKey(): void
|
|
||||||
{
|
|
||||||
$session = Factory::getSession();
|
|
||||||
|
|
||||||
if ($session->get('mokosuitecross.license_warned', false)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = Factory::getUser();
|
|
||||||
|
|
||||||
if ($user->guest || !$user->authorise('core.manage')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$session->set('mokosuitecross.license_warned', true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('extra_query'))
|
|
||||||
->from($db->quoteName('#__update_sites'))
|
|
||||||
->where($db->quoteName('name') . ' = ' . $db->quote('MokoSuiteCross Updates'))
|
|
||||||
->setLimit(1);
|
|
||||||
$db->setQuery($query);
|
|
||||||
$extraQuery = (string) $db->loadResult();
|
|
||||||
|
|
||||||
if (!empty($extraQuery)) {
|
|
||||||
parse_str($extraQuery, $parsed);
|
|
||||||
|
|
||||||
if (!empty($parsed['dlid']) && preg_match('/^MOKO-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}$/', $parsed['dlid'])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->getApplication()->enqueueMessage(
|
|
||||||
'<strong>Moko Consulting License Key Required</strong> — '
|
|
||||||
. 'No download key is configured. Updates will not be available until a valid license key is entered. '
|
|
||||||
. 'Go to <a href="index.php?option=com_installer&view=updatesites">System → Update Sites</a> '
|
|
||||||
. 'and enter your license key (<code>MOKO-XXXX-XXXX-XXXX-XXXX</code>) in the Download Key field '
|
|
||||||
. 'for the MokoSuiteCross update site.',
|
|
||||||
'warning'
|
|
||||||
);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
// Don't break admin over a license check
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store the last page-load run timestamp.
|
* Store the last page-load run timestamp.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="system" method="upgrade">
|
<extension type="plugin" group="system" method="upgrade">
|
||||||
<name>System - MokoSuiteCross Events</name>
|
<name>System - MokoSuiteCross Events</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="system" method="upgrade">
|
<extension type="plugin" group="system" method="upgrade">
|
||||||
<name>System - MokoSuiteCross Gallery</name>
|
<name>System - MokoSuiteCross Gallery</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="task" method="upgrade">
|
<extension type="plugin" group="task" method="upgrade">
|
||||||
<name>Task - MokoSuiteCross Queue Processor</name>
|
<name>Task - MokoSuiteCross Queue Processor</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="webservices" method="upgrade">
|
<extension type="plugin" group="webservices" method="upgrade">
|
||||||
<name>Web Services - MokoSuiteCross</name>
|
<name>Web Services - MokoSuiteCross</name>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
+2
-2
@@ -35,8 +35,9 @@ class MokoSuiteCrossWebServices extends CMSPlugin implements SubscriberInterface
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onBeforeApiRoute(&$router): void
|
public function onBeforeApiRoute($event): void
|
||||||
{
|
{
|
||||||
|
$router = $event instanceof \Joomla\CMS\Event\AbstractEvent ? $event->getRouter() : $event;
|
||||||
$defaults = ['component' => 'com_mokosuitecross'];
|
$defaults = ['component' => 'com_mokosuitecross'];
|
||||||
|
|
||||||
$router->createCRUDRoutes('v1/mokosuitecross/posts', 'posts', $defaults);
|
$router->createCRUDRoutes('v1/mokosuitecross/posts', 'posts', $defaults);
|
||||||
@@ -44,7 +45,6 @@ class MokoSuiteCrossWebServices extends CMSPlugin implements SubscriberInterface
|
|||||||
$router->createCRUDRoutes('v1/mokosuitecross/templates', 'templates', $defaults);
|
$router->createCRUDRoutes('v1/mokosuitecross/templates', 'templates', $defaults);
|
||||||
$router->createCRUDRoutes('v1/mokosuitecross/logs', 'logs', $defaults);
|
$router->createCRUDRoutes('v1/mokosuitecross/logs', 'logs', $defaults);
|
||||||
|
|
||||||
// Action endpoint: dispatch cross-posts for an article (POST only)
|
|
||||||
$router->addRoute(
|
$router->addRoute(
|
||||||
new \Joomla\Router\Route(['POST'], 'v1/mokosuitecross/dispatch', 'dispatch.dispatch', [], $defaults)
|
new \Joomla\Router\Route(['POST'], 'v1/mokosuitecross/dispatch', 'dispatch.dispatch', [], $defaults)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<extension type="package" method="upgrade">
|
<extension type="package" method="upgrade">
|
||||||
<name>MokoSuiteCross</name>
|
<name>MokoSuiteCross</name>
|
||||||
<packagename>mokosuitecross</packagename>
|
<packagename>mokosuitecross</packagename>
|
||||||
<version>01.05.00</version>
|
<version>01.08.17</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
# MokoSuiteCross Wiki
|
|
||||||
|
|
||||||
**MokoSuiteCross** — Cross-posting Joomla content to social media, email marketing, and chat platforms.
|
|
||||||
|
|
||||||
## Quick Start
|
|
||||||
|
|
||||||
1. Install `pkg_mokosuitecross-*.zip` via Joomla Extensions → Install
|
|
||||||
2. Navigate to **Components → MokoSuiteCross → Services**
|
|
||||||
3. Add your first service (e.g., Telegram, Discord, Facebook)
|
|
||||||
4. Publish an article — it's automatically cross-posted to all active services
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
- [Installation](getting-started/Installation)
|
|
||||||
- [Configuration](getting-started/Configuration)
|
|
||||||
|
|
||||||
## User Guide
|
|
||||||
|
|
||||||
- [Services](user-guide/Services)
|
|
||||||
- [Telegram](services/Telegram)
|
|
||||||
- [Message Templates](user-guide/Message-Templates)
|
|
||||||
- [Troubleshooting](user-guide/Troubleshooting)
|
|
||||||
|
|
||||||
## Developer
|
|
||||||
|
|
||||||
- [Developer Guide](developer/Developer-Guide)
|
|
||||||
- [Adding Custom Services](developer/Adding-Custom-Services)
|
|
||||||
- [REST API](developer/REST-API)
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
|
|
||||||
MokoSuiteCross uses a **plugin-based service architecture**. Each social platform is a separate Joomla plugin in the custom `mokosuitecross` plugin group. This means:
|
|
||||||
|
|
||||||
- Install only the platforms you need
|
|
||||||
- Third-party developers can add new platforms as plugins
|
|
||||||
- Each service plugin implements `MokoSuiteCrossServiceInterface`
|
|
||||||
- Services support both **default bot/app** mode (pre-configured by Moko) and **custom** mode (bring your own API keys)
|
|
||||||
|
|
||||||
## Database Tables
|
|
||||||
|
|
||||||
| Table | Purpose |
|
|
||||||
|-------|---------|
|
|
||||||
| `#__mokosuitecross_services` | Connected service accounts |
|
|
||||||
| `#__mokosuitecross_posts` | Cross-post queue and history |
|
|
||||||
| `#__mokosuitecross_templates` | Per-platform message templates |
|
|
||||||
| `#__mokosuitecross_logs` | Activity and error logs |
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
# Adding Custom Services
|
|
||||||
|
|
||||||
MokoSuiteCross uses a plugin-based architecture. Any developer can create a new service plugin.
|
|
||||||
|
|
||||||
## Plugin Structure
|
|
||||||
|
|
||||||
Create a Joomla plugin in the `mokosuitecross` group:
|
|
||||||
|
|
||||||
```
|
|
||||||
plg_mokosuitecross_myservice/
|
|
||||||
├── myservice.xml # Plugin manifest (group="mokosuitecross")
|
|
||||||
├── myservice.php # Legacy stub (empty)
|
|
||||||
├── src/
|
|
||||||
│ └── Extension/
|
|
||||||
│ └── MyserviceService.php # Implements MokoSuiteCrossServiceInterface
|
|
||||||
├── services/
|
|
||||||
│ └── provider.php # DI container registration
|
|
||||||
└── language/
|
|
||||||
└── en-GB/
|
|
||||||
├── plg_mokosuitecross_myservice.ini
|
|
||||||
└── plg_mokosuitecross_myservice.sys.ini
|
|
||||||
```
|
|
||||||
|
|
||||||
## Implement the Interface
|
|
||||||
|
|
||||||
Your Extension class must implement `MokoSuiteCrossServiceInterface`:
|
|
||||||
|
|
||||||
```php
|
|
||||||
namespace Joomla\Plugin\MokoSuiteCross\Myservice\Extension;
|
|
||||||
|
|
||||||
use Joomla\CMS\Plugin\CMSPlugin;
|
|
||||||
use Joomla\Component\MokoSuiteCross\Administrator\Service\MokoSuiteCrossServiceInterface;
|
|
||||||
use Joomla\Event\SubscriberInterface;
|
|
||||||
|
|
||||||
class MyserviceService extends CMSPlugin implements SubscriberInterface, MokoSuiteCrossServiceInterface
|
|
||||||
{
|
|
||||||
public static function getSubscribedEvents(): array
|
|
||||||
{
|
|
||||||
return ['onMokoSuiteCrossGetServices' => 'onMokoSuiteCrossGetServices'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onMokoSuiteCrossGetServices(&$services): void
|
|
||||||
{
|
|
||||||
$services[] = $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getServiceType(): string { return 'myservice'; }
|
|
||||||
public function getServiceName(): string { return 'My Service'; }
|
|
||||||
public function getMaxLength(): int { return 500; }
|
|
||||||
public function supportsMedia(): bool { return true; }
|
|
||||||
|
|
||||||
public function publish(string $message, array $media, array $credentials, array $params): array
|
|
||||||
{
|
|
||||||
// Your API integration here
|
|
||||||
return ['success' => true, 'platform_post_id' => '...', 'response' => [...]];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function validateCredentials(array $credentials): array
|
|
||||||
{
|
|
||||||
return ['valid' => true, 'message' => 'OK', 'account_name' => '...'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Required Methods
|
|
||||||
|
|
||||||
| Method | Returns | Purpose |
|
|
||||||
|--------|---------|---------|
|
|
||||||
| `getServiceType()` | string | Unique identifier (lowercase, no spaces) |
|
|
||||||
| `getServiceName()` | string | Display name in admin UI |
|
|
||||||
| `publish()` | array | Send content to the platform |
|
|
||||||
| `validateCredentials()` | array | Test if credentials work |
|
|
||||||
| `getMaxLength()` | int | Character limit (0 = no limit) |
|
|
||||||
| `supportsMedia()` | bool | Whether images can be attached |
|
|
||||||
@@ -1,337 +0,0 @@
|
|||||||
# Developer Guide
|
|
||||||
|
|
||||||
This guide covers building new service plugins for MokoSuiteCross — from directory structure through testing.
|
|
||||||
|
|
||||||
## Plugin Directory Structure
|
|
||||||
|
|
||||||
Each service plugin lives in its own package under `source/packages/`:
|
|
||||||
|
|
||||||
```
|
|
||||||
plg_mokosuitecross_myservice/
|
|
||||||
├── myservice.xml ← Joomla manifest (type="plugin", group="mokosuitecross")
|
|
||||||
├── myservice.php ← Legacy loader stub (empty, required by Joomla)
|
|
||||||
├── services/
|
|
||||||
│ └── provider.php ← DI container: registers the Extension class
|
|
||||||
└── src/
|
|
||||||
└── Extension/
|
|
||||||
└── MyServiceService.php ← Main class: implements the interface
|
|
||||||
```
|
|
||||||
|
|
||||||
## MokoSuiteCrossServiceInterface
|
|
||||||
|
|
||||||
Every service plugin **must** implement `MokoSuiteCrossServiceInterface`. The interface defines 5 methods:
|
|
||||||
|
|
||||||
```php
|
|
||||||
namespace Joomla\Component\MokoSuiteCross\Administrator\Service;
|
|
||||||
|
|
||||||
interface MokoSuiteCrossServiceInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Unique identifier matching the service_type in service.xml.
|
|
||||||
* Must match exactly (e.g. 'mastodon', 'telegram').
|
|
||||||
*/
|
|
||||||
public function getServiceType(): string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Human-readable display name (e.g. 'Mastodon', 'Telegram').
|
|
||||||
*/
|
|
||||||
public function getServiceName(): string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Post content to the platform.
|
|
||||||
*
|
|
||||||
* @param string $message Rendered message text (already template-processed)
|
|
||||||
* @param array $media Array of media file paths (images)
|
|
||||||
* @param array $credentials Decrypted credential key-value pairs from the service record
|
|
||||||
* @param array $params Plugin params + service params merged
|
|
||||||
* @return array ['success' => bool, 'platform_post_id' => string, 'response' => array]
|
|
||||||
*/
|
|
||||||
public function publish(string $message, array $media, array $credentials, array $params): array;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test whether the stored credentials are valid.
|
|
||||||
*
|
|
||||||
* @param array $credentials Decrypted credential key-value pairs
|
|
||||||
* @return array ['valid' => bool, 'message' => string, 'account_name' => string]
|
|
||||||
*/
|
|
||||||
public function validateCredentials(array $credentials): array;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Platform character limit (0 = unlimited).
|
|
||||||
*/
|
|
||||||
public function getMaxLength(): int;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether this service supports image/media attachments.
|
|
||||||
*/
|
|
||||||
public function supportsMedia(): bool;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Step-by-Step: Creating a New Service Plugin
|
|
||||||
|
|
||||||
### 1. Create the manifest (`myservice.xml`)
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
|
||||||
<name>plg_mokosuitecross_myservice</name>
|
|
||||||
<author>Moko Consulting</author>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<description>MyService integration for MokoSuiteCross</description>
|
|
||||||
<namespace path="src">Joomla\Plugin\MokoSuiteCross\MyService</namespace>
|
|
||||||
<files>
|
|
||||||
<filename plugin="myservice">myservice.php</filename>
|
|
||||||
<folder>services</folder>
|
|
||||||
<folder>src</folder>
|
|
||||||
</files>
|
|
||||||
<!-- Optional: plugin-level params (e.g. default bot tokens) -->
|
|
||||||
<config>
|
|
||||||
<fields name="params">
|
|
||||||
<fieldset name="basic">
|
|
||||||
<field name="default_token" type="password"
|
|
||||||
label="Default Bot Token"
|
|
||||||
description="Pre-configured token for default mode" />
|
|
||||||
</fieldset>
|
|
||||||
</fields>
|
|
||||||
</config>
|
|
||||||
</extension>
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Create the legacy stub (`myservice.php`)
|
|
||||||
|
|
||||||
```php
|
|
||||||
<?php
|
|
||||||
// Legacy stub — required by Joomla plugin loader. Intentionally empty.
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. Create the DI provider (`services/provider.php`)
|
|
||||||
|
|
||||||
```php
|
|
||||||
<?php
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Extension\PluginInterface;
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Plugin\PluginHelper;
|
|
||||||
use Joomla\DI\Container;
|
|
||||||
use Joomla\DI\ServiceProviderInterface;
|
|
||||||
use Joomla\Event\DispatcherInterface;
|
|
||||||
use Joomla\Plugin\MokoSuiteCross\MyService\Extension\MyServiceService;
|
|
||||||
|
|
||||||
return new class implements ServiceProviderInterface {
|
|
||||||
public function register(Container $container): void
|
|
||||||
{
|
|
||||||
$container->set(
|
|
||||||
PluginInterface::class,
|
|
||||||
function (Container $container) {
|
|
||||||
$dispatcher = $container->get(DispatcherInterface::class);
|
|
||||||
$plugin = new MyServiceService($dispatcher, (array) PluginHelper::getPlugin('mokosuitecross', 'myservice'));
|
|
||||||
$plugin->setApplication(Factory::getApplication());
|
|
||||||
return $plugin;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. Create the Extension class
|
|
||||||
|
|
||||||
```php
|
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Joomla\Plugin\MokoSuiteCross\MyService\Extension;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Plugin\CMSPlugin;
|
|
||||||
use Joomla\Component\MokoSuiteCross\Administrator\Service\MokoSuiteCrossServiceInterface;
|
|
||||||
use Joomla\Event\SubscriberInterface;
|
|
||||||
|
|
||||||
class MyServiceService extends CMSPlugin implements SubscriberInterface, MokoSuiteCrossServiceInterface
|
|
||||||
{
|
|
||||||
public static function getSubscribedEvents(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'onMokoSuiteCrossGetServices' => 'onMokoSuiteCrossGetServices',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onMokoSuiteCrossGetServices(&$services): void
|
|
||||||
{
|
|
||||||
$services[] = $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getServiceType(): string
|
|
||||||
{
|
|
||||||
return 'myservice';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getServiceName(): string
|
|
||||||
{
|
|
||||||
return 'My Service';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function publish(string $message, array $media, array $credentials, array $params): array
|
|
||||||
{
|
|
||||||
// Your API integration here
|
|
||||||
// $credentials contains the decrypted values from service.xml fields
|
|
||||||
// e.g. $credentials['api_key'], $credentials['webhook_url']
|
|
||||||
|
|
||||||
return [
|
|
||||||
'success' => true,
|
|
||||||
'platform_post_id' => 'abc123',
|
|
||||||
'response' => ['status' => 'ok'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function validateCredentials(array $credentials): array
|
|
||||||
{
|
|
||||||
// Test the credentials against the platform API
|
|
||||||
return [
|
|
||||||
'valid' => true,
|
|
||||||
'message' => 'Connected',
|
|
||||||
'account_name' => 'MyAccount',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMaxLength(): int
|
|
||||||
{
|
|
||||||
return 0; // 0 = no limit
|
|
||||||
}
|
|
||||||
|
|
||||||
public function supportsMedia(): bool
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 5. Add credential fields to `service.xml`
|
|
||||||
|
|
||||||
In `source/packages/com_mokosuitecross/forms/service.xml`, add your fields with `showon`:
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<!-- ======== MY SERVICE ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_myservice_api_key"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOSUITECROSS_CRED_MYSERVICE_KEY"
|
|
||||||
showon="service_type:myservice"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
```
|
|
||||||
|
|
||||||
### 6. Add language strings to `com_mokosuitecross.ini`
|
|
||||||
|
|
||||||
```ini
|
|
||||||
COM_MOKOSUITECROSS_CRED_MYSERVICE_KEY="API Key"
|
|
||||||
```
|
|
||||||
|
|
||||||
### 7. Add to the service_type dropdown (if not already listed)
|
|
||||||
|
|
||||||
In the `<field name="service_type">` list in `service.xml`, add:
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<option value="myservice">My Service</option>
|
|
||||||
```
|
|
||||||
|
|
||||||
## How `showon` Credential Fields Work
|
|
||||||
|
|
||||||
Joomla's `showon` attribute controls field visibility client-side via JavaScript:
|
|
||||||
|
|
||||||
| Pattern | Meaning |
|
|
||||||
|---------|---------|
|
|
||||||
| `showon="service_type:telegram"` | Show when service type is Telegram |
|
|
||||||
| `showon="service_type:telegram[AND]cred_mode:custom"` | Show when Telegram AND custom mode |
|
|
||||||
| `showon="service_type:webhook[AND]cred_webhook_auth_type:bearer,basic"` | Show when webhook AND auth is bearer or basic |
|
|
||||||
|
|
||||||
Fields are hidden/shown without page reloads. The form data for hidden fields is still submitted but ignored by the component.
|
|
||||||
|
|
||||||
## Dispatch Pipeline
|
|
||||||
|
|
||||||
The cross-posting flow works like this:
|
|
||||||
|
|
||||||
1. **Article published** → System plugin (`plg_system_mokosuitecross`) catches `onContentAfterSave`
|
|
||||||
2. **Queue creation** → For each enabled service, a `#__mokosuitecross_posts` row is created with status `queued`
|
|
||||||
3. **Queue processing** → Either the Scheduled Task or page-load fallback picks up queued posts
|
|
||||||
4. **Service dispatch** → `QueueProcessor` fires `onMokoSuiteCrossGetServices` event in the `mokosuitecross` plugin group
|
|
||||||
5. **Plugin response** → Each registered service plugin adds itself to the `$services` array
|
|
||||||
6. **Matching** → The processor finds the plugin whose `getServiceType()` matches the service record's `service_type`
|
|
||||||
7. **Publishing** → `publish()` is called with the rendered message, media paths, decrypted credentials, and params
|
|
||||||
8. **Result** → The post record is updated with `posted`/`failed` status and the platform response
|
|
||||||
|
|
||||||
## Default Bot Mode
|
|
||||||
|
|
||||||
Some services (Telegram, Discord, Slack, Teams, Facebook, Threads) support a **default mode** where pre-configured MokoSuite credentials are used. This is controlled by:
|
|
||||||
|
|
||||||
1. The `cred_mode` field in `service.xml` (shown for services listed in its `showon`)
|
|
||||||
2. Plugin-level params in the plugin manifest (`<config>` section) that store default tokens
|
|
||||||
3. The service plugin's `publish()` method checks `$credentials['mode']`:
|
|
||||||
- `'default'` → use plugin params (`$this->params->get('default_token')`)
|
|
||||||
- `'custom'` → use the per-service credentials from `$credentials`
|
|
||||||
|
|
||||||
## OAuth Integration
|
|
||||||
|
|
||||||
For services requiring OAuth (Facebook, LinkedIn, Twitter, Pinterest, etc.):
|
|
||||||
|
|
||||||
1. **OAuthHelper** (`source/packages/com_mokosuitecross/src/Helper/OAuthHelper.php`) handles:
|
|
||||||
- Authorization URL generation with state parameter
|
|
||||||
- Code-to-token exchange
|
|
||||||
- Token storage back to the service record's credentials
|
|
||||||
|
|
||||||
2. **OauthController** provides two endpoints:
|
|
||||||
- `task=oauth.authorize` → redirects to the platform's auth page
|
|
||||||
- `task=oauth.callback` → handles the redirect, exchanges code for token
|
|
||||||
|
|
||||||
3. Plugin params store the OAuth Client ID and Secret (set in Extensions → Plugins)
|
|
||||||
|
|
||||||
4. In `edit.php`, services listed in `$oauthServices` get a "Connect to {Service}" button
|
|
||||||
|
|
||||||
## Testing Your Plugin
|
|
||||||
|
|
||||||
1. **Syntax check**: `php -l source/packages/plg_mokosuitecross_myservice/src/Extension/MyServiceService.php`
|
|
||||||
2. **Install**: Include the plugin in `pkg_mokosuitecross.xml` or install the plugin ZIP standalone
|
|
||||||
3. **Enable**: Extensions → Plugins → search "mokosuitecross myservice" → Enable
|
|
||||||
4. **Add service**: Components → MokoSuiteCross → Services → New → select your service type
|
|
||||||
5. **Verify fields**: Confirm your credential fields appear when your service type is selected
|
|
||||||
6. **Test post**: Publish an article and check the Post Queue for results
|
|
||||||
|
|
||||||
## Example: Building a "Fediverse" Service
|
|
||||||
|
|
||||||
Imagine building a service for a Mastodon-compatible platform:
|
|
||||||
|
|
||||||
```php
|
|
||||||
public function publish(string $message, array $media, array $credentials, array $params): array
|
|
||||||
{
|
|
||||||
$instanceUrl = rtrim($credentials['instance_url'] ?? '', '/');
|
|
||||||
$token = $credentials['access_token'] ?? '';
|
|
||||||
|
|
||||||
$ch = curl_init($instanceUrl . '/api/v1/statuses');
|
|
||||||
curl_setopt_array($ch, [
|
|
||||||
CURLOPT_POST => true,
|
|
||||||
CURLOPT_POSTFIELDS => json_encode(['status' => $message]),
|
|
||||||
CURLOPT_HTTPHEADER => [
|
|
||||||
'Content-Type: application/json',
|
|
||||||
'Authorization: Bearer ' . $token,
|
|
||||||
],
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_TIMEOUT => 30,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
$data = json_decode($response, true) ?: [];
|
|
||||||
|
|
||||||
if ($httpCode === 200 && !empty($data['id'])) {
|
|
||||||
return ['success' => true, 'platform_post_id' => $data['id'], 'response' => $data];
|
|
||||||
}
|
|
||||||
|
|
||||||
return ['success' => false, 'platform_post_id' => '', 'response' => $data];
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
This pattern — curl to API, check response code, return structured result — is the same for every service plugin. The only differences are the API endpoint, authentication method, and payload format.
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
# REST API
|
|
||||||
|
|
||||||
MokoSuiteCross includes a WebServices plugin that provides REST API endpoints via Joomla's API application.
|
|
||||||
|
|
||||||
## Authentication
|
|
||||||
|
|
||||||
All endpoints require a Joomla API token. Generate one in **Users → Manage → [User] → API Tokens**.
|
|
||||||
|
|
||||||
Include the token in the `Authorization` header:
|
|
||||||
|
|
||||||
```
|
|
||||||
Authorization: Bearer YOUR_API_TOKEN
|
|
||||||
```
|
|
||||||
|
|
||||||
## Base URL
|
|
||||||
|
|
||||||
```
|
|
||||||
https://yoursite.com/api/index.php/v1/mokosuitecross/
|
|
||||||
```
|
|
||||||
|
|
||||||
## Endpoints
|
|
||||||
|
|
||||||
### Posts
|
|
||||||
|
|
||||||
| Method | Endpoint | Description |
|
|
||||||
|--------|----------|-------------|
|
|
||||||
| GET | `/v1/mokosuitecross/posts` | List all cross-posts |
|
|
||||||
| GET | `/v1/mokosuitecross/posts/:id` | Get single post details |
|
|
||||||
| POST | `/v1/mokosuitecross/posts` | Create a cross-post entry |
|
|
||||||
| DELETE | `/v1/mokosuitecross/posts/:id` | Delete a post |
|
|
||||||
|
|
||||||
### Services
|
|
||||||
|
|
||||||
| Method | Endpoint | Description |
|
|
||||||
|--------|----------|-------------|
|
|
||||||
| GET | `/v1/mokosuitecross/services` | List connected services |
|
|
||||||
| GET | `/v1/mokosuitecross/services/:id` | Get service details |
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# List all posts
|
|
||||||
curl -H "Authorization: Bearer YOUR_TOKEN" \
|
|
||||||
https://yoursite.com/api/index.php/v1/mokosuitecross/posts
|
|
||||||
|
|
||||||
# List services
|
|
||||||
curl -H "Authorization: Bearer YOUR_TOKEN" \
|
|
||||||
https://yoursite.com/api/index.php/v1/mokosuitecross/services
|
|
||||||
```
|
|
||||||
|
|
||||||
## Filtering
|
|
||||||
|
|
||||||
Posts support query parameters:
|
|
||||||
- `filter[status]=posted` — Filter by status (queued, posting, posted, failed, scheduled)
|
|
||||||
- `filter[service_id]=5` — Filter by service
|
|
||||||
- `page[limit]=20` — Pagination limit
|
|
||||||
- `page[offset]=0` — Pagination offset
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
# Configuration
|
|
||||||
|
|
||||||
Navigate to **Components → MokoSuiteCross** to access the admin panel.
|
|
||||||
|
|
||||||
## Global Settings
|
|
||||||
|
|
||||||
Go to **Options** (toolbar gear icon) to configure:
|
|
||||||
|
|
||||||
| Setting | Default | Description |
|
|
||||||
|---------|---------|-------------|
|
|
||||||
| Auto-post on Publish | Yes | Automatically cross-post when articles are published |
|
|
||||||
| Max Retries | 3 | How many times to retry a failed post |
|
|
||||||
| Retry Delay | 300s | Seconds between retry attempts |
|
|
||||||
| Log Retention | 90 days | How long to keep activity logs |
|
|
||||||
| Default Template | `{title}\n\n{introtext}\n\n{url}` | Fallback message template |
|
|
||||||
|
|
||||||
## Message Templates
|
|
||||||
|
|
||||||
Templates use placeholders that are replaced with article data:
|
|
||||||
|
|
||||||
| Placeholder | Description |
|
|
||||||
|-------------|-------------|
|
|
||||||
| `{title}` | Article title |
|
|
||||||
| `{url}` | Full article URL |
|
|
||||||
| `{introtext}` | Article intro text (stripped of HTML, max 280 chars) |
|
|
||||||
| `{image}` | Article intro image URL |
|
|
||||||
| `{category}` | Article category name |
|
|
||||||
| `{author}` | Article author name |
|
|
||||||
|
|
||||||
You can create per-platform templates. The system checks for a platform-specific template first, then falls back to the default.
|
|
||||||
|
|
||||||
## Service Modes
|
|
||||||
|
|
||||||
Services that support universal bots offer two modes:
|
|
||||||
|
|
||||||
- **Default Mode** — Uses the pre-configured MokoSuite bot/app. API keys are stored in the component's encrypted global params and never exposed in the individual service record.
|
|
||||||
- **Custom Mode** — You provide your own API keys, tokens, and credentials.
|
|
||||||
|
|
||||||
Services supporting default mode: **Telegram** (@mokosuite_bot), **Facebook**, **Discord**, **Slack**
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user