Skip to content
This repository has been archived by the owner on Feb 12, 2019. It is now read-only.

Add auto-buddy feature for published rosters #170

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions etc/sm.xml.dist.in
Original file line number Diff line number Diff line change
Expand Up @@ -694,11 +694,13 @@
This will significantly speed up publishing of roster.
If unspecified or 0, no cache is used. -->
<active-cache-ttl>60</active-cache-ttl>
<!-- If <fix-subscriptions/> is not commented, set "to" and "from" subscriptions of
user's contacts to subscriptions of corresponding published
contacts. -->
<!-- If <fix-subscriptions/> is not commented:
1 - set "to" and "from" subscriptions of user's contacts to
subscriptions of corresponding published contacts.
2 - set "to" and "from" subscriptions of user's contacts to "1",
auto-accepting all subscription requests ("auto-buddy"). -->
<!--
<fix-subscriptions/>
<fix-subscriptions>2</fix-subscriptions>
-->
<!-- If <override-names/> is uncommented, then displayed names of
contacts in user's roster will be updated accordingly to
Expand Down
26 changes: 19 additions & 7 deletions sm/mod_roster_publish.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,27 @@ static int _roster_publish_user_load(mod_instance_t mi, user_t user) {
continue; /* do { } while( os_iter_next ) */
}
if( roster_publish->fixsubs ) {
/* check subscriptions and correct if needed */
os_object_get_bool(os, o, "to", &tmp_to);
os_object_get_bool(os, o, "from", &tmp_from);
if( item->to != tmp_to || item->from != tmp_from ) {
item->to = tmp_to;
item->from = tmp_from;
log_debug(ZONE, "fixsubs in roster %s, item %s",jid_user(user->jid),jid_user(item->jid));
xhash_put(user->roster, jid_full(item->jid), (void *) item);
_roster_publish_save_item(user,item);
if( roster_publish->fixsubs == 1 ) {
/* check subscriptions and correct if needed */
if( item->to != tmp_to || item->from != tmp_from ) {
item->to = tmp_to;
item->from = tmp_from;
log_debug(ZONE, "fixsubs in roster %s, item %s",jid_user(user->jid),jid_user(item->jid));
xhash_put(user->roster, jid_full(item->jid), (void *) item);
_roster_publish_save_item(user,item);
}
}
if( roster_publish->fixsubs == 2 ) {
/* force subscriptions for all published contacts */
item->to = 1;
item->from = 1;
if( item->to != tmp_to || item->from != tmp_from ) {
log_debug(ZONE, "auto-buddy in roster %s, item %s",jid_user(user->jid),jid_user(item->jid));
xhash_put(user->roster, jid_full(item->jid), (void *) item);
_roster_publish_save_item(user,item);
}
}
}
if( roster_publish->overridenames ) {
Expand Down