# Contributor: Marian <marian.buschsieweke@ovgu.de>
# Maintainer: Marian <marian.buschsieweke@ovgu.de>
pkgname=prosody-modules
pkgver=0.9.20170828
_commit=595d9d68fd11
pkgrel=0
pkgdesc="modules for the prosody XMPP server"
url="https://modules.prosody.im/"
arch="noarch"
license="MIT"
makedepends=""
# Create one subpackage for every modules considered stable [1]. In addition
# the modules mod-auth-ldap, mod-auth-pam, mod-carbons, mod-mam and mod-smacks
# are included.
# [1]: https://modules.prosody.im/stage_stable.html
subpackages="
	prosody-mod-auth_ldap
	prosody-mod-auth_pam
	prosody-mod-auth_sql
	prosody-mod-broadcast
	prosody-mod-carbons
	prosody-mod-c2s_conn_throttle
	prosody-mod-host_guard
	prosody-mod-ipcheck
	prosody-mod-log_auth
	prosody-mod-mam
	prosody-mod-pastebin
	prosody-mod-register_json
	prosody-mod-register_redirect
	prosody-mod-reload_modules
	prosody-mod-require_otr
	prosody-mod-s2s_idle_timeout
	prosody-mod-saslname
	prosody-mod-server_status
	prosody-mod-smacks
	prosody-mod-stanza_counter
	prosody-mod-support_contact
	prosody-mod-webpresence"
depends="prosody $subpackages"
source="${pkgname}-${_commit}.tar.gz::https://hg.prosody.im/prosody-modules/archive/${_commit}.tar.gz"
options="!check"
builddir="${srcdir}/prosody-modules-${_commit}"

package(){
	mkdir -p "$pkgdir"
}

_package_mod(){
	mod="mod_${subpkgname#prosody-mod-}"
	cd "$builddir"
	if [ -f "$mod/$mod.lua" ] ; then
		# Module is a single file
		install -Dm644 "$mod/$mod.lua" "${subpkgdir}/usr/lib/prosody/modules/$mod.lua"
	else
		# Module is a folder
		mkdir -p "${subpkgdir}/usr/lib/prosody/modules"
		cp -R "$mod/${mod}" "${subpkgdir}/usr/lib/prosody/modules/"
	fi
}

auth_ldap(){
	depends="prosody<0.10 lua5.1-ldap"
	pkgdesc="prosody module providing client authentication using LDAP"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

auth_pam(){
	depends="prosody"
	pkgdesc="prosody module providing client authentication using PAM"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

auth_sql(){
	depends="prosody"
	pkgdesc="prosody module providing client authentication using SQL db queries"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

broadcast(){
	depends="prosody"
	pkgdesc="prosody module similiar to mod_announce, but compatible with shitty clients"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

carbons(){
	depends="prosody<0.10"
	pkgdesc="prosody module limiting the frequency of login attempts"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

c2s_conn_throttle(){
	depends="prosody"
	pkgdesc="prosody module limiting the frequency of login attempts"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

host_guard(){
	depends="prosody"
	pkgdesc="prosody module configure access for each virtual host XMPP hosts"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

ipcheck(){
	depends="prosody"
	pkgdesc="prosody module implementing XEP-0279: Server IP Check"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

log_auth(){
	depends="prosody"
	pkgdesc="prosody module to log the clients IP address for failed login attempts"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

mam(){
	depends="prosody"
	pkgdesc="prosody module implementing XEP-0313: Message Archive Management"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

pastebin(){
	depends="prosody"
	pkgdesc="prosody module moving large messages in MUCs to a build-in webserver"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

register_json(){
	depends="prosody"
	pkgdesc="prosody module to handle registrations via HTTP POST requests containg JSON"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	# This module does not follow naming conventions, package it manually :-(
	mod="mod_${subpkgname#prosody-mod-}"
	cd "$builddir"
	mkdir -p "${subpkgdir}/usr/lib/prosody/modules"
	cp -R "$mod/${mod#mod_}" "${subpkgdir}/usr/lib/prosody/modules/"
}

register_redirect(){
	depends="prosody"
	pkgdesc="prosody module showing instructions on how to register for out-of-band methods"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

reload_modules(){
	depends="prosody"
	pkgdesc="prosody module that reloads modules when the config file changes"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

require_otr(){
	depends="prosody"
	pkgdesc="prosody module that forces clients to use OTR encryption"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

s2s_idle_timeout(){
	depends="prosody"
	pkgdesc="prosody module that closes idle s2s connections after a while"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

saslname(){
	depends="prosody"
	pkgdesc="prosody module that implements XEP-0233 to advertise the Kerberes principal name"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

server_status(){
	depends="prosody prosody-mod-stanza_counter"
	pkgdesc="prosody module that publishes the server status as XML/JSON"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

smacks(){
	depends="prosody"
	pkgdesc="prosody module that implements XEP-0198: Stream Management"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

stanza_counter(){
	depends="prosody"
	pkgdesc="prosody module that counts in- and outgoing stanzas"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

support_contact(){
	depends="prosody"
	pkgdesc="prosody module that adds a default contact to newly registered accounts"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

webpresence(){
	depends="prosody"
	pkgdesc="prosody module that publishes the online status of jabber uses e.g. in a blog"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

sha512sums="fba8311f4b718b613435536bef36c0c01c62c663d8093ac6710eab9b784a08d4f689658c800f58fe4148bd43d9e0c6a5d56be3f2cff4ead6555a623860cb0825  prosody-modules-595d9d68fd11.tar.gz"
