@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add some basic sound preferences

Summary: Ref T7567. This adds some constants (for adding new sounds), global setting for turning on and off sound (setting) and per thread preference for sound choice. Also specc'd out Mentions, if added.

Test Plan: I tested all the preference wiring, but need to set up notifications locally to verify if this works. Feel free to test.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: amckinley, Korvin

Maniphest Tasks: T7567

Differential Revision: https://secure.phabricator.com/D17726

+188 -16
+4
src/__phutil_library_map__.php
··· 311 311 'ConpherenceReplyHandler' => 'applications/conpherence/mail/ConpherenceReplyHandler.php', 312 312 'ConpherenceRoomListController' => 'applications/conpherence/controller/ConpherenceRoomListController.php', 313 313 'ConpherenceRoomPictureController' => 'applications/conpherence/controller/ConpherenceRoomPictureController.php', 314 + 'ConpherenceRoomSettings' => 'applications/conpherence/constants/ConpherenceRoomSettings.php', 314 315 'ConpherenceRoomTestCase' => 'applications/conpherence/__tests__/ConpherenceRoomTestCase.php', 315 316 'ConpherenceSchemaSpec' => 'applications/conpherence/storage/ConpherenceSchemaSpec.php', 316 317 'ConpherenceTestCase' => 'applications/conpherence/__tests__/ConpherenceTestCase.php', ··· 2398 2399 'PhabricatorConpherenceNotificationsSetting' => 'applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php', 2399 2400 'PhabricatorConpherencePreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php', 2400 2401 'PhabricatorConpherenceProfileMenuItem' => 'applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php', 2402 + 'PhabricatorConpherenceSoundSetting' => 'applications/settings/setting/PhabricatorConpherenceSoundSetting.php', 2401 2403 'PhabricatorConpherenceThreadPHIDType' => 'applications/conpherence/phid/PhabricatorConpherenceThreadPHIDType.php', 2402 2404 'PhabricatorConpherenceWidgetVisibleSetting' => 'applications/settings/setting/PhabricatorConpherenceWidgetVisibleSetting.php', 2403 2405 'PhabricatorConsoleApplication' => 'applications/console/application/PhabricatorConsoleApplication.php', ··· 5103 5105 'ConpherenceReplyHandler' => 'PhabricatorMailReplyHandler', 5104 5106 'ConpherenceRoomListController' => 'ConpherenceController', 5105 5107 'ConpherenceRoomPictureController' => 'ConpherenceController', 5108 + 'ConpherenceRoomSettings' => 'ConpherenceConstants', 5106 5109 'ConpherenceRoomTestCase' => 'ConpherenceTestCase', 5107 5110 'ConpherenceSchemaSpec' => 'PhabricatorConfigSchemaSpec', 5108 5111 'ConpherenceTestCase' => 'PhabricatorTestCase', ··· 7505 7508 'PhabricatorConpherenceNotificationsSetting' => 'PhabricatorSelectSetting', 7506 7509 'PhabricatorConpherencePreferencesSettingsPanel' => 'PhabricatorEditEngineSettingsPanel', 7507 7510 'PhabricatorConpherenceProfileMenuItem' => 'PhabricatorProfileMenuItem', 7511 + 'PhabricatorConpherenceSoundSetting' => 'PhabricatorSelectSetting', 7508 7512 'PhabricatorConpherenceThreadPHIDType' => 'PhabricatorPHIDType', 7509 7513 'PhabricatorConpherenceWidgetVisibleSetting' => 'PhabricatorInternalSetting', 7510 7514 'PhabricatorConsoleApplication' => 'PhabricatorApplication',
+31
src/applications/conpherence/constants/ConpherenceRoomSettings.php
··· 1 + <?php 2 + 3 + final class ConpherenceRoomSettings extends ConpherenceConstants { 4 + 5 + const SOUND_RECEIVE = 'receive'; 6 + const SOUND_MENTION = 'mention'; 7 + 8 + const DEFAULT_RECEIVE_SOUND = 'tap'; 9 + const DEFAULT_MENTION_SOUND = 'tap'; // Upload a new sound 10 + const DEFAULT_NO_SOUND = 'none'; 11 + 12 + public static function getSoundMap() { 13 + return array( 14 + 'none' => array( 15 + 'name' => pht('No Sound'), 16 + 'rsrc' => '', 17 + ), 18 + 'tap' => array( 19 + 'name' => pht('Tap'), 20 + 'rsrc' => celerity_get_resource_uri('/rsrc/audio/basic/tap.mp3'), 21 + ), 22 + ); 23 + } 24 + 25 + public static function getDropdownSoundMap() { 26 + $map = self::getSoundMap(); 27 + return ipull($map, 'name'); 28 + } 29 + 30 + 31 + }
+72 -16
src/applications/conpherence/controller/ConpherenceUpdateController.php
··· 115 115 break; 116 116 case ConpherenceUpdateActions::NOTIFICATIONS: 117 117 $notifications = $request->getStr('notifications'); 118 + $sounds = $request->getArr('sounds'); 118 119 $participant = $conpherence->getParticipantIfExists($user->getPHID()); 119 120 if (!$participant) { 120 121 return id(new Aphront404Response()); 121 122 } 122 123 $participant->setSettings(array('notifications' => $notifications)); 124 + $participant->setSettings(array('sounds' => $sounds)); 123 125 $participant->save(); 124 126 return id(new AphrontRedirectResponse()) 125 127 ->setURI('/'.$conpherence->getMonogram()); ··· 266 268 $notification_key = PhabricatorConpherenceNotificationsSetting::SETTINGKEY; 267 269 $notification_default = $user->getUserSetting($notification_key); 268 270 271 + $sound_key = PhabricatorConpherenceSoundSetting::SETTINGKEY; 272 + $sound_default = $user->getUserSetting($sound_key); 273 + 269 274 $settings = $participant->getSettings(); 270 - $notifications = idx( 271 - $settings, 272 - 'notifications', 273 - $notification_default); 275 + $notifications = idx($settings, 'notifications', $notification_default); 276 + 277 + $sounds = idx($settings, 'sounds', array()); 278 + $map = PhabricatorConpherenceSoundSetting::getDefaultSound($sound_default); 279 + $receive = idx($sounds, 280 + ConpherenceRoomSettings::SOUND_RECEIVE, 281 + $map[ConpherenceRoomSettings::SOUND_RECEIVE]); 282 + $mention = idx($sounds, 283 + ConpherenceRoomSettings::SOUND_MENTION, 284 + $map[ConpherenceRoomSettings::SOUND_MENTION]); 274 285 275 286 $form = id(new AphrontFormView()) 276 287 ->setUser($user) 277 - ->setFullWidth(true) 278 288 ->appendControl( 279 - id(new AphrontFormRadioButtonControl()) 280 - ->addButton( 289 + id(new AphrontFormRadioButtonControl()) 290 + ->setLabel(pht('Notify')) 291 + ->addButton( 281 292 PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL, 282 293 PhabricatorConpherenceNotificationsSetting::getSettingLabel( 283 294 PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL), 284 - '') 285 - ->addButton( 295 + '') 296 + ->addButton( 286 297 PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY, 287 298 PhabricatorConpherenceNotificationsSetting::getSettingLabel( 288 299 PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY), 289 - '') 290 - ->setName('notifications') 291 - ->setValue($notifications)); 300 + '') 301 + ->setName('notifications') 302 + ->setValue($notifications)) 303 + ->appendChild( 304 + id(new AphrontFormSelectControl()) 305 + ->setLabel(pht('Message Received')) 306 + ->setName('sounds['.ConpherenceRoomSettings::SOUND_RECEIVE.']') 307 + ->setOptions(ConpherenceRoomSettings::getDropdownSoundMap()) 308 + ->setValue($receive)); 309 + 310 + // TODO: Future Adventure! Expansion Pack 311 + // 312 + // ->appendChild( 313 + // id(new AphrontFormSelectControl()) 314 + // ->setLabel(pht('Username Mentioned')) 315 + // ->setName('sounds['.ConpherenceRoomSettings::SOUND_MENTION.']') 316 + // ->setOptions(ConpherenceRoomSettings::getDropdownSoundMap()) 317 + // ->setValue($mention)); 292 318 293 319 return id(new AphrontDialogView()) 294 320 ->setTitle(pht('Room Preferences')) ··· 496 522 ->executeOne(); 497 523 498 524 $non_update = false; 525 + $participant = $conpherence->getParticipant($user->getPHID()); 526 + 499 527 if ($need_transactions && $conpherence->getTransactions()) { 500 528 $data = ConpherenceTransactionRenderer::renderTransactions( 501 529 $user, ··· 503 531 $key = PhabricatorConpherenceColumnMinimizeSetting::SETTINGKEY; 504 532 $minimized = $user->getUserSetting($key); 505 533 if (!$minimized) { 506 - $participant_obj = $conpherence->getParticipant($user->getPHID()); 507 - $participant_obj 508 - ->markUpToDate($conpherence, $data['latest_transaction']); 534 + $participant->markUpToDate($conpherence, $data['latest_transaction']); 509 535 } 510 536 } else if ($need_transactions) { 511 537 $non_update = true; ··· 547 573 ->setViewer($user); 548 574 $dropdown_query->execute(); 549 575 550 - $receive_sound = celerity_get_resource_uri('/rsrc/audio/basic/tap.mp3'); 576 + $sounds = $this->getSoundForParticipant($user, $participant); 577 + $receive_sound = $sounds[ConpherenceRoomSettings::SOUND_RECEIVE]; 578 + $mention_sound = $sounds[ConpherenceRoomSettings::SOUND_MENTION]; 551 579 552 580 $content = array( 553 581 'non_update' => $non_update, ··· 564 592 ), 565 593 'sound' => array( 566 594 'receive' => $receive_sound, 595 + 'mention' => $mention_sound, 567 596 ), 568 597 ); 569 598 570 599 return $content; 600 + } 601 + 602 + protected function getSoundForParticipant( 603 + PhabricatorUser $user, 604 + ConpherenceParticipant $participant) { 605 + 606 + $sound_key = PhabricatorConpherenceSoundSetting::SETTINGKEY; 607 + $sound_default = $user->getUserSetting($sound_key); 608 + 609 + $settings = $participant->getSettings(); 610 + $sounds = idx($settings, 'sounds', array()); 611 + $map = PhabricatorConpherenceSoundSetting::getDefaultSound($sound_default); 612 + 613 + $receive = idx($sounds, 614 + ConpherenceRoomSettings::SOUND_RECEIVE, 615 + $map[ConpherenceRoomSettings::SOUND_RECEIVE]); 616 + $mention = idx($sounds, 617 + ConpherenceRoomSettings::SOUND_MENTION, 618 + $map[ConpherenceRoomSettings::SOUND_MENTION]); 619 + 620 + $sound_map = ConpherenceRoomSettings::getSoundMap(); 621 + 622 + return array( 623 + ConpherenceRoomSettings::SOUND_RECEIVE => $sound_map[$receive]['rsrc'], 624 + ConpherenceRoomSettings::SOUND_MENTION => $sound_map[$mention]['rsrc'], 625 + ); 626 + 571 627 } 572 628 573 629 }
+81
src/applications/settings/setting/PhabricatorConpherenceSoundSetting.php
··· 1 + <?php 2 + 3 + final class PhabricatorConpherenceSoundSetting 4 + extends PhabricatorSelectSetting { 5 + 6 + const SETTINGKEY = 'conpherence-sound'; 7 + 8 + const VALUE_CONPHERENCE_SILENT = '0'; 9 + const VALUE_CONPHERENCE_MENTION = '1'; 10 + const VALUE_CONPHERENCE_ALL = '2'; 11 + 12 + public function getSettingName() { 13 + return pht('Conpherence Sound'); 14 + } 15 + 16 + public function getSettingPanelKey() { 17 + return PhabricatorConpherencePreferencesSettingsPanel::PANELKEY; 18 + } 19 + 20 + protected function getControlInstructions() { 21 + return pht( 22 + 'Choose the default sound behavior for new Conpherence rooms.'); 23 + } 24 + 25 + protected function isEnabledForViewer(PhabricatorUser $viewer) { 26 + return PhabricatorApplication::isClassInstalledForViewer( 27 + 'PhabricatorConpherenceApplication', 28 + $viewer); 29 + } 30 + 31 + public function getSettingDefaultValue() { 32 + return self::VALUE_CONPHERENCE_ALL; 33 + } 34 + 35 + protected function getSelectOptions() { 36 + return self::getOptionsMap(); 37 + } 38 + 39 + public static function getSettingLabel($key) { 40 + $labels = self::getOptionsMap(); 41 + return idx($labels, $key, pht('Unknown ("%s")', $key)); 42 + } 43 + 44 + public static function getDefaultSound($value) { 45 + switch ($value) { 46 + case self::VALUE_CONPHERENCE_ALL: 47 + return array( 48 + ConpherenceRoomSettings::SOUND_RECEIVE => 49 + ConpherenceRoomSettings::DEFAULT_RECEIVE_SOUND, 50 + ConpherenceRoomSettings::SOUND_MENTION => 51 + ConpherenceRoomSettings::DEFAULT_MENTION_SOUND, 52 + ); 53 + break; 54 + case self::VALUE_CONPHERENCE_MENTION: 55 + return array( 56 + ConpherenceRoomSettings::SOUND_RECEIVE => 57 + ConpherenceRoomSettings::DEFAULT_NO_SOUND, 58 + ConpherenceRoomSettings::SOUND_MENTION => 59 + ConpherenceRoomSettings::DEFAULT_MENTION_SOUND, 60 + ); 61 + break; 62 + case self::VALUE_CONPHERENCE_SILENT: 63 + return array( 64 + ConpherenceRoomSettings::SOUND_RECEIVE => 65 + ConpherenceRoomSettings::DEFAULT_NO_SOUND, 66 + ConpherenceRoomSettings::SOUND_MENTION => 67 + ConpherenceRoomSettings::DEFAULT_NO_SOUND, 68 + ); 69 + break; 70 + } 71 + } 72 + 73 + private static function getOptionsMap() { 74 + return array( 75 + self::VALUE_CONPHERENCE_SILENT => pht('No Sounds'), 76 + // self::VALUE_CONPHERENCE_MENTION => pht('Mentions Only'), 77 + self::VALUE_CONPHERENCE_ALL => pht('All Messages'), 78 + ); 79 + } 80 + 81 + }