Fossil

Check-in [1f5474ec31]
Login

Check-in [1f5474ec31]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Do not require that the chat-timeline robot username be an actual user in the USER table. If the chat-timeline-user config variable exists, then timeline events are announced in chat, regardless.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1f5474ec319780d36a6b1c3098e53f0abd81f24ce4683f43490adf4776898434
User & Date: drh 2022-09-14 19:24:31.815
Context
2022-09-15
15:35
Improved chat messages for the chat-timeline-robot. ... (check-in: 974cf3667c user: drh tags: trunk)
2022-09-14
19:24
Do not require that the chat-timeline robot username be an actual user in the USER table. If the chat-timeline-user config variable exists, then timeline events are announced in chat, regardless. ... (check-in: 1f5474ec31 user: drh tags: trunk)
2022-09-13
20:11
Add the ability to designate a timeline robot user. If such a user exists, and if chat is enabled, then notifications of all timeline events appear in chat, from the robot user. ... (check-in: e9d7cf3e92 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/alerts.c.
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
      "    SELECT printf('%%.1c%%d',new.type,new.objid) WHERE true\n"
      "    ON CONFLICT(eventId) DO NOTHING;\n"
      "END;"
    );
  }
  if( db_table_exists("repository","chat") ){
    const char *zChatUser = db_get("chat-timeline-user", 0);
    char *zChatCaps;
    if( zChatUser==0 || zChatUser[0]==0 ) return;
    zChatCaps = db_text(0, "SELECT cap FROM user WHERE login=%Q", zChatUser);
    if( zChatCaps && strchr(zChatCaps,'C')!=0 ){
      db_multi_exec(
         "CREATE TRIGGER temp.chat_trigger1\n"
         "AFTER INSERT ON repository.event BEGIN\n"
         "  INSERT INTO chat(mtime,xfrom,xmsg)"
         "  SELECT julianday(), %Q,"
                 " format('[%%.12s]: %%s', blob.uuid, new.comment)"
         "  FROM blob WHERE rid=new.objid;\n"
         "END;\n",
         zChatUser
      );
    }
    fossil_free(zChatCaps);
  }
}

/*
** Disable triggers the event_pending and chat triggers.
**
** This must be called before rebuilding the EVENT table, for example







<
|
<
<











<







158
159
160
161
162
163
164

165


166
167
168
169
170
171
172
173
174
175
176

177
178
179
180
181
182
183
      "    SELECT printf('%%.1c%%d',new.type,new.objid) WHERE true\n"
      "    ON CONFLICT(eventId) DO NOTHING;\n"
      "END;"
    );
  }
  if( db_table_exists("repository","chat") ){
    const char *zChatUser = db_get("chat-timeline-user", 0);

    if( zChatUser && zChatUser[0] ){


      db_multi_exec(
         "CREATE TRIGGER temp.chat_trigger1\n"
         "AFTER INSERT ON repository.event BEGIN\n"
         "  INSERT INTO chat(mtime,xfrom,xmsg)"
         "  SELECT julianday(), %Q,"
                 " format('[%%.12s]: %%s', blob.uuid, new.comment)"
         "  FROM blob WHERE rid=new.objid;\n"
         "END;\n",
         zChatUser
      );
    }

  }
}

/*
** Disable triggers the event_pending and chat triggers.
**
** This must be called before rebuilding the EVENT table, for example
Changes to src/chat.c.
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
**
** This is the name of the builtin sound file to use for the alert tone.
** The value must be the name of a builtin WAV file.
*/
/*
** SETTING: chat-timeline-user    width=10
**
** If this setting is defined and is not an empty string and its value is
** the name of a user that hash chat privilege (privilege letter "C"), then
** timeline events are posted to the chat as they arrive. The synthesized
** chat messages appear to come from the user identified by this setting,
** not the user on the timeline event.
**
** All chat messages that come from the chat-timeline-user are interpreted
** as text/x-fossil-wiki instead of as text/markdown.  For this reason,
** the chat-timeline-user name should probably not be a real user.







|
<







128
129
130
131
132
133
134
135

136
137
138
139
140
141
142
**
** This is the name of the builtin sound file to use for the alert tone.
** The value must be the name of a builtin WAV file.
*/
/*
** SETTING: chat-timeline-user    width=10
**
** If this setting is defined and is not an empty string, then

** timeline events are posted to the chat as they arrive. The synthesized
** chat messages appear to come from the user identified by this setting,
** not the user on the timeline event.
**
** All chat messages that come from the chat-timeline-user are interpreted
** as text/x-fossil-wiki instead of as text/markdown.  For this reason,
** the chat-timeline-user name should probably not be a real user.
Changes to src/setup.c.
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
  @ default setting of approximately 7 minutes works well on many systems.
  @ Shorter delays might be required on installations that use proxies
  @ or web-servers with short timeouts.  For best efficiency, this value
  @ should be larger rather than smaller.
  @ (Property: "chat-poll-timeout")</p>
  @ <hr />
  entry_attribute("Chat Timeline Robot Username", 15,
                  "chat-timeout-user", "chatrobot", "", 0);
  @ <p>If this setting is the name of a user that has "C" privilege, then
  @ all changes to the timeline will result in a new chat message from this
  @ user.  Leave this blank to omit notifications of check-ins and other
  @ timeline events from appearing in chat.
  @ (Property: "chat-timeout-user")</p>
  @ <hr />

  multiple_choice_attribute("Alert sound",
     "chat-alert-sound", "snd", azAlerts[0],
     count(azAlerts)/2, azAlerts);
  @ <p>The sound used in the client-side chat to indicate that a new
  @ chat message has arrived.







|
|
|
|
<
|







1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361

1362
1363
1364
1365
1366
1367
1368
1369
  @ default setting of approximately 7 minutes works well on many systems.
  @ Shorter delays might be required on installations that use proxies
  @ or web-servers with short timeouts.  For best efficiency, this value
  @ should be larger rather than smaller.
  @ (Property: "chat-poll-timeout")</p>
  @ <hr />
  entry_attribute("Chat Timeline Robot Username", 15,
                  "chat-timeline-user", "chatrobot", "", 0);
  @ <p>If this setting is not an empty string, then any changes that appear
  @ on the timeline are announced in the chatroom under the username
  @ supplied.  That user does not need to actually exist in the USER table.

  @ (Property: "chat-timeline-user")</p>
  @ <hr />

  multiple_choice_attribute("Alert sound",
     "chat-alert-sound", "snd", azAlerts[0],
     count(azAlerts)/2, azAlerts);
  @ <p>The sound used in the client-side chat to indicate that a new
  @ chat message has arrived.