forked from GNUsocial/gnu-social
API group actions join/leave now handle same events of web UI action
This commit is contained in:
parent
c246c17d3e
commit
dc41e3dc2d
@ -125,25 +125,16 @@ class ApiGroupJoinAction extends ApiAuthAction
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$member = new Group_member();
|
try {
|
||||||
|
if (Event::handle('StartJoinGroup', array($this->group, $this->user))) {
|
||||||
$member->group_id = $this->group->id;
|
Group_member::join($this->group->id, $this->user->id);
|
||||||
$member->profile_id = $this->user->id;
|
Event::handle('EndJoinGroup', array($this->group, $this->user));
|
||||||
$member->created = common_sql_now();
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
$result = $member->insert();
|
// TRANS: Server error displayed when joining a group failed in the database.
|
||||||
|
// TRANS: %1$s is the joining user's nickname, $2$s is the group nickname for which the join failed.
|
||||||
if (!$result) {
|
$this->serverError(sprintf(_('Could not join user %1$s to group %2$s.'),
|
||||||
common_log_db_error($member, 'INSERT', __FILE__);
|
$cur->nickname, $this->group->nickname));
|
||||||
$this->serverError(
|
|
||||||
sprintf(
|
|
||||||
// TRANS: Server error displayed when joining a group fails.
|
|
||||||
// TRANS: %1$s is a user nickname, $2$s is a group nickname.
|
|
||||||
_('Could not join user %1$s to group %2$s.'),
|
|
||||||
$this->user->nickname,
|
|
||||||
$this->group->nickname
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,22 +116,18 @@ class ApiGroupLeaveAction extends ApiAuthAction
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $member->delete();
|
try {
|
||||||
|
if (Event::handle('StartLeaveGroup', array($this->group,$this->user))) {
|
||||||
if (!$result) {
|
Group_member::leave($this->group->id, $this->user->id);
|
||||||
common_log_db_error($member, 'DELETE', __FILE__);
|
Event::handle('EndLeaveGroup', array($this->group, $this->user));
|
||||||
$this->serverError(
|
}
|
||||||
sprintf(
|
} catch (Exception $e) {
|
||||||
// TRANS: Server error displayed when leaving a group fails.
|
// TRANS: Server error displayed when leaving a group failed in the database.
|
||||||
// TRANS: %1$s is a user nickname, $2$s is a group nickname.
|
// TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
|
||||||
_('Could not remove user %1$s from group %2$s.'),
|
$this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'),
|
||||||
$this->user->nickname,
|
$cur->nickname, $this->group->nickname));
|
||||||
$this->group->nickname
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->showSingleXmlGroup($this->group);
|
$this->showSingleXmlGroup($this->group);
|
||||||
|
Loading…
Reference in New Issue
Block a user