feat(slack): ask the other person too, and put rating before sharing
ci / lint-test (push) Successful in 43s
ci / lint-test (push) Successful in 43s
Two halves of the same requirement, one of which was quietly missing. Sharing split the money but never reached her: she is not in #smarthome, so the card whose caption said "both verdicts welcome" was one she could not see. Now a share DMs her a card of her own. A DM rather than adding her to the channel, so her surface stays "orders that concern me" instead of the whole house's ops feed. She was already in SLACK_USER_MAP, so her press files under participant 4. Only on the press that turns sharing ON, and only when someone else did the sharing. Re-notifying on every later rating press would turn one shared meal into a stream of DMs, which is how a nudge gets muted. Her card carries no share button: she is being told it was shared, not asked to decide, and two people toggling one split from separate copies of a card is a race with no upside. The app still holds no Slack bot token — it returns a notify instruction and n8n sends it, the same shape as the modal open. If SLACK_USER_MAP has no id for her the DM is skipped silently: the split is correct and complete either way, and failing the press over an unaddressable nudge would be the worse trade. Card reordered to rate -> details -> share. You judge the food, then decide who pays for it; asking "was this shared?" first inverts the order a person thinks in. The status caption moved under the share button it describes rather than sitting orphaned mid-card.
This commit is contained in:
@@ -47,6 +47,16 @@ export function verifySlackSignature(
|
||||
* two-person household a wrong attribution is not a rounding error, it is the
|
||||
* other person's opinion recorded under your name.
|
||||
*/
|
||||
/** The reverse: which Slack user is this participant, for DMing them. */
|
||||
export function slackUserForParticipant(participantId: number): string | null {
|
||||
const map = process.env.SLACK_USER_MAP ?? "";
|
||||
for (const pair of map.split(",")) {
|
||||
const [slack, participant] = pair.split(":").map((s) => s.trim());
|
||||
if (slack && Number(participant) === participantId) return slack;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function participantForSlackUser(slackUserId: string): number | null {
|
||||
const map = process.env.SLACK_USER_MAP ?? "";
|
||||
for (const pair of map.split(",")) {
|
||||
|
||||
Reference in New Issue
Block a user